fix compilation errors related to C specifics
This commit is contained in:
@@ -54,7 +54,7 @@ void pst_call_site_param_fini(pst_call_site_param* param)
|
||||
// -----------------------------------------------------------------------------------
|
||||
// pst_call_site
|
||||
// -----------------------------------------------------------------------------------
|
||||
pst_call_site_param* add_param(pst_call_site* site)
|
||||
static pst_call_site_param* add_param(pst_call_site* site)
|
||||
{
|
||||
pst_call_site_param* p = pst_call_site_param_new();
|
||||
pst_call_site_param_init(p);
|
||||
@@ -63,13 +63,13 @@ pst_call_site_param* add_param(pst_call_site* site)
|
||||
return p;
|
||||
}
|
||||
|
||||
void del_param(pst_call_site*, pst_call_site_param* p)
|
||||
static void del_param(pst_call_site_param* p)
|
||||
{
|
||||
list_del(&p->node);
|
||||
pst_call_site_param_fini(p);
|
||||
}
|
||||
|
||||
pst_call_site_param* next_param(pst_call_site* site, pst_call_site_param* p)
|
||||
static pst_call_site_param* next_param(pst_call_site* site, pst_call_site_param* p)
|
||||
{
|
||||
list_node* n = (p == NULL) ? list_first(&site->params) : list_next(&p->node);
|
||||
pst_call_site_param* ret = NULL;
|
||||
@@ -109,7 +109,7 @@ bool call_site_handle_dwarf(pst_call_site* site, Dwarf_Die* child)
|
||||
attr = dwarf_attr(child, DW_AT_location, &attr_mem);
|
||||
if(!handle_location(site->ctx, attr, ¶m->location, pc, NULL)) {
|
||||
pst_log(SEVERITY_ERROR, "Failed to calculate DW_AT_location expression: %s", site->ctx->buff);
|
||||
del_param(site, param);
|
||||
del_param(param);
|
||||
return false;
|
||||
}
|
||||
pst_log(SEVERITY_DEBUG, " DW_AT_location: %s", site->ctx->buff);
|
||||
@@ -126,7 +126,7 @@ bool call_site_handle_dwarf(pst_call_site* site, Dwarf_Die* child)
|
||||
pst_log(SEVERITY_DEBUG, " DW_AT_GNU_call_site_value:\"%s\" ==> 0x%lX", site->ctx->buff, param->value);
|
||||
} else {
|
||||
pst_log(SEVERITY_ERROR, "Failed to calculate DW_AT_location expression: %s", site->ctx->buff);
|
||||
del_param(site, param);
|
||||
del_param(param);
|
||||
pst_dwarf_expr_fini(&loc);
|
||||
return false;
|
||||
}
|
||||
@@ -320,8 +320,8 @@ void pst_call_site_storage_init(pst_call_site_storage* storage, pst_context* ctx
|
||||
{
|
||||
storage->ctx = ctx;
|
||||
list_head_init(&storage->call_sites);
|
||||
hash_head_init(&storage->cs_to_target);
|
||||
hash_head_init(&storage->cs_to_origin);
|
||||
hash_head_init(&storage->cs_to_target, HASH_MIN_SHIFT, 0, 0);
|
||||
hash_head_init(&storage->cs_to_origin, HASH_MIN_SHIFT, 0 ,0);
|
||||
storage->allocated = false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "../utils/list_head.h"
|
||||
#include "context.h"
|
||||
|
||||
typedef struct pst_callee_info {
|
||||
typedef struct __pst_callee_info {
|
||||
Dwarf_Addr target;
|
||||
char* origin;
|
||||
} pst_callee_info;
|
||||
@@ -25,7 +25,7 @@ typedef struct pst_callee_info {
|
||||
// -----------------------------------------------------------------------------------
|
||||
// DW_TAG_call_site_parameter
|
||||
// -----------------------------------------------------------------------------------
|
||||
typedef struct pst_call_site_param {
|
||||
typedef struct __pst_call_site_param {
|
||||
list_node node; // uplink. !!! must be first !!!
|
||||
|
||||
Dwarf_Die* param; // reference to parameter DIE in callee (DW_AT_call_parameter)
|
||||
@@ -43,7 +43,7 @@ void pst_call_site_param_fini(pst_call_site_param* param);
|
||||
// -----------------------------------------------------------------------------------
|
||||
// DW_TAG_call_site
|
||||
// -----------------------------------------------------------------------------------
|
||||
typedef struct pst_call_site {
|
||||
typedef struct __pst_call_site {
|
||||
list_node node; // uplink to list of call-sites
|
||||
hash_node tgt_node; // uplink to call-site by node dictionary
|
||||
hash_node org_node; // uplink to call-site by origin dictionary
|
||||
@@ -68,7 +68,7 @@ typedef struct __pst_function pst_function;
|
||||
// -----------------------------------------------------------------------------------
|
||||
// storage for all of function's call sites
|
||||
// -----------------------------------------------------------------------------------
|
||||
typedef struct pst_call_site_storage {
|
||||
typedef struct __pst_call_site_storage {
|
||||
pst_context* ctx;
|
||||
list_head call_sites; // Call-Site definitions
|
||||
hash_head cs_to_target; // map pointer to caller to call-site
|
||||
|
||||
@@ -54,7 +54,7 @@ void pst_dwarf_op_fini(pst_dwarf_op* dwop)
|
||||
//
|
||||
// pst_dwarf_expr
|
||||
//
|
||||
pst_dwarf_op* add_op(pst_dwarf_expr* expr, uint8_t operation, uint64_t arg1, uint64_t arg2)
|
||||
static pst_dwarf_op* add_op(pst_dwarf_expr* expr, uint8_t operation, uint64_t arg1, uint64_t arg2)
|
||||
{
|
||||
pst_new(pst_dwarf_op, op, operation, arg1, arg2);
|
||||
list_add_bottom(&expr->operations, &op->node);
|
||||
@@ -62,7 +62,7 @@ pst_dwarf_op* add_op(pst_dwarf_expr* expr, uint8_t operation, uint64_t arg1, uin
|
||||
return op;
|
||||
}
|
||||
|
||||
pst_dwarf_op* next_op(pst_dwarf_expr* expr, pst_dwarf_op* op)
|
||||
static pst_dwarf_op* next_op(pst_dwarf_expr* expr, pst_dwarf_op* op)
|
||||
{
|
||||
struct list_node* n = (op == NULL) ? list_first(&expr->operations) : list_next(&op->node);
|
||||
|
||||
@@ -74,7 +74,7 @@ pst_dwarf_op* next_op(pst_dwarf_expr* expr, pst_dwarf_op* op)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void clean(pst_dwarf_expr* expr)
|
||||
static void clean(pst_dwarf_expr* expr)
|
||||
{
|
||||
pst_dwarf_op* op = NULL;
|
||||
struct list_node *pos, *tn;
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
#include <dwarf.h>
|
||||
#include <stdlib.h>
|
||||
#include <cxxabi.h>
|
||||
#include <libiberty/demangle.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "dwarf_stack.h"
|
||||
#include "dwarf_utils.h"
|
||||
@@ -17,7 +19,7 @@
|
||||
// -----------------------------------------------------------------------------------
|
||||
// pst_function
|
||||
// -----------------------------------------------------------------------------------
|
||||
bool get_frame(pst_function* fn)
|
||||
static bool get_frame(pst_function* fn)
|
||||
{
|
||||
// get CFI (Call Frame Information) for current module
|
||||
// from handle_cfi()
|
||||
@@ -85,7 +87,7 @@ bool get_frame(pst_function* fn)
|
||||
return true;
|
||||
}
|
||||
|
||||
pst_parameter* add_param(pst_function* fn)
|
||||
static pst_parameter* add_param(pst_function* fn)
|
||||
{
|
||||
pst_new(pst_parameter, p, fn->ctx);
|
||||
list_add_bottom(&fn->params, &p->node);
|
||||
@@ -93,13 +95,13 @@ pst_parameter* add_param(pst_function* fn)
|
||||
return p;
|
||||
}
|
||||
|
||||
void del_param(pst_parameter* p)
|
||||
static void del_param(pst_parameter* p)
|
||||
{
|
||||
list_del(&p->node);
|
||||
pst_free(p);
|
||||
}
|
||||
|
||||
void clear(pst_function* fn)
|
||||
static void clear(pst_function* fn)
|
||||
{
|
||||
pst_parameter* param = NULL;
|
||||
struct list_node *pos, *tn;
|
||||
@@ -111,7 +113,7 @@ void clear(pst_function* fn)
|
||||
pst_call_site_storage_fini(&fn->call_sites);
|
||||
}
|
||||
|
||||
pst_parameter* next_param(pst_function* fn, pst_parameter* p)
|
||||
static pst_parameter* next_param(pst_function* fn, pst_parameter* p)
|
||||
{
|
||||
struct list_node* n = (p == NULL) ? list_first(&fn->params) : list_next(&p->node);
|
||||
|
||||
@@ -400,8 +402,7 @@ bool pst_function_unwind(pst_function* fn, Dwarf_Addr addr)
|
||||
const char* addrname = dwfl_module_addrname(fn->ctx->module, addr);
|
||||
char* demangle_name = NULL;
|
||||
if(addrname) {
|
||||
int status;
|
||||
demangle_name = abi::__cxa_demangle(addrname, NULL, NULL, &status);
|
||||
demangle_name = cplus_demangle(addrname, 0);
|
||||
char* function_name = NULL;
|
||||
if(asprintf(&function_name, "%s%s", demangle_name ? demangle_name : addrname, demangle_name ? "" : "()") == -1) {
|
||||
pst_log(SEVERITY_ERROR, "Failed to allocate memory");
|
||||
@@ -424,7 +425,7 @@ bool pst_function_unwind(pst_function* fn, Dwarf_Addr addr)
|
||||
return true;
|
||||
}
|
||||
|
||||
void pst_function_init(pst_function* fn, pst_context* _ctx, __pst_function* _parent)
|
||||
void pst_function_init(pst_function* fn, pst_context* _ctx, pst_function* _parent)
|
||||
{
|
||||
list_node_init(&fn->node);
|
||||
|
||||
@@ -448,7 +449,7 @@ void pst_function_init(pst_function* fn, pst_context* _ctx, __pst_function* _par
|
||||
fn->allocated = false;
|
||||
}
|
||||
|
||||
pst_function* pst_function_new(pst_context* _ctx, __pst_function* _parent)
|
||||
pst_function* pst_function_new(pst_context* _ctx, pst_function* _parent)
|
||||
{
|
||||
pst_function* fn = pst_alloc(pst_function);
|
||||
if(fn) {
|
||||
@@ -36,13 +36,13 @@ typedef struct __pst_function {
|
||||
unw_cursor_t cursor; // copy of stack state of the function
|
||||
int line; // line in code where function is defined
|
||||
char* file; // file name (DWARF Compilation Unit) where function is defined
|
||||
__pst_function* parent; // parent function in call trace (caller)
|
||||
struct __pst_function* parent; // parent function in call trace (caller)
|
||||
Dwarf_Frame* frame; // function's stack frame
|
||||
pst_context* ctx; // context of unwinding
|
||||
bool allocated; // whether this object was allocated or not
|
||||
} pst_function;
|
||||
void pst_function_init(pst_function* fn, pst_context* _ctx, __pst_function* _parent);
|
||||
pst_function* pst_function_new(pst_context* _ctx, __pst_function* _parent);
|
||||
void pst_function_init(pst_function* fn, pst_context* _ctx, pst_function* _parent);
|
||||
pst_function* pst_function_new(pst_context* _ctx, pst_function* _parent);
|
||||
void pst_function_fini(pst_function* fn);
|
||||
|
||||
bool pst_function_unwind(pst_function* fn, Dwarf_Addr addr);
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
* Created on: Dec 28, 2019
|
||||
* Author: nnosov
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
#include <dwarf.h>
|
||||
#include <elfutils/libdwfl.h>
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
#include <inttypes.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -75,7 +76,7 @@ bool get_dwarf_function(pst_handler* h, pst_function* fun)
|
||||
return nret;
|
||||
}
|
||||
|
||||
pst_function* add_function(pst_handler* h, pst_function* parent)
|
||||
static pst_function* add_function(pst_handler* h, pst_function* parent)
|
||||
{
|
||||
pst_new(pst_function, fn, &h->ctx, parent);
|
||||
list_add_bottom(&h->functions, &fn->node);
|
||||
@@ -83,13 +84,13 @@ pst_function* add_function(pst_handler* h, pst_function* parent)
|
||||
return fn;
|
||||
}
|
||||
|
||||
void del_function(pst_function* fn)
|
||||
static void del_function(pst_function* fn)
|
||||
{
|
||||
list_del(&fn->node);
|
||||
pst_function_fini(fn);
|
||||
}
|
||||
|
||||
void clear(pst_handler* h)
|
||||
static void clear(pst_handler* h)
|
||||
{
|
||||
pst_function* fn = NULL;
|
||||
struct list_node *pos, *tn;
|
||||
@@ -99,7 +100,7 @@ void clear(pst_handler* h)
|
||||
}
|
||||
}
|
||||
|
||||
pst_function* next_function(pst_handler* h, pst_function* fn)
|
||||
static pst_function* next_function(pst_handler* h, pst_function* fn)
|
||||
{
|
||||
list_node* n = (fn == NULL) ? list_first(&h->functions) : list_next(&fn->node);
|
||||
pst_function* ret = NULL;
|
||||
@@ -110,7 +111,7 @@ pst_function* next_function(pst_handler* h, pst_function* fn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
pst_function* prev_function(pst_handler* h, pst_function* fn)
|
||||
static pst_function* prev_function(pst_handler* h, pst_function* fn)
|
||||
{
|
||||
list_node* n = (fn == NULL) ? list_last(&h->functions) : list_prev(&fn->node);
|
||||
pst_function* ret = NULL;
|
||||
@@ -121,7 +122,7 @@ pst_function* prev_function(pst_handler* h, pst_function* fn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
pst_function* last_function(pst_handler* h)
|
||||
static pst_function* last_function(pst_handler* h)
|
||||
{
|
||||
list_node* n = list_last(&h->functions);
|
||||
if(n) {
|
||||
@@ -46,7 +46,7 @@ void pst_type_fini(pst_type* t)
|
||||
//
|
||||
// pst_parameter
|
||||
//
|
||||
void clear(pst_parameter* param)
|
||||
static void clear(pst_parameter* param)
|
||||
{
|
||||
pst_type* t = NULL;
|
||||
struct list_node *pos, *tn;
|
||||
@@ -56,7 +56,7 @@ void clear(pst_parameter* param)
|
||||
}
|
||||
}
|
||||
|
||||
pst_type* next_type(pst_parameter* param, pst_type* t)
|
||||
static pst_type* next_type(pst_parameter* param, pst_type* t)
|
||||
{
|
||||
list_node* n = (t == NULL) ? list_first(¶m->types) : list_next(&t->node);
|
||||
pst_type* ret = NULL;
|
||||
@@ -9,6 +9,7 @@
|
||||
#define __PST_DWARF_STACK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "context.h"
|
||||
@@ -86,10 +87,10 @@ void pst_dwarf_stack_init(pst_dwarf_stack* st, pst_context* ctx);
|
||||
pst_dwarf_stack* pst_dwarf_stack_new(pst_context* ctx);
|
||||
void pst_dwarf_stack_fini(pst_dwarf_stack* st);
|
||||
|
||||
bool pst_dwarf_stack_calc(pst_dwarf_stack* st, Dwarf_Op *exprs, int expr_len, Dwarf_Attribute* attr, pst_function* fun = NULL);
|
||||
bool pst_dwarf_stack_calc(pst_dwarf_stack* st, Dwarf_Op *exprs, int expr_len, Dwarf_Attribute* attr, pst_function* fun);
|
||||
void pst_dwarf_stack_clear(pst_dwarf_stack* st);
|
||||
bool pst_dwarf_stack_get_value(pst_dwarf_stack* st, uint64_t* value);
|
||||
pst_dwarf_value* pst_dwarf_stack_get(pst_dwarf_stack* st, uint32_t idx = 0);
|
||||
pst_dwarf_value* pst_dwarf_stack_get(pst_dwarf_stack* st, uint32_t idx);
|
||||
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(pst_dwarf_stack* st, void* v, uint32_t s, int t);
|
||||
|
||||
@@ -31,7 +31,7 @@ int regname_callback (void *arg, int regno, const char *setname, const char *pre
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool handle_location(pst_context* ctx, Dwarf_Attribute* attr, pst_dwarf_expr* loc, Dwarf_Addr pc, pst_function* fun = NULL)
|
||||
bool handle_location(pst_context* ctx, Dwarf_Attribute* attr, pst_dwarf_expr* loc, Dwarf_Addr pc, pst_function* fun)
|
||||
{
|
||||
ctx->clean_print(ctx);
|
||||
Dwarf_Addr offset = pc - ctx->base_addr;
|
||||
@@ -15,10 +15,6 @@
|
||||
#include "dwarf_function.h"
|
||||
|
||||
typedef struct __reginfo {
|
||||
__reginfo() {
|
||||
regname[0] = 0;
|
||||
regno = -1;
|
||||
}
|
||||
char regname[32];
|
||||
int regno;
|
||||
} reginfo;
|
||||
|
||||
Reference in New Issue
Block a user