]> granicus.if.org Git - strace/commitdiff
unwind: move stacktrace capturing and mmap cache invalidating to trace_syscall_entering
authorMasatake YAMATO <yamato@redhat.com>
Wed, 16 Apr 2014 06:33:35 +0000 (15:33 +0900)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 30 May 2014 22:59:01 +0000 (22:59 +0000)
Instead of handling stacktrace capturing and mmap cache invalidating in
sys_* functions, handle them uniformly in trace_syscall_entering using
new flags introduced by previous two commits.

The patch is simpler than its older version(v3).  The value of
hide_log_until_execve is just ignored.  I found the value is nothing
to do with this patch.  unwind_cache_invalidate is mentioned only
once in trace_syscall_exiting.
Both are suggested by Dmitry Levin.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
mem.c
process.c
syscall.c

diff --git a/mem.c b/mem.c
index 180e37006035c52e07b29503dfe6c42500b5cca3..6ecd363c82ad8fdc5bdb16371a1aee5b35e944d4 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -60,13 +60,6 @@ static int
 print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
 {
        if (entering(tcp)) {
-#ifdef USE_LIBUNWIND
-               if (stack_trace_enabled) {
-                       unwind_capture_stacktrace(tcp);
-                       unwind_cache_invalidate(tcp);
-               }
-#endif
-
                /* addr */
                if (!u_arg[0])
                        tprints("NULL, ");
@@ -195,17 +188,7 @@ sys_munmap(struct tcb *tcp)
        if (entering(tcp)) {
                tprintf("%#lx, %lu",
                        tcp->u_arg[0], tcp->u_arg[1]);
-#ifdef USE_LIBUNWIND
-               if (stack_trace_enabled)
-                       unwind_capture_stacktrace(tcp);
-#endif
-       }
-#ifdef USE_LIBUNWIND
-       else {
-               if (stack_trace_enabled)
-                       unwind_cache_invalidate(tcp);
        }
-#endif
        return 0;
 }
 
@@ -216,17 +199,7 @@ sys_mprotect(struct tcb *tcp)
                tprintf("%#lx, %lu, ",
                        tcp->u_arg[0], tcp->u_arg[1]);
                printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
-#ifdef USE_LIBUNWIND
-               if (stack_trace_enabled)
-                       unwind_capture_stacktrace(tcp);
-#endif
        }
-#ifdef USE_LIBUNWIND
-       else {
-               if (stack_trace_enabled)
-                       unwind_cache_invalidate(tcp);
-       }
-#endif
        return 0;
 }
 
index ec9e1b4ed43ab1a773e14e495d0685d43c86a72f..a880f9e36138f1f2943a7c6c043dfb09a6f170f7 100644 (file)
--- a/process.c
+++ b/process.c
@@ -798,20 +798,7 @@ sys_execve(struct tcb *tcp)
                        printargv(tcp, tcp->u_arg[2]);
                        tprints("]");
                }
-#ifdef USE_LIBUNWIND
-               if (stack_trace_enabled) {
-                       unwind_capture_stacktrace(tcp);
-               }
-#endif
        }
-#ifdef USE_LIBUNWIND
-       else {
-               if (stack_trace_enabled) {
-                       unwind_cache_invalidate(tcp);
-               }
-       }
-#endif
-
        return 0;
 }
 
index f8165510206d6e0a775246af4a9c4c82040fc6d7..c95eb6c888e7c44d841da8ab1bc047fcb42f2645 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -2040,6 +2040,13 @@ trace_syscall_entering(struct tcb *tcp)
                goto ret;
        }
 
+#ifdef USE_LIBUNWIND
+       if (stack_trace_enabled) {
+               if (tcp->s_ent->sys_flags & STACKTRACE_CAPTURE_ON_ENTER)
+                       unwind_capture_stacktrace(tcp);
+       }
+#endif
+
        printleader(tcp);
        if (tcp->qual_flg & UNDEFINED_SCNO)
                tprintf("%s(", undefined_scno_name(tcp));
@@ -2513,6 +2520,13 @@ 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 & STACKTRACE_INVALIDATE_CACHE)
+                       unwind_cache_invalidate(tcp);
+       }
+#endif
+
 #if SUPPORTED_PERSONALITIES > 1
        update_personality(tcp, tcp->currpers);
 #endif