]> granicus.if.org Git - strace/commitdiff
Warn about flags that have no effect with -c
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 3 Jun 2014 13:20:05 +0000 (13:20 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 3 Jun 2014 13:20:05 +0000 (13:20 +0000)
* strace.c (init): Issue a warning if -i, -k, -r, -t, -T, or -y is used
along with -c.
This fixes Debian bug #443895.

strace.c

index fe197e5d3ea0705282a369ffe27a21141da46728..46c9d63ef3a4ec4faafc8dee3516e2cb18555826 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -1817,11 +1817,6 @@ init(int argc, char *argv[])
                error_msg_and_die("-D and -p are mutually exclusive");
        }
 
-#ifdef USE_LIBUNWIND
-       if (stack_trace_enabled)
-               unwind_init();
-#endif
-
        if (!followfork)
                followfork = optF;
 
@@ -1833,6 +1828,28 @@ init(int argc, char *argv[])
                error_msg_and_die("-w must be given with (-c or -C)");
        }
 
+       if (cflag == CFLAG_ONLY_STATS) {
+               if (iflag)
+                       error_msg("-%c has no effect with -c", 'i');
+#ifdef USE_LIBUNWIND
+               if (stack_trace_enabled)
+                       error_msg("-%c has no effect with -c", 'k');
+#endif
+               if (rflag)
+                       error_msg("-%c has no effect with -c", 'r');
+               if (tflag)
+                       error_msg("-%c has no effect with -c", 't');
+               if (Tflag)
+                       error_msg("-%c has no effect with -c", 'T');
+               if (show_fd_path)
+                       error_msg("-%c has no effect with -c", 'y');
+       }
+
+#ifdef USE_LIBUNWIND
+       if (stack_trace_enabled)
+               unwind_init();
+#endif
+
        /* See if they want to run as another user. */
        if (username != NULL) {
                struct passwd *pent;