From 0d06fa0d3a59d516d2816c0067e4e26e4429bcb2 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 9 Jul 2013 09:50:48 -0400 Subject: [PATCH] PR14927: make more warnings from staprun/stapdyn sensitive to -w Before, even with the -w option specified for staprun, some warnings (such as when the child process exits with a nonzero code) were still output. Now, all warnings are affected by -w. A similar operation was carried out in stapdyn, where the use of warnx() was changed to stapwarn() so that -w now silences them. This changes also gives those warnings the chance to be colored if necessary. --- stapdyn/dynutil.cxx | 10 +++++----- staprun/staprun.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/stapdyn/dynutil.cxx b/stapdyn/dynutil.cxx index 54d1c5846..919d890a9 100644 --- a/stapdyn/dynutil.cxx +++ b/stapdyn/dynutil.cxx @@ -143,20 +143,20 @@ check_dyninst_exit(BPatch_process *process) code = process->getExitCode(); if (code == EXIT_SUCCESS) return true; - warnx("Warning: child process exited with status %d", code); + stapwarn() << "Child process exited with status " << code << endl; return false; case ExitedViaSignal: code = process->getExitSignal(); - warnx("Warning: child process exited with signal %d (%s)", - code, strsignal(code)); + stapwarn() << "Child process exited with signal " << code + << " (" << strsignal(code) << ")" << endl; return false; case NoExit: if (process->isTerminated()) - warnx("Warning: child process exited in an unknown manner"); + stapwarn() << "Child process exited in an unknown manner" << endl; else - warnx("Warning: child process has not exited"); + stapwarn() << "Child process has not exited" << endl; return false; default: diff --git a/staprun/staprun.h b/staprun/staprun.h index 836c0558c..1ae856510 100644 --- a/staprun/staprun.h +++ b/staprun/staprun.h @@ -88,6 +88,8 @@ extern char *__name__; } while (0) #define warn(args...) do { \ + if (suppress_warnings) \ + break; \ print_color("warning"); \ eprintf(_("WARNING:")); \ print_color(NULL); \ -- 2.43.5