1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-25 08:37:38 +01:00

Preprocess out debug code from release builds

This commit is contained in:
Théophile Bastian 2019-06-09 23:38:38 +02:00
parent 11cce868c6
commit 7b2e5e7548
2 changed files with 8 additions and 0 deletions

View file

@ -97,6 +97,7 @@ int set_dwarf_loc_ifdef(
int eh_elf_step_cursor(struct cursor *cursor) { int eh_elf_step_cursor(struct cursor *cursor) {
uintptr_t ip = cursor->dwarf.ip; uintptr_t ip = cursor->dwarf.ip;
#ifdef DEBUG
{ {
uintptr_t dbp; uintptr_t dbp;
dwarf_get(&cursor->dwarf, cursor->dwarf.loc[UNW_TDEP_BP], &dbp); dwarf_get(&cursor->dwarf, cursor->dwarf.loc[UNW_TDEP_BP], &dbp);
@ -104,6 +105,7 @@ int eh_elf_step_cursor(struct cursor *cursor) {
DWARF_IS_NULL_LOC(cursor->dwarf.loc[UNW_TDEP_BP])?" [NULL]":"", DWARF_IS_NULL_LOC(cursor->dwarf.loc[UNW_TDEP_BP])?" [NULL]":"",
cursor->dwarf.cfa, cursor->dwarf.ip); cursor->dwarf.cfa, cursor->dwarf.ip);
} }
#endif
// Retrieve memory map entry // Retrieve memory map entry
mmap_entry_t* mmap_entry = mmap_get_entry(ip); mmap_entry_t* mmap_entry = mmap_get_entry(ip);

View file

@ -62,12 +62,14 @@ typedef struct {
unw_word_t orig_cfa; unw_word_t orig_cfa;
} unw_step_call_data; } unw_step_call_data;
#ifdef DEBUG
static int unw_step_id(unw_step_call_data *call_data) { static int unw_step_id(unw_step_call_data *call_data) {
return ( return (
((call_data->orig_ip + call_data->orig_ip * 257) % 1000003) ((call_data->orig_ip + call_data->orig_ip * 257) % 1000003)
+ (1000003 * init_id)) + (1000003 * init_id))
% (1000000007); % (1000000007);
} }
#endif
#define UnwDebug(lvl, fmt, ...) Debug(lvl, "[%X] <%d> {%d} " fmt, unw_step_id(&_step_id_data), init_id, __LINE__, ##__VA_ARGS__) #define UnwDebug(lvl, fmt, ...) Debug(lvl, "[%X] <%d> {%d} " fmt, unw_step_id(&_step_id_data), init_id, __LINE__, ##__VA_ARGS__)
@ -75,11 +77,14 @@ PROTECTED int
unw_step (unw_cursor_t *cursor) unw_step (unw_cursor_t *cursor)
{ {
struct cursor *c = (struct cursor *) cursor; struct cursor *c = (struct cursor *) cursor;
#ifdef DEBUG
unw_step_call_data _step_id_data; unw_step_call_data _step_id_data;
_step_id_data.orig_ip = c->dwarf.ip; _step_id_data.orig_ip = c->dwarf.ip;
_step_id_data.orig_cfa = c->dwarf.cfa; _step_id_data.orig_cfa = c->dwarf.cfa;
#endif
UnwDebug(3, "unw_step called\n"); UnwDebug(3, "unw_step called\n");
#ifdef DEBUG
{ {
uintptr_t dbp; uintptr_t dbp;
dwarf_get(&c->dwarf, c->dwarf.loc[RBP], &dbp); dwarf_get(&c->dwarf, c->dwarf.loc[RBP], &dbp);
@ -87,6 +92,7 @@ unw_step (unw_cursor_t *cursor)
DWARF_IS_NULL_LOC(c->dwarf.loc[RBP])? " [NULL]": "", DWARF_IS_NULL_LOC(c->dwarf.loc[RBP])? " [NULL]": "",
c->dwarf.cfa, c->dwarf.ip); c->dwarf.cfa, c->dwarf.ip);
} }
#endif
struct timespec _timer_start = chrono_start(); struct timespec _timer_start = chrono_start();
int ret, i; int ret, i;