fstrace: add dump -debug option

As a debugging aid, add a -debug option to the dump subcommand to
display each trace record in raw hex format as well as the normal
decoded format.

Change-Id: I80dd675a07e048e25749a9afb584515effcbc08a
Reviewed-on: https://gerrit.openafs.org/14557
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Mark Vitale 2021-03-09 17:20:22 -05:00 committed by Benjamin Kaduk
parent 966d5eb58f
commit afcb051f16
2 changed files with 23 additions and 1 deletions

View File

@ -11,12 +11,14 @@ B<fstrace dump> S<<< [B<-set> <I<set name>>+] >>>
S<<< [B<-follow> <I<log name>>] >>>
S<<< [B<-file> <I<output filename>>] >>>
S<<< [B<-sleep> <I<seconds between reads>>] >>>
S<<< [B<-debug>] >>>
[B<-help>]
B<fstrace d> S<<< [B<-se> <I<set name>>+] >>>
S<<< [B<-fo> <I<log name>>] >>>
S<<< [B<-fi> <I<output filename>>] >>>
S<<< [B<-sl> <I<seconds between reads>>] >>>
S<<< [B<-d>] >>>
[B<-h>]
=for html
@ -31,7 +33,8 @@ the B<-file> argument.
To write the log continuously to the standard output stream or to a file,
use the B<-follow> argument. By default, the log's contents are written
out every ten seconds and then automatically cleared. To change the
interval between writes, use the B<-sleep> argument.
interval between writes, use the B<-sleep> argument. To display the raw
format of each trace log entry, use the B<-debug> argument.
=head1 CAUTIONS
@ -85,6 +88,11 @@ Sets the number of seconds between writes of the trace log's contents when
it is dumped continuously. Provide the B<-follow> argument along with this
one. If this argument is omitted, the default interval is ten seconds.
=item B<-debug>
Specifies that each record in the trace log should be displayed in its raw
hex format as well as the normal decoded output.
=item B<-help>
Prints the online help for this command. All other valid options are

View File

@ -69,6 +69,7 @@ struct logInfo {
} *allInfo = 0;
int dumpDebugFlag = 0;
/* given a type and an address, get the size of the thing
* in words.
@ -250,6 +251,13 @@ DisplayRecord(FILE *outFilep, afs_int32 *alp, afs_int32 rsize)
pftix = 0;
/* init things */
if (dumpDebugFlag) {
fprintf(outFilep, "DEBUG:");
for (i = 0; i < rsize; i++) {
fprintf(outFilep, " %08x", alp[i]);
}
fprintf(outFilep, "\n");
}
for (i = 0; i < 4 * ICL_MAXEXPANSION; i++)
printfParms[i] = 0;
/* decode each parameter, getting addrs for afs_hyper_t and strings */
@ -1152,6 +1160,10 @@ DoDump(struct cmd_syndesc *as, void *arock)
waitTime = strtol(as->parms[3].items->data, NULL, 0);
}
if (as->parms[4].items) {
dumpDebugFlag = 1;
}
if (as->parms[2].items) {
/* try to open the specified output file */
if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL) {
@ -1212,6 +1224,8 @@ SetUpDump(void)
"path to trace log file for writing");
(void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL,
"interval (secs) for writes when using -follow");
(void)cmd_AddParm(dumpSyntax, "-debug", CMD_FLAG, CMD_OPTIONAL,
"dump raw record as well");
}