minor refactoring
This commit is contained in:
@@ -196,7 +196,7 @@ void pst_context_fini(pst_context* ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* pst_dup(const char* str)
|
char* pst_strdup(const char* str)
|
||||||
{
|
{
|
||||||
pst_assert(str);
|
pst_assert(str);
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -18,22 +18,23 @@
|
|||||||
#include "allocator.h"
|
#include "allocator.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 PS library
|
extern pst_allocator allocator; // custom allocator for PST library
|
||||||
|
|
||||||
#define pst_alloc(TYPE) (TYPE*)allocator.alloc(&allocator, sizeof(TYPE))
|
#define pst_alloc(TYPE) (TYPE*)allocator.alloc(&allocator, sizeof(TYPE))
|
||||||
#define pst_free(NAME) allocator.free(&allocator, NAME)
|
#define pst_free(NAME) allocator.free(&allocator, NAME)
|
||||||
|
|
||||||
#define pst_log(SEVERITY, FORMAT, ...) logger.log(&logger, SEVERITY, FORMAT, ##__VA_ARGS__)
|
#define pst_log(SEVERITY, FORMAT, ...) logger.log(&logger, SEVERITY, FORMAT, ##__VA_ARGS__)
|
||||||
char* pst_dup(const char* str);
|
|
||||||
|
|
||||||
typedef struct __pst_context {
|
char* pst_strdup(const char* str);
|
||||||
|
|
||||||
|
typedef struct pst_context {
|
||||||
// methods
|
// methods
|
||||||
void (*clean_print) (__pst_context* ctx);
|
void (*clean_print) (pst_context* ctx);
|
||||||
bool (*print) (__pst_context* ctx, const char* fmt, ...);
|
bool (*print) (pst_context* ctx, const char* fmt, ...);
|
||||||
void (*log) (SC_LogSeverity severity, const char*fmt, ...);
|
void (*log) (SC_LogSeverity severity, const char*fmt, ...);
|
||||||
bool (*print_expr) (__pst_context* ctx, Dwarf_Op *exprs, int exprlen, Dwarf_Attribute* attr);
|
bool (*print_expr) (pst_context* ctx, Dwarf_Op *exprs, int exprlen, Dwarf_Attribute* attr);
|
||||||
void (*print_registers) (__pst_context* ctx, int from, int to);
|
void (*print_registers) (pst_context* ctx, int from, int to);
|
||||||
void (*print_stack) (__pst_context* ctx, int max, uint64_t next_cfa);
|
void (*print_stack) (pst_context* ctx, int max, uint64_t next_cfa);
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
ucontext_t* hcontext; // context of signal handler
|
ucontext_t* hcontext; // context of signal handler
|
||||||
|
|||||||
@@ -62,10 +62,11 @@ typedef struct pst_call_site {
|
|||||||
pst_context* ctx; // execution context
|
pst_context* ctx; // execution context
|
||||||
bool allocated; // whether this object was allocated or not
|
bool allocated; // whether this object was allocated or not
|
||||||
} pst_call_site;
|
} pst_call_site;
|
||||||
void pst_call_site_init(pst_call_site* site, pst_context* c, uint64_t tgt, const char* orn);
|
void pst_call_site_init(pst_call_site* site, pst_context* context, uint64_t target, const char* origin);
|
||||||
pst_call_site* pst_call_site_new(pst_context* c, uint64_t tgt, const char* orn);
|
pst_call_site* pst_call_site_new(pst_context* context, uint64_t target, const char* origin);
|
||||||
void pst_call_site_fini(pst_call_site* site);
|
void pst_call_site_fini(pst_call_site* site);
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
// storage for all of function's call sites
|
// storage for all of function's call sites
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
void pst_type_init(pst_type* t, const char* name, uint32_t type)
|
void pst_type_init(pst_type* t, const char* name, uint32_t type)
|
||||||
{
|
{
|
||||||
list_node_init(&t->node);
|
list_node_init(&t->node);
|
||||||
t->name = pst_dup(name);
|
t->name = pst_strdup(name);
|
||||||
t->type = type;
|
t->type = type;
|
||||||
t->allocated = false;
|
t->allocated = false;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ bool param_handle_dwarf(pst_parameter* param, Dwarf_Die* result, pst_function* f
|
|||||||
Dwarf_Attribute attr_mem;
|
Dwarf_Attribute attr_mem;
|
||||||
Dwarf_Attribute* attr;
|
Dwarf_Attribute* attr;
|
||||||
|
|
||||||
param->name = pst_dup(dwarf_diename(result));
|
param->name = pst_strdup(dwarf_diename(result));
|
||||||
param->is_variable = (dwarf_tag(result) == DW_TAG_variable);
|
param->is_variable = (dwarf_tag(result) == DW_TAG_variable);
|
||||||
|
|
||||||
dwarf_decl_line(result, (int*)¶m->line);
|
dwarf_decl_line(result, (int*)¶m->line);
|
||||||
|
|||||||
Reference in New Issue
Block a user