This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Tell the user if UTS_VERSION does not match running kernel
- From: Timo Juhani Lindfors <timo dot lindfors at iki dot fi>
- To: systemtap at sourceware dot org
- Cc: Timo Juhani Lindfors <timo dot lindfors at iki dot fi>
- Date: Wed, 21 Sep 2011 12:19:01 +0300
- Subject: [PATCH] Tell the user if UTS_VERSION does not match running kernel
- References: <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