count: add ability to select columnt being shown
* count.c (set_count_summary_columns): New function. * defs.h (set_count_summary_columns): New declaration. * strace.c (init) <-U>: Pass option argument to set_count_summary_columns. * strace.1.in (.SH OPTIONS): Document it.
This commit is contained in:
55
count.c
55
count.c
@ -188,6 +188,61 @@ set_sortby(const char *sortby)
|
||||
error_msg_and_help("invalid sortby: '%s'", sortby);
|
||||
}
|
||||
|
||||
void
|
||||
set_count_summary_columns(const char *s)
|
||||
{
|
||||
static const char *cnames[] = {
|
||||
[CSC_TIME_100S] = "time_percent",
|
||||
[CSC_TIME_TOTAL] = "total_time",
|
||||
[CSC_TIME_AVG] = "avg_time",
|
||||
[CSC_CALLS] = "calls",
|
||||
[CSC_ERRORS] = "errors",
|
||||
[CSC_SC_NAME] = "syscall",
|
||||
};
|
||||
|
||||
const char *pos = s;
|
||||
const char *prev = s;
|
||||
size_t cur = 0;
|
||||
|
||||
memset(columns, 0, sizeof(columns));
|
||||
memset(visible, 0, sizeof(visible));
|
||||
|
||||
do {
|
||||
bool found = false;
|
||||
|
||||
pos = strchr(prev, ',');
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(cnames); i++) {
|
||||
if (!cnames[i] || (pos
|
||||
? ((size_t) (pos - prev) != strlen(cnames[i]))
|
||||
|| strncmp(prev, cnames[i], pos - prev)
|
||||
: strcmp(prev, cnames[i]))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visible[i])
|
||||
error_msg_and_help("call summary column "
|
||||
"has been provided more "
|
||||
"than once: '%s' (-U option "
|
||||
"residual: '%s')",
|
||||
cnames[i], prev);
|
||||
|
||||
columns[cur++] = i;
|
||||
visible[i] = 1;
|
||||
found = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
error_msg_and_help("unknown column name: '%.*s'",
|
||||
(int) (pos ? pos - prev : INT_MAX),
|
||||
prev);
|
||||
|
||||
prev = pos + 1;
|
||||
} while (pos);
|
||||
}
|
||||
|
||||
void
|
||||
set_overhead(const char *str)
|
||||
{
|
||||
|
1
defs.h
1
defs.h
@ -432,6 +432,7 @@ extern int read_int_from_file(struct tcb *, const char *, int *);
|
||||
|
||||
extern void set_sortby(const char *);
|
||||
extern void set_overhead(const char *);
|
||||
extern void set_count_summary_columns(const char *columns);
|
||||
extern void print_pc(struct tcb *);
|
||||
|
||||
extern int syscall_entering_decode(struct tcb *);
|
||||
|
35
strace.1.in
35
strace.1.in
@ -67,6 +67,9 @@ strace \- trace system calls and signals
|
||||
.OP \-I n
|
||||
.OP \-b execve
|
||||
.OM \-e expr
|
||||
.OP \-O overhead
|
||||
.OP \-S sortby
|
||||
.OP \-U columns
|
||||
.OP \-a column
|
||||
.OP \-o file
|
||||
.OP \-s strsize
|
||||
@ -90,6 +93,7 @@ strace \- trace system calls and signals
|
||||
.OM \-e expr
|
||||
.OP \-O overhead
|
||||
.OP \-S sortby
|
||||
.OP \-U columns
|
||||
.OM \-P path
|
||||
.OM \-p pid
|
||||
.BR "" {
|
||||
@ -422,6 +426,37 @@ and
|
||||
default is
|
||||
.BR time .
|
||||
.TP
|
||||
.BI "\-U " columns
|
||||
Configure a set (and order) of columns being shown in the call summary.
|
||||
The
|
||||
.I columns
|
||||
argument is a comma-separated list with items being one of the following:
|
||||
.RS
|
||||
.TP 14
|
||||
.B time_percent
|
||||
Percentage of cumulative time consumed by a specific system call.
|
||||
.TQ
|
||||
.B total_time
|
||||
Total system (or wall clock, if
|
||||
.B \-w
|
||||
option is provided) time consumed by a specific process.
|
||||
.TQ
|
||||
.B avg_time
|
||||
Average call duration.
|
||||
.TQ
|
||||
.B calls
|
||||
Call count.
|
||||
.TQ
|
||||
.B errors
|
||||
Error count.
|
||||
.TQ
|
||||
.B syscall
|
||||
Syscall name.
|
||||
.RE
|
||||
.IP
|
||||
The default value is
|
||||
.BR time_percent , total_time , avg_time , calls , errors , syscall .
|
||||
.TP
|
||||
.B \-w
|
||||
Summarise the wall clock time difference between the beginning and the end of
|
||||
each system call. The default is to summarise the system time.
|
||||
|
5
strace.c
5
strace.c
@ -1615,7 +1615,7 @@ init(int argc, char *argv[])
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
"k"
|
||||
#endif
|
||||
"a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxX:yz")) != EOF) {
|
||||
"a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:U:vVwxX:yz")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
acolumn = string_to_uint(optarg);
|
||||
@ -1714,6 +1714,9 @@ init(int argc, char *argv[])
|
||||
case 'u':
|
||||
username = optarg;
|
||||
break;
|
||||
case 'U':
|
||||
set_count_summary_columns(optarg);
|
||||
break;
|
||||
case 'v':
|
||||
qualify("abbrev=none");
|
||||
break;
|
||||
|
Reference in New Issue
Block a user