This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug translator/23775] Pass 2 failed when generate a kernel module for stap script which uses kernel trace-point
- From: "houtao1 at huawei dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sourceware dot org
- Date: Sun, 14 Oct 2018 11:29:40 +0000
- Subject: [Bug translator/23775] Pass 2 failed when generate a kernel module for stap script which uses kernel trace-point
- Auto-submitted: auto-generated
- References: <bug-23775-6586@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=23775
--- Comment #1 from houtao1 at huawei dot com ---
>Ignoring duplicate kernel source tree (DW_AT_comp_dir) at '/home/htbegin/code/linux/newest'
>Checking tracepoint glob /home/htbegin/code/linux/newest//include/trace/events/*.h
>Checking tracepoint glob /home/htbegin/code/linux/newest//include/trace/*.h
>Checking tracepoint glob /home/htbegin/code/linux/newest//include/ras/*_event.h
It seems that elaborator can not find the correct kernel source directory, so
it can not find the definition of trace-point block_rq_issue neither.
The problem can be fixed by the patch proposed in
https://sourceware.org/ml/systemtap/2018-q3/msg00166.html:
When generating kernel module for a systemtap script that uses trace-point
probe, if the vanilla kernel is built by using O=build_path option and
r=build_path option is passed to stap, stap will not be able to find
kernel_source_tree and will fail on pass-2.
Linux kernel will create a symlink named source to the source tree
for out-of-source build since (399b835be30e "kbuild: add a symlink
to the source for separate objdirs"), so fix the problem by checking
whether or not the symlink exists and using it as the kernel_source_tree.
Also using a new helper dir_exists() instead of file_exists() to
ensure the existence of the directory of source tree.
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
tapsets.cxx | 34 ++++++++++++++++++++++++++--------
util.cxx | 13 +++++++++++++
util.h | 1 +
3 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/tapsets.cxx b/tapsets.cxx
index ca94be4ce..8617796d8 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -12391,16 +12391,34 @@ tracepoint_builder::init_dw(systemtap_session& s)
}
// find kernel_source_tree from a source link, when different from build
- if (s.kernel_source_tree == "" && endswith(s.kernel_build_tree, "/build"))
+ if (s.kernel_source_tree == "")
{
- string source_tree = s.kernel_build_tree;
- source_tree.replace(source_tree.length() - 5, 5, "source");
- if (file_exists(source_tree) &&
- resolve_path(source_tree) != resolve_path(s.kernel_build_tree))
+ vector<string> source_trees;
+
+ // vendor kernel (e.g. Fedora): the source link is in the same dir
+ // as the build tree
+ if (endswith(s.kernel_build_tree, "/build"))
+ {
+ string source_tree = s.kernel_build_tree;
+ source_tree.replace(source_tree.length() - 5, 5, "source");
+ source_trees.push_back(source_tree);
+ }
+
+ // vanilla kernel: the source link is in the build tree
+ source_trees.push_back(s.kernel_build_tree + "/source");
+
+ for (unsigned i = 0; i < source_trees.size(); i++)
{
- if (s.verbose > 2)
- clog << _F("Located kernel source tree at '%s'",
source_tree.c_str()) << endl;
- s.kernel_source_tree = source_tree;
+ string source_tree = source_trees[i];
+
+ if (dir_exists(source_tree) &&
+ resolve_path(source_tree) != resolve_path(s.kernel_build_tree))
+ {
+ if (s.verbose > 2)
+ clog << _F("Located kernel source tree at '%s'",
source_tree.c_str()) << endl;
+ s.kernel_source_tree = source_tree;
+ break;
+ }
}
}
diff --git a/util.cxx b/util.cxx
index 1b1127995..b4f1e9c25 100644
--- a/util.cxx
+++ b/util.cxx
@@ -103,6 +103,19 @@ file_exists (const string &path)
return false;
}
+// Check that a dir is present
+bool
+dir_exists(const string &path)
+{
+ struct stat info;
+
+ if (stat(path.c_str(), &info) == 0 &&
+ S_ISDIR(info.st_mode))
+ return true;
+
+ return false;
+}
+
// Copy a file. The copy is done via a temporary file and atomic
// rename.
bool
diff --git a/util.h b/util.h
index b4c4e40b7..4e30d4237 100644
--- a/util.h
+++ b/util.h
@@ -72,6 +72,7 @@ const char *get_home_directory(void);
size_t get_file_size(const std::string &path);
size_t get_file_size(int fd);
bool file_exists (const std::string &path);
+bool dir_exists(const std::string &path);
bool copy_file(const std::string& src, const std::string& dest,
bool verbose=false);
int create_dir(const char *dir, int mode = 0777);
--
2.16.2.dirty
--
You are receiving this mail because:
You are the assignee for the bug.