]> granicus.if.org Git - strace/commitdiff
Make -b take SYSCALL param, document it in --help and in manpage.
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 27 Feb 2013 11:15:19 +0000 (12:15 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 27 Feb 2013 11:15:19 +0000 (12:15 +0100)
To not waste an option letter for just one trick,
extend -b to take a parameter:
"on which syscalls do you want to detach?".
Currently supports only execve.

While at it, fixed (by removing non-Linux and stale info)
and extended manpage text about -f.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
strace.1
strace.c

index f31b2172ae19531b3fe73fb498879cc332160e65..63b604c84ce648b84e5d6a575eb1a7adaa6aa20c 100644 (file)
--- a/strace.1
+++ b/strace.1
@@ -41,7 +41,9 @@ strace \- trace system calls and signals
 .B strace
 [\fB-CdffhiqrtttTvVxxy\fR]
 [\fB-I\fIn\fR]
-[\fB-e\fIexpr\fR]... [\fB-a\fIcolumn\fR]
+[\fB-b\fIexecve\fR]
+[\fB-e\fIexpr\fR]...
+[\fB-a\fIcolumn\fR]
 [\fB-o\fIfile\fR]
 [\fB-s\fIstrsize\fR]
 [\fB-P\fIpath\fR]... \fB-p\fIpid\fR... /
@@ -52,7 +54,9 @@ strace \- trace system calls and signals
 .B strace
 \fB-c\fR[\fBdf\fR]
 [\fB-I\fIn\fR]
-[\fB-e\fIexpr\fR]... [\fB-O\fIoverhead\fR]
+[\fB-b\fIexecve\fR]
+[\fB-e\fIexpr\fR]...
+[\fB-O\fIoverhead\fR]
 [\fB-S\fIsortby\fR] \fB-p\fIpid\fR... /
 [\fB-D\fR]
 [\fB-E\fIvar\fR[=\fIval\fR]]... [\fB-u\fIusername\fR]
@@ -226,24 +230,16 @@ itself on the standard error.
 .B \-f
 Trace child processes as they are created by currently traced
 processes as a result of the
-.BR fork (2)
-system call.
-.IP
-On non-Linux platforms the new process is
-attached to as soon as its pid is known (through the return value of
-.BR fork (2)
-in the parent process). This means that such children may run
-uncontrolled for a while (especially in the case of a
-.BR vfork (2)),
-until the parent is scheduled again to complete its
-.RB ( v ) fork (2)
-call.  On Linux the child is traced from its first instruction with no delay.
-If the parent process decides to
-.BR wait (2)
-for a child that is currently
-being traced, it is suspended until an appropriate child process either
-terminates or incurs a signal that would cause it to terminate (as
-determined from the child's current signal disposition).
+.BR fork (2),
+.BR vfork (2)
+and
+.BR clone (2)
+system calls. Note that
+.B \-p
+.I PID
+.B \-f
+will attach all threads of process PID if it is multi-threaded,
+not only thread with thread_id = PID.
 .TP
 .B \-ff
 If the
@@ -313,6 +309,14 @@ Print paths associated with file descriptor arguments.
 .BI "\-a " column
 Align return values in a specific column (default column 40).
 .TP
+.BI "\-b " syscall
+If specified syscall is reached, detach from traced process.
+Currently, only
+.I execve
+syscall is supported. This option is useful if you want to trace
+multi-threaded process and therefore require -f, but don't want
+to trace its (potentially very complex) children.
+.TP
 .BI "\-e " expr
 A qualifying expression which modifies which events to trace
 or how to trace them.  The format of the expression is:
index 4975153540f20eefbd58cb9305fbfa0c43e277f4..319dff2fd33c22c911dc3fca42e2a7ebf1585347 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -210,6 +210,7 @@ usage: strace [-CdffhiqrtttTvVxxy] [-I n] [-e expr]...\n\
 -y -- print paths associated with file descriptor arguments\n\
 -h -- print help message, -V -- print version\n\
 -a column -- alignment COLUMN for printing syscall results (default %d)\n\
+-b execve -- detach on this syscall\n\
 -e expr -- a qualifying expression: option=[!]all or option=[!]val1[,val2]...\n\
    options: trace, abbrev, verbose, raw, signal, read, write\n\
 -I interruptible --\n\
@@ -234,9 +235,6 @@ usage: strace [-CdffhiqrtttTvVxxy] [-I n] [-e expr]...\n\
 /* this is broken, so don't document it
 -z -- print only succeeding syscalls\n\
  */
-/* experimental, don't document it yet (option letter may change in the future!)
--b -- detach on successful execve\n\
- */
 , DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);
        exit(exitval);
 }
@@ -1561,11 +1559,14 @@ init(int argc, char *argv[])
 #endif
        qualify("signal=all");
        while ((c = getopt(argc, argv,
-               "+bcCdfFhiqrtTvVxyz"
+               "+b:cCdfFhiqrtTvVxyz"
                "D"
                "a:e:o:O:p:s:S:u:E:P:I:")) != EOF) {
                switch (c) {
                case 'b':
+                       if (strcmp(optarg, "execve") != 0)
+                               error_msg_and_die("Syscall '%s' for -b isn't supported",
+                                       optarg);
                        detach_on_execve = 1;
                        break;
                case 'c':