summaryrefslogtreecommitdiffstats
path: root/hash.cxx
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-04-01 23:04:29 +0200
committerMark Wielaard <mjw@redhat.com>2009-04-01 23:04:29 +0200
commit2c246d55893998d60461671767c5f9c05f70c6b7 (patch)
tree04e20f69c813c67534d8a3bd9cd0d4cad84a3544 /hash.cxx
parentdd1636396623adacdb9e6502adabd9195ae7ef33 (diff)
parent952ce18c9672046c052fc77d5da8f98e8ae75735 (diff)
downloadsystemtap-steved-2c246d55893998d60461671767c5f9c05f70c6b7.tar.gz
systemtap-steved-2c246d55893998d60461671767c5f9c05f70c6b7.tar.xz
systemtap-steved-2c246d55893998d60461671767c5f9c05f70c6b7.zip
Merge branch 'master' into pr6866
Diffstat (limited to 'hash.cxx')
-rw-r--r--hash.cxx45
1 files changed, 31 insertions, 14 deletions
diff --git a/hash.cxx b/hash.cxx
index b8d5a0e4..3ff6848d 100644
--- a/hash.cxx
+++ b/hash.cxx
@@ -48,6 +48,20 @@ hash::add(const unsigned char *buffer, size_t size)
void
+hash::add_file(const std::string& filename)
+{
+ struct stat st;
+
+ if (stat(filename.c_str(), &st) == 0)
+ {
+ add(filename);
+ add(st.st_size);
+ add(st.st_mtime);
+ }
+}
+
+
+void
hash::result(string& r)
{
ostringstream rstream;
@@ -68,37 +82,40 @@ hash::result(string& r)
static void
get_base_hash (systemtap_session& s, hash& h)
{
- struct stat st;
-
// Hash kernel release and arch.
h.add(s.kernel_release);
h.add(s.kernel_build_tree);
h.add(s.architecture);
+ // Hash a few kernel version/build-id files too
+ // (useful for kernel developers reusing a single source tree)
+ h.add_file(s.kernel_build_tree + "/.config");
+ h.add_file(s.kernel_build_tree + "/.version");
+ h.add_file(s.kernel_build_tree + "/include/linux/compile.h");
+ h.add_file(s.kernel_build_tree + "/include/linux/version.h");
+ h.add_file(s.kernel_build_tree + "/include/linux/utsrelease.h");
+
+ // If the kernel is a git working directory, then add the git HEAD
+ // revision to our hash as well.
+ // XXX avoiding this for now, because it's potentially expensive and has
+ // uncertain gain. The only corner case that this may help is if a developer
+ // is switching the source tree without rebuilding the kernel...
+ ///h.add(git_revision(s.kernel_build_tree));
+
// Hash runtime path (that gets added in as "-R path").
h.add(s.runtime_path);
// Hash compiler path, size, and mtime. We're just going to assume
// we'll be using gcc. XXX: getting kbuild to spit out out would be
// better.
- string gcc_path = find_executable ("gcc");
- if (stat(gcc_path.c_str(), &st) == 0)
- {
- h.add(gcc_path);
- h.add(st.st_size);
- h.add(st.st_mtime);
- }
+ h.add_file(find_executable("gcc"));
// Hash the systemtap size and mtime. We could use VERSION/DATE,
// but when developing systemtap that doesn't work well (since you
// can compile systemtap multiple times in 1 day). Since we don't
// know exactly where we're getting run from, we'll use
// /proc/self/exe.
- if (stat("/proc/self/exe", &st) == 0)
- {
- h.add(st.st_size);
- h.add(st.st_mtime);
- }
+ h.add_file("/proc/self/exe");
}