[PATCHv4] print stack trace after each syscall
Luca Clementi
luca.clementi at gmail.com
Fri Sep 20 01:05:06 UTC 2013
On Wed, Sep 18, 2013 at 2:47 AM, Masatake YAMATO <yamato at redhat.com> wrote:
> On Tue, 17 Sep 2013 23:47:03 -0700, Luca Clementi <luca.clementi at gmail.com> wrote:
>> On Tue, Sep 17, 2013 at 5:12 AM, Masatake YAMATO <yamato at redhat.com> wrote:
>>>> In the patch `delete_mmap_cache' is used as a trigger for updating
>>>> proc/maps info cache. It is called as expected when mmap and friends
>>>> are traced. However, if the tracing is disabled with -e option, strae
>>>> misses the chance to updating the info cache.
>>>
>>> Could you review this patch for the bug I reported and merge if appreciated.
>>>
>>> `REQUIRED_BY_STACKTRACE' is introduced to trigger the `delete_mmap_cache'.
>>>
>>
>> It works for me.
>>
>> Acked-by: Luca Clementi <luca.clementi at gmail.com>
>>
>> Thanks for the fix,
>> Luca
>
> Thank you for testing and reviewing.
> I'll revise the patch for merging.
>
> For revising I have a question about the original patch:
>
> int
> sys_waitid(struct tcb *tcp)
> {
> if (entering(tcp)) {
> printxval(waitid_types, tcp->u_arg[0], "P_???");
> tprintf(", %ld, ", tcp->u_arg[1]);
> }
> else {
> #ifdef USE_LIBUNWIND
> if (stack_trace_enabled)
> delete_mmap_cache(tcp);
> #endif
>
> Why delete_mmap_cache invocation is needed after wait related system calls?
>
I can't find a logical explanation for that.
I think that part of the code should be removed as you indicated.
Although I have one minor comment.
Since we are printing the stack trace on return of a sys call,
shouldn't we update the mapping _before_ we print the stack trace?
In most of the situation it does not matter except for execve (we can
avoid a "backtracing_error").
I simply moved the delete_mmap_cache up in the trace_syscall_exiting:
diff --git a/syscall.c b/syscall.c
index b01c023..4ada5cd 100644
--- a/syscall.c
+++ b/syscall.c
@@ -97,6 +97,7 @@
#define TM TRACE_MEMORY
#define NF SYSCALL_NEVER_FAILS
#define MA MAX_ARGS
+#define RT REQUIRED_BY_STACKTRACE
const struct_sysent sysent0[] = {
#include "syscallent.h"
@@ -2508,6 +2509,14 @@ trace_syscall_exiting(struct tcb *tcp)
if (Tflag || cflag)
gettimeofday(&tv, NULL);
+
+#ifdef USE_LIBUNWIND
+ if (stack_trace_enabled)
+ if (tcp->s_ent->sys_flags & REQUIRED_BY_STACKTRACE)
+ delete_mmap_cache(tcp);
+#endif
#if SUPPORTED_PERSONALITIES > 1
update_personality(tcp, tcp->currpers);
#endif
To complete your patch it will require modification to all 25
syscallent.h, correct?
Luca
More information about the Strace-devel
mailing list