1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 12:03:41 +01:00

unw_step dbg: fix unique id

This commit is contained in:
Théophile Bastian 2019-06-08 16:17:06 +02:00
parent c0f4449920
commit cc2d07f550

View file

@ -57,22 +57,30 @@ is_plt_entry (struct dwarf_cursor *c)
extern int init_id; extern int init_id;
static int unw_step_id(unw_cursor_t *cursor) { typedef struct {
struct cursor *c = (struct cursor *) cursor; 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 ( return (
((c->dwarf.ip + c->dwarf.cfa * 257) % 1000003) ((call_data->orig_ip + call_data->orig_ip * 257) % 1000003)
+ (1000003 * init_id)) + (1000003 * init_id))
% (1000000007); % (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 PROTECTED int
unw_step (unw_cursor_t *cursor) 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"); UnwDebug(3, "unw_step called\n");
struct timespec _timer_start = chrono_start(); struct timespec _timer_start = chrono_start();
struct cursor *c = (struct cursor *) cursor;
int ret, i; int ret, i;
#if CONSERVATIVE_CHECKS #if CONSERVATIVE_CHECKS