From: "houtao1 at huawei dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/23775] Pass 2 failed when generate a kernel module for stap script which uses kernel trace-point
Date: Sun, 14 Oct 2018 11:29:00 -0000 [thread overview]
Message-ID: <bug-23775-6586-TjHRaeRYZb@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <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.
next prev parent reply other threads:[~2018-10-14 11:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-14 11:13 [Bug translator/23775] New: " houtao1 at huawei dot com
2018-10-14 11:29 ` houtao1 at huawei dot com [this message]
2018-10-14 11:41 ` [Bug translator/23775] " houtao1 at huawei dot com
2018-10-16 15:25 ` fche at redhat dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-23775-6586-TjHRaeRYZb@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).