strace.c: support simultaneous usage of -r and -t options
* strace.c (init): Do not set tflag when rflag is set. (printleader): Handle rflag and tflag separately. * strace.1.in (.SH OPTIONS): Add a note about differences between the monotonic clock time and the wall clock time. * tests/options-syntax.test: Remove the check for "-tt has no effect with -r" warning. * NEWS: Mention this. Suggested-by: Josh Triplett <josh@freedesktop.org> Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org> Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466195
This commit is contained in:
parent
bed7622d49
commit
698e9c30d4
2
NEWS
2
NEWS
@ -9,6 +9,8 @@ Noteworthy changes in release ?.?? (????-??-??)
|
||||
in the output of paths associated with file descriptors.
|
||||
* Data dump for write syscalls (-e write) is performed regardless
|
||||
of successfulness of these syscall (addresses Debian bug #436284).
|
||||
* -r and -t options are now affect output independently. Previously,
|
||||
-r option led to ignoring of the -t option (addresses Debian bug #466195).
|
||||
|
||||
* Improvements
|
||||
* Implemented delay injection (-e inject=SET:delay_enter= and
|
||||
|
@ -287,6 +287,13 @@ If given twice, suppress messages about process exit status.
|
||||
Print a relative timestamp upon entry to each system call. This
|
||||
records the time difference between the beginning of successive
|
||||
system calls.
|
||||
Note that since
|
||||
.B \-r
|
||||
option uses the monotonic clock time for measuring time difference and not the
|
||||
wall clock time, its measurements can differ from the difference in time
|
||||
reported by the
|
||||
.B \-t
|
||||
option.
|
||||
.TP
|
||||
.BI "\-s " strsize
|
||||
Specify the maximum string size to print (the default is 32). Note
|
||||
|
40
strace.c
40
strace.c
@ -646,20 +646,9 @@ printleader(struct tcb *tcp)
|
||||
|
||||
if (tflag) {
|
||||
struct timespec ts;
|
||||
clock_gettime(rflag ? CLOCK_MONOTONIC : CLOCK_REALTIME, &ts);
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
|
||||
if (rflag) {
|
||||
static struct timespec ots;
|
||||
if (ots.tv_sec == 0)
|
||||
ots = ts;
|
||||
|
||||
struct timespec dts;
|
||||
ts_sub(&dts, &ts, &ots);
|
||||
ots = ts;
|
||||
|
||||
tprintf("%6ld.%06ld ",
|
||||
(long) dts.tv_sec, (long) dts.tv_nsec / 1000);
|
||||
} else if (tflag > 2) {
|
||||
if (tflag > 2) {
|
||||
tprintf("%lld.%06ld ",
|
||||
(long long) ts.tv_sec, (long) ts.tv_nsec / 1000);
|
||||
} else {
|
||||
@ -678,6 +667,25 @@ printleader(struct tcb *tcp)
|
||||
tprintf("%s ", str);
|
||||
}
|
||||
}
|
||||
|
||||
if (rflag) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
static struct timespec ots;
|
||||
if (ots.tv_sec == 0)
|
||||
ots = ts;
|
||||
|
||||
struct timespec dts;
|
||||
ts_sub(&dts, &ts, &ots);
|
||||
ots = ts;
|
||||
|
||||
tprintf("%s%6ld.%06ld%s ",
|
||||
tflag ? "(+" : "",
|
||||
(long) dts.tv_sec, (long) dts.tv_nsec / 1000,
|
||||
tflag ? ")" : "");
|
||||
}
|
||||
|
||||
if (iflag)
|
||||
print_pc(tcp);
|
||||
}
|
||||
@ -1756,12 +1764,6 @@ init(int argc, char *argv[])
|
||||
error_msg("-%c has no effect with -c", 'y');
|
||||
}
|
||||
|
||||
if (rflag) {
|
||||
if (tflag > 1)
|
||||
error_msg("-tt has no effect with -r");
|
||||
tflag = 1;
|
||||
}
|
||||
|
||||
acolumn_spaces = xmalloc(acolumn + 1);
|
||||
memset(acolumn_spaces, ' ', acolumn);
|
||||
acolumn_spaces[acolumn] = '\0';
|
||||
|
@ -92,9 +92,6 @@ $STRACE_EXE: -t has no effect with -c
|
||||
$STRACE_EXE: -T has no effect with -c
|
||||
$STRACE_EXE: -y has no effect with -c
|
||||
$STRACE_EXE: $umsg" -u :nosuchuser: -cirtTy true
|
||||
|
||||
check_e "-tt has no effect with -r
|
||||
$STRACE_EXE: $umsg" -u :nosuchuser: -r -tt true
|
||||
fi
|
||||
|
||||
args='-p 2147483647'
|
||||
|
Loading…
x
Reference in New Issue
Block a user