From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11601 invoked by alias); 21 Sep 2011 09:19:22 -0000 Received: (qmail 11594 invoked by uid 22791); 21 Sep 2011 09:19:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mta-out.inet.fi (HELO kirsi1.inet.fi) (195.156.147.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Sep 2011 09:19:04 +0000 Received: from sauna (84.248.66.131) by kirsi1.inet.fi (8.5.133) id 4DF73CDC04DA497B; Wed, 21 Sep 2011 12:19:03 +0300 Received: from lindi by sauna with local (Exim 4.72) (envelope-from ) id 1R6IxL-0005x0-3H; Wed, 21 Sep 2011 12:19:03 +0300 From: Timo Juhani Lindfors To: systemtap@sourceware.org Cc: Timo Juhani Lindfors Subject: [PATCH] Tell the user if UTS_VERSION does not match running kernel Date: Wed, 21 Sep 2011 09:19:00 -0000 Message-Id: <1316596741-22842-1-git-send-email-timo.lindfors@iki.fi> In-Reply-To: <848vpigsqm.fsf@sauna.l.org> References: <848vpigsqm.fsf@sauna.l.org> X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2011-q3/txt/msg00370.txt.bz2 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 + +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 "; 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\" "; -- 1.7.2.5