From 1d381a0d947061c10eb0209a49aaf8af8873726d Mon Sep 17 00:00:00 2001 From: Timo Juhani Lindfors Date: Wed, 21 Sep 2011 12:19:01 +0300 Subject: [PATCH] Tell the user if UTS_VERSION does not match running kernel 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(+) create mode 100644 runtime/autoconf-generated-compile.c diff --git a/buildrun.cxx b/buildrun.cxx index 4582232aa..daa7b00c6 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 000000000..abf076597 --- /dev/null +++ b/runtime/autoconf-generated-compile.c @@ -0,0 +1,4 @@ +#include + +char* x = UTS_VERSION; + diff --git a/translate.cxx b/translate.cxx index 8dc0995bb..0aff9d1ef 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 "; s.op->newline() << "#include "; // s.op->newline() << "#include "; + s.op->newline() << "#ifdef STAPCONF_GENERATED_COMPILE"; + s.op->newline() << "#include "; + s.op->newline() << "#endif"; s.op->newline() << "#include \"loc2c-runtime.h\" "; s.op->newline() << "#include \"access_process_vm.h\" "; -- 2.43.5