From: Timo Juhani Lindfors <timo.lindfors@iki.fi>
To: systemtap@sourceware.org
Cc: Timo Juhani Lindfors <timo.lindfors@iki.fi>
Subject: [PATCH] Tell the user if UTS_VERSION does not match running kernel
Date: Wed, 21 Sep 2011 09:19:00 -0000 [thread overview]
Message-ID: <1316596741-22842-1-git-send-email-timo.lindfors@iki.fi> (raw)
In-Reply-To: <848vpigsqm.fsf@sauna.l.org>
The test is done before looking at build-id since build-id error
messages like
ERROR: Build-id mismatch: "kernel" vs. "vmlinux-2.6.32-5-amd64" byte 0 (0x5e vs 0xff)
Pass 5: run failed. Try again with another '--vp 00001' option.
are not very user-friendly.
---
buildrun.cxx | 1 +
runtime/autoconf-generated-compile.c | 4 ++++
translate.cxx | 17 +++++++++++++++++
3 files changed, 22 insertions(+), 0 deletions(-)
create mode 100644 runtime/autoconf-generated-compile.c
diff --git a/buildrun.cxx b/buildrun.cxx
index 0435403..f3dcda5 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -214,6 +214,7 @@ compile_pass (systemtap_session& s)
o << "$(STAPCONF_HEADER):" << endl;
o << "\t@echo -n > $@" << endl;
output_autoconf(s, o, "autoconf-hrtimer-rel.c", "STAPCONF_HRTIMER_REL", NULL);
+ output_autoconf(s, o, "autoconf-generated-compile.c", "STAPCONF_GENERATED_COMPILE", NULL);
output_autoconf(s, o, "autoconf-hrtimer-getset-expires.c", "STAPCONF_HRTIMER_GETSET_EXPIRES", NULL);
output_autoconf(s, o, "autoconf-inode-private.c", "STAPCONF_INODE_PRIVATE", NULL);
output_autoconf(s, o, "autoconf-constant-tsc.c", "STAPCONF_CONSTANT_TSC", NULL);
diff --git a/runtime/autoconf-generated-compile.c b/runtime/autoconf-generated-compile.c
new file mode 100644
index 0000000..abf0765
--- /dev/null
+++ b/runtime/autoconf-generated-compile.c
@@ -0,0 +1,4 @@
+#include <generated/compile.h>
+
+char* x = UTS_VERSION;
+
diff --git a/translate.cxx b/translate.cxx
index 8dc0995..0aff9d1 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -1162,6 +1162,9 @@ c_unparser::emit_module_init ()
// just in case modversions didn't.
o->newline() << "{";
o->newline(1) << "const char* release = UTS_RELEASE;";
+ o->newline() << "#ifdef STAPCONF_GENERATED_COMPILE";
+ o->newline() << "const char* version = UTS_VERSION;";
+ o->newline() << "#endif";
// NB: This UTS_RELEASE compile-time macro directly checks only that
// the compile-time kbuild tree matches the compile-time debuginfo/etc.
@@ -1182,6 +1185,17 @@ c_unparser::emit_module_init ()
o->newline() << "rc = -EINVAL;";
o->newline(-1) << "}";
+ o->newline() << "#ifdef STAPCONF_GENERATED_COMPILE";
+ o->newline() << "if (strcmp (utsname()->version, version)) {";
+ o->newline(1) << "_stp_error (\"module version mismatch (%s vs %s), release %s\", "
+ << "version, "
+ << "utsname()->version, "
+ << "release"
+ << ");";
+ o->newline() << "rc = -EINVAL;";
+ o->newline(-1) << "}";
+ o->newline() << "#endif";
+
// perform buildid-based checking if able
o->newline() << "if (_stp_module_check()) rc = -EINVAL;";
@@ -5813,6 +5827,9 @@ translate_pass (systemtap_session& s)
s.op->newline() << "#include <linux/utsname.h>";
s.op->newline() << "#include <linux/version.h>";
// s.op->newline() << "#include <linux/compile.h>";
+ s.op->newline() << "#ifdef STAPCONF_GENERATED_COMPILE";
+ s.op->newline() << "#include <generated/compile.h>";
+ s.op->newline() << "#endif";
s.op->newline() << "#include \"loc2c-runtime.h\" ";
s.op->newline() << "#include \"access_process_vm.h\" ";
--
1.7.2.5
prev parent reply other threads:[~2011-09-21 9:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-13 7:54 RFC: improve build-id mismatch error reporting Timo Juhani Lindfors
2011-09-13 8:38 ` Mark Wielaard
2011-09-20 11:30 ` Timo Juhani Lindfors
2011-09-20 12:52 ` Frank Ch. Eigler
2011-09-21 9:17 ` Timo Juhani Lindfors
2011-09-21 9:19 ` Timo Juhani Lindfors [this message]
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=1316596741-22842-1-git-send-email-timo.lindfors@iki.fi \
--to=timo.lindfors@iki.fi \
--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).