rename function-related function's names
This commit is contained in:
+30
-19
@@ -115,19 +115,7 @@ static void clear(pst_function* fn)
|
|||||||
pst_call_site_storage_fini(&fn->call_sites);
|
pst_call_site_storage_fini(&fn->call_sites);
|
||||||
}
|
}
|
||||||
|
|
||||||
pst_parameter* pst_function_next_parameter(pst_function* fn, pst_parameter* p)
|
static bool handle_lexical_block(pst_function* fn, Dwarf_Die* result)
|
||||||
{
|
|
||||||
struct list_node* n = (p == NULL) ? list_first(&fn->params) : list_next(&p->node);
|
|
||||||
|
|
||||||
pst_parameter* ret = NULL;
|
|
||||||
if(n) {
|
|
||||||
ret = list_entry(n, pst_parameter, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool handle_lexical_block(pst_function* fn, Dwarf_Die* result)
|
|
||||||
{
|
{
|
||||||
uint64_t lowpc = 0, highpc = 0; const char* origin_name = "";
|
uint64_t lowpc = 0, highpc = 0; const char* origin_name = "";
|
||||||
dwarf_lowpc(result, &lowpc);
|
dwarf_lowpc(result, &lowpc);
|
||||||
@@ -188,7 +176,30 @@ bool handle_lexical_block(pst_function* fn, Dwarf_Die* result)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pst_function_print_dwarf(pst_function* fn)
|
pst_parameter* function_next_parameter(pst_function* fn, pst_parameter* p)
|
||||||
|
{
|
||||||
|
struct list_node* n = (p == NULL) ? list_first(&fn->params) : list_next(&p->node);
|
||||||
|
|
||||||
|
pst_parameter* ret = NULL;
|
||||||
|
if(n) {
|
||||||
|
ret = list_entry(n, pst_parameter, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void function_print_simple(pst_function* fn)
|
||||||
|
{
|
||||||
|
fn->ctx->print(fn->ctx, "%s() ", fn->info.name);
|
||||||
|
if(fn->info.file) {
|
||||||
|
fn->ctx->print(fn->ctx, "at %s:%d, %p", fn->info.file, fn->info.line, (void*)fn->info.pc);
|
||||||
|
} else {
|
||||||
|
fn->ctx->print(fn->ctx, "at %p", (void*)fn->info.pc);
|
||||||
|
}
|
||||||
|
fn->ctx->print(fn->ctx, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool function_print_pretty(pst_function* fn)
|
||||||
{
|
{
|
||||||
char* at = NULL;
|
char* at = NULL;
|
||||||
if(fn->info.file) {
|
if(fn->info.file) {
|
||||||
@@ -199,18 +210,18 @@ bool pst_function_print_dwarf(pst_function* fn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle return parameter and be safe if function haven't parameters (for example, dwar info for function is absent)
|
// handle return parameter and be safe if function haven't parameters (for example, dwar info for function is absent)
|
||||||
pst_parameter* param = pst_function_next_parameter(fn, NULL);
|
pst_parameter* param = function_next_parameter(fn, NULL);
|
||||||
if(param && (param->info.flags & PARAM_RETURN)) {
|
if(param && (param->info.flags & PARAM_RETURN)) {
|
||||||
// print return value type, function name and start list of parameters
|
// print return value type, function name and start list of parameters
|
||||||
parameter_print(param);
|
parameter_print(param);
|
||||||
fn->ctx->print(fn->ctx, " %s(", fn->info.name);
|
fn->ctx->print(fn->ctx, " %s(", fn->info.name);
|
||||||
param = pst_function_next_parameter(fn, param);
|
param = function_next_parameter(fn, param);
|
||||||
} else {
|
} else {
|
||||||
fn->ctx->print(fn->ctx, "%s(", fn->info.name);
|
fn->ctx->print(fn->ctx, "%s(", fn->info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool first = true; bool start_variable = false;
|
bool first = true; bool start_variable = false;
|
||||||
for(; param; param = pst_function_next_parameter(fn, param)) {
|
for(; param; param = function_next_parameter(fn, param)) {
|
||||||
if(param->info.flags & PARAM_RETURN) {
|
if(param->info.flags & PARAM_RETURN) {
|
||||||
// print return value type, function name and start list of parameters
|
// print return value type, function name and start list of parameters
|
||||||
parameter_print(param);
|
parameter_print(param);
|
||||||
@@ -251,7 +262,7 @@ bool pst_function_print_dwarf(pst_function* fn)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d)
|
bool function_handle_dwarf(pst_function * fn, Dwarf_Die* d)
|
||||||
{
|
{
|
||||||
fn->die = d;
|
fn->die = d;
|
||||||
get_frame(fn);
|
get_frame(fn);
|
||||||
@@ -378,7 +389,7 @@ bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pst_function_unwind(pst_function* fn)
|
bool function_unwind(pst_function* fn)
|
||||||
{
|
{
|
||||||
Dwfl_Line *dwline = dwfl_getsrc(fn->ctx->dwfl, fn->info.pc);
|
Dwfl_Line *dwline = dwfl_getsrc(fn->ctx->dwfl, fn->info.pc);
|
||||||
if(dwline != NULL) {
|
if(dwline != NULL) {
|
||||||
|
|||||||
@@ -36,9 +36,11 @@ void pst_function_init(pst_function* fn, pst_context* _ctx, pst_function* _paren
|
|||||||
pst_function* pst_function_new(pst_context* _ctx, pst_function* _parent);
|
pst_function* pst_function_new(pst_context* _ctx, pst_function* _parent);
|
||||||
void pst_function_fini(pst_function* fn);
|
void pst_function_fini(pst_function* fn);
|
||||||
|
|
||||||
bool pst_function_unwind(pst_function* fn);
|
bool function_unwind(pst_function* fn);
|
||||||
bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d);
|
bool function_handle_dwarf(pst_function * fn, Dwarf_Die* d);
|
||||||
bool pst_function_print_dwarf(pst_function* fn);
|
bool function_print_pretty(pst_function* fn);
|
||||||
pst_parameter* pst_function_next_parameter(pst_function* fn, pst_parameter* p);
|
void function_print_simple(pst_function* fn);
|
||||||
|
|
||||||
|
pst_parameter* function_next_parameter(pst_function* fn, pst_parameter* p);
|
||||||
|
|
||||||
#endif /* __PST_DWARF_FUNCTION_H__ */
|
#endif /* __PST_DWARF_FUNCTION_H__ */
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ bool get_dwarf_function(pst_handler* h, pst_function* fun)
|
|||||||
if(tag == DW_TAG_subprogram || tag == DW_TAG_entry_point || tag == DW_TAG_inlined_subroutine) {
|
if(tag == DW_TAG_subprogram || tag == DW_TAG_entry_point || tag == DW_TAG_inlined_subroutine) {
|
||||||
//ctx.log(SEVERITY_DEBUG, "function die name %s", dwarf_diename(&result));
|
//ctx.log(SEVERITY_DEBUG, "function die name %s", dwarf_diename(&result));
|
||||||
if(!strcmp(fun->info.name, dwarf_diename(&result))) {
|
if(!strcmp(fun->info.name, dwarf_diename(&result))) {
|
||||||
return pst_function_handle_dwarf(fun, &result);
|
return function_handle_dwarf(fun, &result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(dwarf_siblingof(&result, &result) == 0);
|
} while(dwarf_siblingof(&result, &result) == 0);
|
||||||
@@ -169,7 +169,7 @@ const char* pst_print_pretty(pst_handler* h)
|
|||||||
uint32_t idx = 0;
|
uint32_t idx = 0;
|
||||||
for(pst_function* fn = pst_handler_next_function(h, NULL); fn; fn = pst_handler_next_function(h, fn)) {
|
for(pst_function* fn = pst_handler_next_function(h, NULL); fn; fn = pst_handler_next_function(h, fn)) {
|
||||||
h->ctx.print(&h->ctx, "[%-2u] ", idx); idx++;
|
h->ctx.print(&h->ctx, "[%-2u] ", idx); idx++;
|
||||||
pst_function_print_dwarf(fn);
|
function_print_pretty(fn);
|
||||||
h->ctx.print(&h->ctx, "\n");
|
h->ctx.print(&h->ctx, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,14 +191,8 @@ const char* pst_print_simple(pst_handler* h)
|
|||||||
h->ctx.print(&h->ctx, "Simple unwind-based stack trace:\n");
|
h->ctx.print(&h->ctx, "Simple unwind-based stack trace:\n");
|
||||||
uint32_t idx = 0;
|
uint32_t idx = 0;
|
||||||
for(pst_function* fn = pst_handler_next_function(h, NULL); fn; fn = pst_handler_next_function(h, fn)) {
|
for(pst_function* fn = pst_handler_next_function(h, NULL); fn; fn = pst_handler_next_function(h, fn)) {
|
||||||
h->ctx.print(&h->ctx, "[%-2d] ", idx);
|
h->ctx.print(&h->ctx, "[%-2u] ", idx);
|
||||||
h->ctx.print(fn->ctx, "%s() ", fn->info.name);
|
function_print_simple(fn);
|
||||||
if(fn->info.file) {
|
|
||||||
h->ctx.print(fn->ctx, "at %s:%d, %p", fn->info.file, fn->info.line, (void*)fn->info.pc);
|
|
||||||
} else {
|
|
||||||
h->ctx.print(fn->ctx, "at %p", (void*)fn->info.pc);
|
|
||||||
}
|
|
||||||
h->ctx.print(&h->ctx, "\n");
|
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +277,7 @@ bool pst_handler_unwind(pst_handler* h)
|
|||||||
pst_function* last = last_function(h);
|
pst_function* last = last_function(h);
|
||||||
pst_function* fn = add_function(h, NULL);
|
pst_function* fn = add_function(h, NULL);
|
||||||
fn->info.pc = pc; fn->info.sp = sp;
|
fn->info.pc = pc; fn->info.sp = sp;
|
||||||
if(!pst_function_unwind(fn)) {
|
if(!function_unwind(fn)) {
|
||||||
del_function(fn);
|
del_function(fn);
|
||||||
} else if(last) {
|
} else if(last) {
|
||||||
last->parent = fn;
|
last->parent = fn;
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ pst_function* pst_function_next(pst_handler* handler, pst_function* current)
|
|||||||
|
|
||||||
pst_parameter* pst_parameter_next(pst_function* function, pst_parameter* current)
|
pst_parameter* pst_parameter_next(pst_function* function, pst_parameter* current)
|
||||||
{
|
{
|
||||||
return pst_function_next_parameter(function, current);
|
return function_next_parameter(function, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
pst_parameter* pst_parameter_next_child(pst_parameter* parent, pst_parameter* current)
|
pst_parameter* pst_parameter_next_child(pst_parameter* parent, pst_parameter* current)
|
||||||
|
|||||||
Reference in New Issue
Block a user