diff options
author | Petr Machata <pmachata@redhat.com> | 2012-04-12 23:09:21 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-04-12 23:09:21 +0200 |
commit | 1429874dee5758cc99c0dae73bd3f928109e53d7 (patch) | |
tree | 9931c161d2f7936616c2b90e4b1cdd803bae57d4 /handle_event.c | |
parent | 31b2f9f7296e52aff489138c78be2f8cf9140bbc (diff) | |
download | ltrace-1429874dee5758cc99c0dae73bd3f928109e53d7.tar.gz |
Fix previous commit, which broke the common case
- in this commit I drop a bit of MIPS support. First, I don't think MIPS
is supported right now. The multi-threading merge was an invasive change
and most arches other than x86 are in fact currently broken.
Second, deciding that we shouldn't push a slot just based on address
equality is too strong. This would also reject actual recursion, which
is a common case (for -x anyway, for -e less so).
Diffstat (limited to 'handle_event.c')
-rw-r--r-- | handle_event.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/handle_event.c b/handle_event.c index dcc1f8c..8c3c7ce 100644 --- a/handle_event.c +++ b/handle_event.c @@ -565,6 +565,15 @@ void *get_count_register (Process *proc); #endif static void +output_right_tos(struct Process *proc) +{ + size_t d = proc->callstack_depth; + struct callstack_element *elem = &proc->callstack[d - 1]; + if (proc->state != STATE_IGNORED) + output_right(LT_TOF_FUNCTIONR, proc, elem->c_un.libfunc->name); +} + +static void handle_breakpoint(Event *event) { int i, j; @@ -672,29 +681,26 @@ handle_breakpoint(Event *event) } event->proc->return_addr = brk_addr; + output_right_tos(event->proc); + callstack_pop(event->proc); + /* Pop also any other entries that seem like * they are linked to the current one: they * have the same return address, but were made * for different symbols. This should only * happen for entry point tracing, i.e. for -x * everywhere, or -x and -e on PPC64. */ - int first = 1; while (event->proc->callstack_depth > 0) { struct callstack_element *prev; size_t d = event->proc->callstack_depth; prev = &event->proc->callstack[d - 1]; - if (event->proc->state != STATE_IGNORED) - output_right(LT_TOF_FUNCTIONR, - event->proc, - prev->c_un.libfunc->name); - - if (prev->c_un.libfunc != libsym - && prev->return_addr == brk_addr) - callstack_pop(event->proc); - else if (!first) + if (prev->c_un.libfunc == libsym + || prev->return_addr != brk_addr) break; - first = 0; + + output_right_tos(event->proc); + callstack_pop(event->proc); } sbp = address2bpstruct(leader, brk_addr); @@ -765,7 +771,7 @@ callstack_push_syscall(Process *proc, int sysnum) { static void callstack_push_symfunc(Process *proc, struct library_symbol *sym) { - struct callstack_element *elem, *prev; + struct callstack_element *elem; debug(DEBUG_FUNCTION, "callstack_push_symfunc(pid=%d, symbol=%s)", proc->pid, sym->name); /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */ @@ -775,8 +781,7 @@ callstack_push_symfunc(Process *proc, struct library_symbol *sym) { return; } - prev = &proc->callstack[proc->callstack_depth-1]; - elem = &proc->callstack[proc->callstack_depth]; + elem = &proc->callstack[proc->callstack_depth++]; elem->is_syscall = 0; elem->c_un.libfunc = sym; @@ -786,8 +791,6 @@ callstack_push_symfunc(Process *proc, struct library_symbol *sym) { } /* handle functions like atexit() on mips which have no return */ - if (elem->return_addr != prev->return_addr) - proc->callstack_depth++; if (opt_T || options.summary) { struct timezone tz; gettimeofday(&elem->time_spent, &tz); |