various changes related to refactor of header files

This commit is contained in:
2020-02-05 12:45:06 +04:00
parent 064951f4c8
commit ef055f0324
24 changed files with 96 additions and 64 deletions
+15 -1
View File
@@ -1,4 +1,16 @@
#pragma once #ifndef __PST_REGISTERS_H__
#define __PST_REGISTERS_H__
/*
* registers.cpp
*
* x86_64 registers mapping to DWARF registers
*
* Created on: Jan 27, 2020
* Author: nnosov
*/
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -22,3 +34,5 @@ typedef enum {
} pst_reg_error; } pst_reg_error;
pst_reg_error pst_get_reg(pst_context* ctx, int regno, uint64_t& regval); pst_reg_error pst_get_reg(pst_context* ctx, int regno, uint64_t& regval);
#endif /* __PST_REGISTERS_H__ */
+7
View File
@@ -1,5 +1,12 @@
#ifndef __PST_COMMON_H__ #ifndef __PST_COMMON_H__
#define __PST_COMMON_H__ #define __PST_COMMON_H__
/*
* common.h
*
* Created on: Jan 8, 2020
* Author: nnosov
*/
#include <stdint.h> #include <stdint.h>
+2 -2
View File
@@ -10,8 +10,8 @@
#include "context.h" #include "context.h"
#include "../src/dwarf/dwarf_operations.h" #include "dwarf/dwarf_operations.h"
#include "registers.h" #include "arch/registers.h"
extern dwarf_reg_map reg_map[]; extern dwarf_reg_map reg_map[];
+2 -2
View File
@@ -14,8 +14,8 @@
#include <libunwind.h> #include <libunwind.h>
#include <elfutils/libdwfl.h> #include <elfutils/libdwfl.h>
#include "../src/utils/allocator.h" #include "utils/allocator.h"
#include "../src/utils/log.h" #include "utils/log.h"
extern pst_log logger; // logger for whole PST library extern pst_log logger; // logger for whole PST library
extern pst_allocator allocator; // custom allocator for PST library extern pst_allocator allocator; // custom allocator for PST library
+5 -5
View File
@@ -5,15 +5,15 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_call_site.h"
#include <dwarf.h> #include <dwarf.h>
#include <elfutils/libdw.h> #include <elfutils/libdw.h>
#include "../src/dwarf/dwarf_function.h" #include "dwarf_call_site.h"
#include "../src/dwarf/dwarf_utils.h" #include "dwarf_function.h"
#include "../src/dwarf/dwarf_utils.h" #include "dwarf_utils.h"
#include "../utils/hash_multimap.h" #include "dwarf_utils.h"
#include "utils/hash_multimap.h"
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// pst_call_site_param // pst_call_site_param
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_CALL_SITE_H_ #ifndef __PST_DWARF_CALL_SITE_H__
#define SRC_DWARF_DWARF_CALL_SITE_H_ #define __PST_DWARF_CALL_SITE_H__
#include <inttypes.h> #include <inttypes.h>
#include <elfutils/libdw.h> #include <elfutils/libdw.h>
@@ -87,4 +87,4 @@ void pst_call_site_storage_del(pst_call_site_storage* storage, pst_call_site* st
void pst_call_site_storage_del(pst_call_site_storage* storage, pst_call_site* st); void pst_call_site_storage_del(pst_call_site_storage* storage, pst_call_site* st);
#endif /* SRC_DWARF_DWARF_CALL_SITE_H_ */ #endif /* __PST_DWARF_CALL_SITE_H__ */
+2 -2
View File
@@ -5,13 +5,13 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_expression.h"
#include <stdarg.h> #include <stdarg.h>
#include "../utils/allocator.h" #include "utils/allocator.h"
#include "common.h" #include "common.h"
#include "context.h" #include "context.h"
#include "dwarf_expression.h"
// //
// DWARF operation // DWARF operation
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_EXPRESSION_H_ #ifndef __PST_DWARF_EXPRESSION_H__
#define SRC_DWARF_DWARF_EXPRESSION_H_ #define __PST_DWARF_EXPRESSION_H__
#include <inttypes.h> #include <inttypes.h>
#include <elfutils/libdwfl.h> #include <elfutils/libdwfl.h>
@@ -46,4 +46,4 @@ bool pst_dwarf_expr_equal(pst_dwarf_expr* lhs, pst_dwarf_expr* rhs);
bool pst_dwarf_expr_print_op(pst_dwarf_expr* expr, const char* fmt, ...); bool pst_dwarf_expr_print_op(pst_dwarf_expr* expr, const char* fmt, ...);
void pst_dwarf_expr_set_value(pst_dwarf_expr* expr, uint64_t v); void pst_dwarf_expr_set_value(pst_dwarf_expr* expr, uint64_t v);
#endif /* SRC_DWARF_DWARF_EXPRESSION_H_ */ #endif /* __PST_DWARF_EXPRESSION_H__ */
+3 -3
View File
@@ -5,14 +5,14 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_function.h"
#include <dwarf.h> #include <dwarf.h>
#include <stdlib.h> #include <stdlib.h>
#include <cxxabi.h> #include <cxxabi.h>
#include "../src/dwarf/dwarf_stack.h" #include "dwarf_stack.h"
#include "../src/dwarf/dwarf_utils.h" #include "dwarf_utils.h"
#include "dwarf_function.h"
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// pst_function // pst_function
+10 -7
View File
@@ -5,14 +5,17 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_FUNCTION_H_ #ifndef __PST_DWARF_FUNCTION_H__
#define SRC_DWARF_DWARF_FUNCTION_H_ #define __PST_DWARF_FUNCTION_H__
#include "../src/dwarf/dwarf_call_site.h" #include <elfutils/libdw.h>
#include "../src/dwarf/dwarf_expression.h" #include <libunwind.h>
#include "../src/dwarf/dwarf_parameter.h"
#include "../utils/list_head.h" #include "utils/list_head.h"
#include "context.h" #include "context.h"
#include "dwarf_call_site.h"
#include "dwarf_expression.h"
#include "dwarf_parameter.h"
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// pst_function // pst_function
@@ -46,4 +49,4 @@ bool pst_function_unwind(pst_function* fn, Dwarf_Addr addr);
bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d); bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d);
bool pst_function_print_dwarf(pst_function* fn); bool pst_function_print_dwarf(pst_function* fn);
#endif /* SRC_DWARF_DWARF_FUNCTION_H_ */ #endif /* __PST_DWARF_FUNCTION_H__ */
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef PST_HANDLER_H_ #ifndef __PST_DWARF_HANDLER_H__
#define PST_HANDLER_H_ #define __PST_DWARF_HANDLER_H__
//system //system
#include <ucontext.h> #include <ucontext.h>
@@ -29,4 +29,4 @@ bool pst_handler_handle_dwarf(pst_handler* h);
void pst_handler_print_dwarf(pst_handler* h); void pst_handler_print_dwarf(pst_handler* h);
bool pst_handler_unwind(pst_handler* h); bool pst_handler_unwind(pst_handler* h);
#endif /* PST_HANDLER_H_ */ #endif /* __PST_DWARF_HANDLER_H__ */
+1 -1
View File
@@ -5,13 +5,13 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_operations.h"
#include <dwarf.h> #include <dwarf.h>
#include <inttypes.h> #include <inttypes.h>
#include "common.h" #include "common.h"
#include "registers.h" #include "registers.h"
#include "dwarf_operations.h"
// not implemented operations // not implemented operations
bool dw_op_notimpl(pst_dwarf_stack* stack, const dwarf_op_map* map, Dwarf_Word op1, Dwarf_Word op2) bool dw_op_notimpl(pst_dwarf_stack* stack, const dwarf_op_map* map, Dwarf_Word op1, Dwarf_Word op2)
+12 -1
View File
@@ -1,4 +1,13 @@
#pragma once #ifndef __PST_DWARF_OPERATIONS_H__
#define __PST_DWARF_OPERATIONS_H__
/*
* dwarf_operations.cpp
*
* Created on: Jan 11, 2020
* Author: nnosov
*/
#include <elfutils/libdwfl.h> #include <elfutils/libdwfl.h>
@@ -20,3 +29,5 @@ typedef struct __dwarf_op_map {
} dwarf_op_map; } dwarf_op_map;
const dwarf_op_map* find_op_map(int op); const dwarf_op_map* find_op_map(int op);
#endif /* __PST_DWARF_OPERATIONS_H__ */
+2 -2
View File
@@ -5,13 +5,13 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_parameter.h"
#include <dwarf.h> #include <dwarf.h>
#include <elfutils/libdw.h> #include <elfutils/libdw.h>
#include "../src/dwarf/dwarf_utils.h" #include "dwarf_utils.h"
#include "context.h" #include "context.h"
#include "dwarf_parameter.h"
// //
// pst_type // pst_type
+5 -5
View File
@@ -5,14 +5,14 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_PARAMETER_H_ #ifndef __PST_DWARF_PARAMETER_H__
#define SRC_DWARF_DWARF_PARAMETER_H_ #define __PST_DWARF_PARAMETER_H__
#include <inttypes.h> #include <inttypes.h>
#include <elfutils/libdwfl.h> #include <elfutils/libdwfl.h>
#include "../src/dwarf/dwarf_expression.h" #include "dwarf_expression.h"
#include "../utils/list_head.h" #include "utils/list_head.h"
#include "context.h" #include "context.h"
typedef struct __pst_type { typedef struct __pst_type {
@@ -56,4 +56,4 @@ bool pst_parameter_print_dwarf(pst_parameter* param);
bool pst_parameter_handle_type(pst_parameter* param, Dwarf_Attribute* base); bool pst_parameter_handle_type(pst_parameter* param, Dwarf_Attribute* base);
pst_type* pst_parameter_add_type(pst_parameter* param, const char* name, int type); pst_type* pst_parameter_add_type(pst_parameter* param, const char* name, int type);
#endif /* SRC_DWARF_DWARF_PARAMETER_H_ */ #endif /* __PST_DWARF_PARAMETER_H__ */
+4 -4
View File
@@ -5,16 +5,16 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/dwarf/dwarf_stack.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <dwarf.h> #include <dwarf.h>
#include "../src/dwarf/dwarf_operations.h" #include "utils/allocator.h"
#include "../utils/allocator.h" #include "utils/list_head.h"
#include "../utils/list_head.h" #include "dwarf_operations.h"
#include "dwarf_handler.h" #include "dwarf_handler.h"
#include "dwarf_stack.h"
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// DWARF Stack value // DWARF Stack value
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_STACK_H_ #ifndef __PST_DWARF_STACK_H__
#define SRC_DWARF_DWARF_STACK_H_ #define __PST_DWARF_STACK_H__
#include <stdint.h> #include <stdint.h>
@@ -94,4 +94,4 @@ pst_dwarf_value* pst_dwarf_stack_pop(pst_dwarf_stack* st);
void pst_dwarf_stack_push_value(pst_dwarf_stack* st, pst_dwarf_value* value); void pst_dwarf_stack_push_value(pst_dwarf_stack* st, pst_dwarf_value* value);
void pst_dwarf_stack_push(pst_dwarf_stack* st, void* v, uint32_t s, int t); void pst_dwarf_stack_push(pst_dwarf_stack* st, void* v, uint32_t s, int t);
#endif /* SRC_DWARF_DWARF_STACK_H_ */ #endif /* __PST_DWARF_STACK_H__ */
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef SRC_DWARF_DWARF_UTILS_H_ #ifndef __PST_DWARF_UTILS_H__
#define SRC_DWARF_DWARF_UTILS_H_ #define __PST_DWARF_UTILS_H__
#include <elfutils/libdw.h> #include <elfutils/libdw.h>
@@ -27,4 +27,4 @@ int regname_callback (void *arg, int regno, const char *setname, const char *pre
bool handle_location(pst_context* ctx, Dwarf_Attribute* attr, pst_dwarf_expr* loc, Dwarf_Addr pc, pst_function* fun); bool handle_location(pst_context* ctx, Dwarf_Attribute* attr, pst_dwarf_expr* loc, Dwarf_Addr pc, pst_function* fun);
bool is_location_form(int form); bool is_location_form(int form);
#endif /* SRC_DWARF_DWARF_UTILS_H_ */ #endif /* __PST_DWARF_UTILS_H__ */
+1 -1
View File
@@ -5,12 +5,12 @@
* Author: nnosov * Author: nnosov
*/ */
#include "../src/utils/allocator.h"
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include "allocator.h"
#include "common.h" #include "common.h"
void heap_free(pst_allocator* alloc, void* buff) void heap_free(pst_allocator* alloc, void* buff)
+3 -3
View File
@@ -5,8 +5,8 @@
* Author: nnosov * Author: nnosov
*/ */
#ifndef PST_ALLOCATOR_H_ #ifndef __PST_ALLOCATOR_H__
#define PST_ALLOCATOR_H_ #define __PST_ALLOCATOR_H__
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
@@ -56,4 +56,4 @@ void pst_alloc_init(pst_allocator* alloc);
void pst_alloc_init_custom(pst_allocator* alloc, void* buff, uint32_t size); void pst_alloc_init_custom(pst_allocator* alloc, void* buff, uint32_t size);
void pst_alloc_fini(pst_allocator* alloc); void pst_alloc_fini(pst_allocator* alloc);
#endif /* PST_ALLOCATOR_H_ */ #endif /* __PST_ALLOCATOR_H__ */
+1 -1
View File
@@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
Copyright (c) 2006, Nikolay Nosov Copyright (c) 2006, Nikolai Nosov
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
+2 -1
View File
@@ -1,8 +1,9 @@
#include "../../src/utils/log.h"
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include "log.h"
const char * const severity_map[] = { const char * const severity_map[] = {
" [DEBUG] : ", " [DEBUG] : ",
" [INFO] : ", " [INFO] : ",
+4 -6
View File
@@ -1,5 +1,5 @@
#ifndef PST_LOG_H_ #ifndef __PST_LOG_H_
#define PST_LOG_H_ #define __PST_LOG_H_
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
@@ -20,9 +20,7 @@ enum SC_LogSeverity {
#define LOG_BUFF_SIZE (1024*1024) #define LOG_BUFF_SIZE (1024*1024)
typedef struct __pst_log pst_log; typedef struct pst_log {
typedef struct __pst_log {
// methods // methods
void (*close) (pst_log* log); void (*close) (pst_log* log);
bool (*open) (pst_log* log); bool (*open) (pst_log* log);
@@ -47,4 +45,4 @@ void pst_log_init_console(pst_log* log);
void pst_log_init_file(pst_log* log, const char* path, uint64_t max_bytes = 64 * 1024 * 1024/* 64Mb */); void pst_log_init_file(pst_log* log, const char* path, uint64_t max_bytes = 64 * 1024 * 1024/* 64Mb */);
void pst_log_fini(pst_log* log); void pst_log_fini(pst_log* log);
#endif /* PST_LOG_H_ */ #endif /* __PST_LOG_H_ */
-2
View File
@@ -1,6 +1,5 @@
#include <stdio.h> #include <stdio.h>
void do_stuff(int my_arg) void do_stuff(int my_arg)
{ {
int my_local = my_arg + 2; int my_local = my_arg + 2;
@@ -10,7 +9,6 @@ void do_stuff(int my_arg)
printf("i = %d\n", i); printf("i = %d\n", i);
} }
int main() int main()
{ {
do_stuff(2); do_stuff(2);