From afcb051f169afc0e26ded3b68a1e78661ee5a908 Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Tue, 9 Mar 2021 17:20:22 -0500 Subject: [PATCH 1/1] 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 Reviewed-by: Benjamin Kaduk --- doc/man-pages/pod8/fstrace_dump.pod | 10 +++++++++- src/venus/fstrace.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/man-pages/pod8/fstrace_dump.pod b/doc/man-pages/pod8/fstrace_dump.pod index 92c5224..d1031ff 100644 --- a/doc/man-pages/pod8/fstrace_dump.pod +++ b/doc/man-pages/pod8/fstrace_dump.pod @@ -11,12 +11,14 @@ B S<<< [B<-set> >+] >>> S<<< [B<-follow> >] >>> S<<< [B<-file> >] >>> S<<< [B<-sleep> >] >>> + S<<< [B<-debug>] >>> [B<-help>] B S<<< [B<-se> >+] >>> S<<< [B<-fo> >] >>> S<<< [B<-fi> >] >>> S<<< [B<-sl> >] >>> + 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 diff --git a/src/venus/fstrace.c b/src/venus/fstrace.c index d2d1a17..45be05e 100644 --- a/src/venus/fstrace.c +++ b/src/venus/fstrace.c @@ -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"); } -- 1.9.4