use internal linkedlist implementation instead of std::list,
std::vector. make stack trace a bit more complex
This commit is contained in:
+42
-9
@@ -27,7 +27,17 @@ char* GetExecutableName(char* path, uint32_t size);
|
||||
|
||||
typedef struct __pst_function pst_function;
|
||||
|
||||
typedef struct __pst_parameter {
|
||||
typedef struct __pst_type : public SC_ListNode {
|
||||
__pst_type(const char* n, uint32_t t) : type(t) {
|
||||
if(n) {
|
||||
name = n;
|
||||
}
|
||||
}
|
||||
std::string name; // type name
|
||||
uint32_t type; // DW_AT_XXX type
|
||||
} pst_type;
|
||||
|
||||
typedef struct __pst_parameter : public SC_ListNode {
|
||||
__pst_parameter(pst_context* c) : ctx(c)
|
||||
{
|
||||
die = NULL;
|
||||
@@ -41,8 +51,17 @@ typedef struct __pst_parameter {
|
||||
line = 0;
|
||||
}
|
||||
|
||||
~__pst_parameter()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear();
|
||||
pst_type* add_type(const char* name, int type);
|
||||
pst_type* next_type(pst_type* t);
|
||||
|
||||
bool handle_dwarf(Dwarf_Die* d);
|
||||
bool handle_type(Dwarf_Attribute* param, bool is_return = false);
|
||||
bool handle_type(Dwarf_Attribute* param);
|
||||
bool print_dwarf();
|
||||
|
||||
Dwarf_Die* die; // DWARF DIE containing parameter's definition
|
||||
@@ -50,7 +69,7 @@ typedef struct __pst_parameter {
|
||||
uint32_t line; // line of parameter definition
|
||||
Dwarf_Word size; // size of parameter in bytes
|
||||
int type; // base type of parameter in DW_TAG_XXX types enumeration
|
||||
std::vector<std::string> types; // list of parameter's definitions i.e. 'typedef', 'uint32_t'
|
||||
SC_ListHead types; // list of parameter's definitions i.e. 'typedef', 'uint32_t'
|
||||
void* loc; // pointer to location of parameter's value
|
||||
bool is_return; // whether this parameter is return value of the function
|
||||
bool is_variable;// whether this parameter is function variable or argument of function
|
||||
@@ -61,9 +80,8 @@ typedef struct __pst_parameter {
|
||||
|
||||
typedef struct __pst_handler pst_handler;
|
||||
|
||||
typedef struct __pst_function {
|
||||
__pst_function(pst_context* ctx) : ctx(ctx)
|
||||
{
|
||||
typedef struct __pst_function : public SC_ListNode {
|
||||
__pst_function(pst_context* ctx) : ctx(ctx) {
|
||||
pc = 0;
|
||||
line = -1;
|
||||
die = NULL;
|
||||
@@ -71,6 +89,15 @@ typedef struct __pst_function {
|
||||
highpc = 0;
|
||||
}
|
||||
|
||||
~__pst_function() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear();
|
||||
pst_parameter* add_param();
|
||||
void del_param(pst_parameter* p);
|
||||
pst_parameter* next_param(pst_parameter* p);
|
||||
|
||||
bool unwind(Dwfl* dwfl, Dwfl_Module* module, Dwarf_Addr addr);
|
||||
bool handle_dwarf(Dwarf_Die* d);
|
||||
bool print_dwarf();
|
||||
@@ -79,7 +106,7 @@ typedef struct __pst_function {
|
||||
Dwarf_Addr highpc;
|
||||
Dwarf_Die* die; // DWARF DIE containing definition of the function
|
||||
std::string name; // function's name
|
||||
std::vector<pst_parameter> params; // array of function's parameters
|
||||
SC_ListHead params; // array of function's parameters
|
||||
unw_word_t pc; // pointer to the start of the function
|
||||
int line; // line in code where function is defined
|
||||
std::string file; // file name (DWARF Compilation Unit) where is function defined
|
||||
@@ -102,13 +129,19 @@ typedef struct __pst_handler {
|
||||
if(handle) {
|
||||
dlclose(handle);
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear();
|
||||
pst_function* add_function();
|
||||
void del_function(pst_function* f);
|
||||
pst_function* next_function(pst_function* f);
|
||||
|
||||
void print_dwarf();
|
||||
bool unwind();
|
||||
bool get_frame();
|
||||
bool get_dwarf_function(pst_function& fun);
|
||||
bool get_dwarf_function(pst_function* fun);
|
||||
|
||||
pst_context ctx; // context of unwinding
|
||||
void* handle; // process handle
|
||||
@@ -117,7 +150,7 @@ typedef struct __pst_handler {
|
||||
Dwfl_Module* module; // currently processed CU
|
||||
Dwarf_Frame* frame; // currently processed stack frame
|
||||
void* caller; // pointer to the function which requested to unwind stack
|
||||
std::vector<pst_function> functions; // array of functions in stack frame
|
||||
SC_ListHead functions; // list of functions in stack frame
|
||||
} pst_handler;
|
||||
|
||||
#endif /* SC_SYSUTILS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user