From cc2d07f550eb9ce796fc7a984b22ed49698a4dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 8 Jun 2019 16:17:06 +0200 Subject: [PATCH] unw_step dbg: fix unique id --- src/x86_64/Gstep.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/x86_64/Gstep.c b/src/x86_64/Gstep.c index 1741dc5d..39cc473b 100644 --- a/src/x86_64/Gstep.c +++ b/src/x86_64/Gstep.c @@ -57,22 +57,30 @@ is_plt_entry (struct dwarf_cursor *c) extern int init_id; -static int unw_step_id(unw_cursor_t *cursor) { - struct cursor *c = (struct cursor *) cursor; +typedef struct { + unw_word_t orig_ip; + unw_word_t orig_cfa; +} unw_step_call_data; + +static int unw_step_id(unw_step_call_data *call_data) { return ( - ((c->dwarf.ip + c->dwarf.cfa * 257) % 1000003) + ((call_data->orig_ip + call_data->orig_ip * 257) % 1000003) + (1000003 * init_id)) % (1000000007); } -#define UnwDebug(lvl, fmt, ...) Debug(lvl, "[%X] <%d> " fmt, unw_step_id(cursor), init_id, ##__VA_ARGS__) +#define UnwDebug(lvl, fmt, ...) Debug(lvl, "[%X] <%d> {%d} " fmt, unw_step_id(&_step_id_data), init_id, __LINE__, ##__VA_ARGS__) PROTECTED int unw_step (unw_cursor_t *cursor) { + struct cursor *c = (struct cursor *) cursor; + unw_step_call_data _step_id_data; + _step_id_data.orig_ip = c->dwarf.ip; + _step_id_data.orig_cfa = c->dwarf.cfa; + UnwDebug(3, "unw_step called\n"); struct timespec _timer_start = chrono_start(); - struct cursor *c = (struct cursor *) cursor; int ret, i; #if CONSERVATIVE_CHECKS