From c1743705978ff048870c0b38d580ee7067d7ad0a Mon Sep 17 00:00:00 2001 From: Adrien Kunysz Date: Tue, 25 May 2010 11:03:41 -0400 Subject: [PATCH] PR11609: --all-options stap option to -d ALL_LOADED_MODULES * session.cxx (insert_loaded_modules): Parse /proc/modules to populate unwindsym_modules ... (parse_cmdline): ... if --all-options was given. * stap.1.in: Document it. --- session.cxx | 20 ++++++++++++++++++++ session.h | 1 + stap.1.in | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/session.cxx b/session.cxx index 86de5e0e4..b2e6c00ee 100644 --- a/session.cxx +++ b/session.cxx @@ -350,6 +350,7 @@ systemtap_session::parse_cmdline (int argc, char * const argv []) #define LONG_OPT_CLEAN_CACHE 13 #define LONG_OPT_COMPATIBLE 14 #define LONG_OPT_LDD 15 +#define LONG_OPT_ALL_MODULES 16 // NB: also see find_hash(), usage(), switch stmt below, stap.1 man page static struct option long_options[] = { { "kelf", 0, &long_opt, LONG_OPT_KELF }, @@ -373,6 +374,7 @@ systemtap_session::parse_cmdline (int argc, char * const argv []) { "clean-cache", 0, &long_opt, LONG_OPT_CLEAN_CACHE }, { "compatible", 1, &long_opt, LONG_OPT_COMPATIBLE }, { "ldd", 0, &long_opt, LONG_OPT_LDD }, + { "all-modules", 0, &long_opt, LONG_OPT_ALL_MODULES }, { NULL, 0, NULL, 0 } }; int grc = getopt_long (argc, argv, "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:W", @@ -706,6 +708,10 @@ systemtap_session::parse_cmdline (int argc, char * const argv []) unwindsym_ldd = true; break; + case LONG_OPT_ALL_MODULES: + insert_loaded_modules(); + break; + default: // NOTREACHED unless one added a getopt option but not a corresponding switch/case: cerr << "Unhandled long argument id " << long_opt << endl; @@ -797,6 +803,20 @@ systemtap_session::check_options (int argc, char * const argv []) } } +void systemtap_session::insert_loaded_modules() +{ + char line[1024]; + ifstream procmods ("/proc/modules"); + while (procmods.good()) { + procmods.getline (line, sizeof(line)); + strtok(line, " \t"); + if (line[0] == '\0') + break; // maybe print a warning? + unwindsym_modules.insert (string (line)); + } + procmods.close(); +} + void systemtap_session::setup_kernel_release (const char* kstr) { diff --git a/session.h b/session.h index f25daf802..04d24e592 100644 --- a/session.h +++ b/session.h @@ -82,6 +82,7 @@ struct systemtap_session // and/or in the initialize method (session.cxx). void initialize (); void setup_kernel_release (const char* kstr); + void insert_loaded_modules (); // command line parsing int parse_cmdline (int argc, char * const argv []); diff --git a/stap.1.in b/stap.1.in index bf5361ff3..9fa091129 100644 --- a/stap.1.in +++ b/stap.1.in @@ -188,6 +188,11 @@ ldd to be necessary for user-space binaries being probe or listed with the \-d option. Caution: this can make the probe modules considerably larger. .TP +.BI \-\-all-modules +Equivalent to specifying "-d" for each kernel modules that are +currently loaded. Caution: this can make the probe modules considerably +larger. +.TP .BI \-o " FILE" Send standard output to named file. In bulk mode, percpu files will start with FILE_ (FILE_cpu with -F) followed by the cpu number. -- 2.43.5