From: Eugene Syromyatnikov Date: Sat, 10 Mar 2018 04:12:45 +0000 (+0100) Subject: Add user interface for configuring xlat output style X-Git-Tag: v4.23~308 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cdaf39e3d81a41c5a2c98d9570a909d1f413955;p=strace Add user interface for configuring xlat output style * strace.c (init): Handle -X option, set xlat_verbosity according to -X argument. * strace.1.in: Document -X option. * NEWS: Mention it. Closes: https://github.com/strace/strace/issues/27 Co-Authored-by: Dmitry V. Levin --- diff --git a/NEWS b/NEWS index 3da6c175..66304fb8 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ Noteworthy changes in release ?.?? (????-??-??) using --with-libdw option. Whether -k option is compiled is now configured at build time using --enable-stacktrace option. + * Added -X option for configuring xlat output formatting. Noteworthy changes in release 4.22 (2018-04-05) =============================================== diff --git a/strace.1.in b/strace.1.in index 46ffc999..b15c17e2 100644 --- a/strace.1.in +++ b/strace.1.in @@ -65,6 +65,7 @@ strace \- trace system calls and signals .OP \-a column .OP \-o file .OP \-s strsize +.OP \-X format .OM \-P path .OM \-p pid .BR "" { @@ -325,6 +326,27 @@ Print all non-ASCII strings in hexadecimal string format. .B \-xx Print all strings in hexadecimal string format. .TP +.BI "\-X " format +Set the format for printing of named constants and flags. +Supported +.I format +values are: +.RS +.TP 10 +.B raw +Raw number output, without decoding. +.TP +.B abbrev +Output a named constant or a set of flags instead of the raw number if they are +found. +This is the default +.B strace +behaviour. +.TP +.B verbose +Output both the raw value and the decoded string (as a comment). +.RE +.TP .B \-y Print paths associated with file descriptor arguments. .TP diff --git a/strace.c b/strace.c index 7b79b0c5..4f41a259 100644 --- a/strace.c +++ b/strace.c @@ -1595,7 +1595,7 @@ init(int argc, char *argv[]) #ifdef ENABLE_STACKTRACE "k" #endif - "a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxyz")) != EOF) { + "a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxX:yz")) != EOF) { switch (c) { case 'a': acolumn = string_to_uint(optarg); @@ -1710,6 +1710,16 @@ init(int argc, char *argv[]) case 'x': xflag++; break; + case 'X': + if (!strcmp(optarg, "raw")) + xlat_verbosity = XLAT_STYLE_RAW; + else if (!strcmp(optarg, "abbrev")) + xlat_verbosity = XLAT_STYLE_ABBREV; + else if (!strcmp(optarg, "verbose")) + xlat_verbosity = XLAT_STYLE_VERBOSE; + else + error_opt_arg(c, optarg); + break; case 'y': show_fd_path++; break;