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 <ldv@altlinux.org>
This commit is contained in:
Eugene Syromyatnikov 2018-03-10 05:12:45 +01:00 committed by Dmitry V. Levin
parent aa01b5368d
commit 3cdaf39e3d
3 changed files with 34 additions and 1 deletions

1
NEWS
View File

@ -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)
===============================================

View File

@ -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

View File

@ -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;