From 61f1a63b261ab99923c07bf83eedcf76ae73f315 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 20 Oct 2010 13:13:20 -0400 Subject: [PATCH] PR10745: automate kernel source_tree finding with stap -r /PATH/ * tapsets.cxx (init_dw): Provide diagnostics when figuring out source_tree. * session.cxx (main): Ditto. For stap -r /PATH/, heuristically infer source_tree too. --- session.cxx | 21 +++++++++++++++++++++ tapsets.cxx | 3 +++ 2 files changed, 24 insertions(+) diff --git a/session.cxx b/session.cxx index e59906070..526ccaa31 100644 --- a/session.cxx +++ b/session.cxx @@ -1101,11 +1101,32 @@ systemtap_session::setup_kernel_release (const char* kstr) while (version_file.get(c) && c != '\n') kernel_release.push_back(c); } + + // PR10745 + // Maybe it's a full kernel source tree, for purposes of PR10745. + // In case CONFIG_DEBUG_INFO was set, we'd find it anyway with the + // normal search in tapsets.cxx. Without CONFIG_DEBUG_INFO, we'd + // need heuristics such as this one: + + string some_random_source_only_file = kernel_build_tree + "/COPYING"; + ifstream epic (some_random_source_only_file.c_str()); + if (! epic.fail()) + { + kernel_source_tree = kernel_build_tree; + if (verbose > 2) + clog << "Located kernel source tree (COPYING) at '" + << kernel_source_tree << "'" << endl; + } } else { kernel_release = string (kstr); kernel_build_tree = "/lib/modules/" + kernel_release + "/build"; + + // PR10745 + // Let's not look for the kernel_source_tree; it's definitely + // not THERE. tapsets.cxx might try to find it later if tracepoints + // need it. } } diff --git a/tapsets.cxx b/tapsets.cxx index 9e9244203..9f2687603 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -8268,6 +8268,9 @@ tracepoint_builder::init_dw(systemtap_session& s) const char* name = dwarf_formstring (dwarf_attr (cudie, DW_AT_comp_dir, &attr)); if (name) { + if (s.verbose > 2) + clog << "Located kernel source tree (DW_AT_comp_dir) at '" << name << "'" << endl; + s.kernel_source_tree = name; break; // skip others; modern Kbuild uses same comp_dir for them all } -- 2.43.5