diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2009-10-08 09:57:43 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-10-08 09:57:43 -0400 |
commit | 561079c8601d7ded6fe958b4cec3d0f7aec1ee63 (patch) | |
tree | b6481615519c60f87314319c1828eb6645833b19 /main.cxx | |
parent | e4cf148d68fe01b680856ad39739faf99bfc29b4 (diff) | |
download | systemtap-steved-561079c8601d7ded6fe958b4cec3d0f7aec1ee63.tar.gz systemtap-steved-561079c8601d7ded6fe958b4cec3d0f7aec1ee63.tar.xz systemtap-steved-561079c8601d7ded6fe958b4cec3d0f7aec1ee63.zip |
PR10702: preprocessor conditional for kernel CONFIG_foo
* session.h (kernel_config[]): New session field.
* main.cxx (parse_kernel_config): Populate it.
* parse.cxx (eval_comparison): Use it.
* testsuite/buildok/utrace.stp, testsuite/parseok/kconfig.stp: New tests.
* NEWS, stap.1.in, doc/langref.tex: Mention it.
Diffstat (limited to 'main.cxx')
-rw-r--r-- | main.cxx | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -335,8 +335,8 @@ setup_signals (sighandler_t handler) sigaction (SIGTERM, &sa, NULL); } -void -setup_kernel_release (systemtap_session &s, const char* kstr) { +void setup_kernel_release (systemtap_session &s, const char* kstr) +{ if (kstr[0] == '/') // fully specified path { s.kernel_build_tree = kstr; @@ -364,6 +364,29 @@ setup_kernel_release (systemtap_session &s, const char* kstr) { } } + +void parse_kernel_config (systemtap_session &s) +{ + // PR10702: pull config options + string kernel_config_file = s.kernel_build_tree + "/.config"; + ifstream kcf (kernel_config_file.c_str()); + string line; + while (getline (kcf, line)) + { + if (line.substr(0, 7) != "CONFIG_") continue; + size_t off = line.find('='); + if (off == string::npos) continue; + string key = line.substr(0, off); + string value = line.substr(off+1, string::npos); + s.kernel_config[key] = value; + } + if (s.verbose > 2) + clog << "Parsed kernel \"" << kernel_config_file << "\", number of tuples: " << s.kernel_config.size() << endl; + + kcf.close(); +} + + static void checkOptions (systemtap_session &s) { @@ -945,6 +968,9 @@ main (int argc, char * const argv []) clog << "Created temporary directory \"" << s.tmpdir << "\"" << endl; } + // Now that no further changes to s.kernel_build_tree can occur, let's use it. + parse_kernel_config (s); + // Create the name of the C source file within the temporary // directory. s.translated_source = string(s.tmpdir) + "/" + s.module_name + ".c"; @@ -1028,7 +1054,7 @@ main (int argc, char * const argv []) // GLOB_NOMATCH is acceptable if (s.verbose>1 && globbuf.gl_pathc > 0) - clog << "Searched '" << dir << "', " + clog << "Searched \"" << dir << "\", " << "found " << globbuf.gl_pathc << endl; for (unsigned j=0; j<globbuf.gl_pathc; j++) |