From 80e8ce73c9ebfc0305fed2a88772ff0a85caceb5 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 7 Nov 2010 17:30:35 -0500 Subject: [PATCH] PR12168: extend staprun with -w (suppress warnings) option. * buildrun.cxx: Pass -w to staprun. * runtime/staprun/common.c: Parse new -w. Document old -u. * runtime/staprun/staprun.8: Ditto. --- buildrun.cxx | 1 + runtime/staprun/common.c | 26 ++++++++++++++++++++------ runtime/staprun/mainloop.c | 2 ++ runtime/staprun/staprun.8 | 6 ++++++ runtime/staprun/staprun.h | 1 + 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/buildrun.cxx b/buildrun.cxx index 32a525a13..b373de61a 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -437,6 +437,7 @@ run_pass (systemtap_session& s) + " " + (s.verbose>1 ? "-v " : "") + (s.verbose>2 ? "-v " : "") + + (s.suppress_warnings ? "-w " : "") + (s.output_file.empty() ? "" : "-o " + s.output_file + " "); if (s.cmd != "") diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c index d3550fb4d..ba56d6ceb 100644 --- a/runtime/staprun/common.c +++ b/runtime/staprun/common.c @@ -7,7 +7,7 @@ * Public License (GPL); either version 2, or (at your option) any * later version. * - * Copyright (C) 2007 Red Hat Inc. + * Copyright (C) 2007-2010 Red Hat Inc. */ #include "staprun.h" @@ -19,6 +19,7 @@ /* variables needed by parse_args() */ int verbose; +int suppress_warnings; int target_pid; unsigned int buffer_size; char *target_cmd; @@ -101,6 +102,7 @@ void parse_args(int argc, char **argv) /* Initialize option variables. */ verbose = 0; + suppress_warnings = 0; target_pid = 0; buffer_size = 0; target_cmd = NULL; @@ -113,7 +115,7 @@ void parse_args(int argc, char **argv) fsize_max = 0; fnum_max = 0; - while ((c = getopt(argc, argv, "ALuvb:t:dc:o:x:S:D")) != EOF) { + while ((c = getopt(argc, argv, "ALuvb:t:dc:o:x:S:Dw")) != EOF) { switch (c) { case 'u': need_uprobes = 1; @@ -121,6 +123,9 @@ void parse_args(int argc, char **argv) case 'v': verbose++; break; + case 'w': + suppress_warnings=1; + break; case 'b': buffer_size = (unsigned)atoi(optarg); if (buffer_size < 1 || buffer_size > 4095) { @@ -233,9 +238,11 @@ void parse_args(int argc, char **argv) void usage(char *prog) { - err("\n%s [-v] [-c cmd ] [-x pid] [-u user] [-A|-L|-d]\n" + err("\n%s [-v] [-w] [-u] [-c cmd ] [-x pid] [-u user] [-A|-L|-d]\n" "\t[-b bufsize] [-o FILE [-D] [-S size[,N]]] MODULE [module-options]\n", prog); err("-v Increase verbosity.\n"); + err("-w Suppress warnings.\n"); + err("-u Load uprobes.ko\n"); err("-c cmd Command \'cmd\' will be run and staprun will\n"); err(" exit when it does. The '_stp_target' variable\n"); err(" will contain the pid for the command.\n"); @@ -259,10 +266,17 @@ void usage(char *prog) err(" assumed to be the maximum file size in MB.\n"); err(" When the number of output files reaches N, it\n"); err(" switches to the first output file. You can omit\n"); - err(" the second argument.\n"); + err(" the second argument.\n\n"); err("MODULE can be either a module name or a module path. If a\n"); - err("module name is used, it is looked for in the following\n"); - err("directory: /lib/modules/`uname -r`/systemtap\n"); + err("module name is used, it is searched in the following directory:\n"); + { + struct utsname utsbuf; + int rc = uname (& utsbuf); + if (! rc) + err("/lib/modules/%s/systemtap\n", utsbuf.release); + else + err("/lib/modules/`uname -r`/systemtap\n"); + } exit(1); } diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c index afdab6cc8..e4dfcbcc4 100644 --- a/runtime/staprun/mainloop.c +++ b/runtime/staprun/mainloop.c @@ -550,6 +550,8 @@ int stp_main_loop(void) break; #endif case STP_OOB_DATA: + if ((strncmp(recvbuf.payload.data, "WARNING:", 7) == 0) && suppress_warnings) + break; eprintf("%.*s", (int) nb, recvbuf.payload.data); if (strncmp(recvbuf.payload.data, "ERROR:", 5) == 0){ error_detected = 1; diff --git a/runtime/staprun/staprun.8 b/runtime/staprun/staprun.8 index 1a84015d7..f4a5a083b 100644 --- a/runtime/staprun/staprun.8 +++ b/runtime/staprun/staprun.8 @@ -43,6 +43,12 @@ prints a list of supported options. .B \-v Verbose mode. .TP +.B \-w +Suppress warnings from the script. +.TP +.B \-u +Load the uprobes.ko module. +.TP .B \-c CMD Command CMD will be run and the .I staprun diff --git a/runtime/staprun/staprun.h b/runtime/staprun/staprun.h index 252c9ed50..685cc8365 100644 --- a/runtime/staprun/staprun.h +++ b/runtime/staprun/staprun.h @@ -178,6 +178,7 @@ extern int kernel_ptr_size; /* flags */ extern int verbose; +extern int suppress_warnings; extern unsigned int buffer_size; extern char *modname; extern char *modpath; -- 2.43.5