diff options
author | Josh Stone <jistone@redhat.com> | 2010-03-01 18:42:18 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2010-03-02 16:05:18 -0800 |
commit | 9b3c54b2fc836e20a0a7895aa759938e62eaacf9 (patch) | |
tree | a9db703d81f4fbabe886c5acb77d6c5cb0964a07 /hash.cxx | |
parent | 6b067d7d20c10acb68d768003bf8031f155e5f39 (diff) | |
download | systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.tar.gz systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.tar.xz systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.zip |
PR11246 cont'd: Separate script/stapconf caching
I'm separating the caching and creation logic for stapconf, so it can be
conditionalized on s.use_cache instead of s.use_script_cache.
* session.h (systemtap_session): Store base_hash for better reuse.
* hash.cxx (get_base_hash): Get the base from the session, or build it.
(find_hash): Split into separate script/stapconf versions.
* cache.cxx (add_to_cache, get_from_cache): Ditto.
* main.cxx (main): Adapt caller, and delay stapconf until pass-4.
Diffstat (limited to 'hash.cxx')
-rw-r--r-- | hash.cxx | 40 |
1 files changed, 18 insertions, 22 deletions
@@ -104,9 +104,15 @@ void create_hash_log(const string &type_str, const string &parms, const string & log_file.close(); } -static void -get_base_hash (systemtap_session& s, hash& h) +static const hash& +get_base_hash (systemtap_session& s) { + if (s.base_hash) + return *s.base_hash; + + s.base_hash = new hash(); + hash& h = *s.base_hash; + // Hash kernel release and arch. h.add(s.kernel_release); h.add(s.kernel_build_tree); @@ -141,6 +147,8 @@ get_base_hash (systemtap_session& s, hash& h) // know exactly where we're getting run from, we'll use // /proc/self/exe. h.add_file("/proc/self/exe"); + + return h; } @@ -178,10 +186,10 @@ create_hashdir (systemtap_session& s, const string& result, string& hashdir) } -static void -find_script_hash (systemtap_session& s, const string& script, const hash &base) +void +find_script_hash (systemtap_session& s, const string& script) { - hash h(base); + hash h(get_base_hash(s)); struct stat st; // Hash getuid. This really shouldn't be necessary (since who you @@ -260,10 +268,10 @@ find_script_hash (systemtap_session& s, const string& script, const hash &base) } -static void -find_stapconf_hash (systemtap_session& s, const hash& base) +void +find_stapconf_hash (systemtap_session& s) { - hash h(base); + hash h(get_base_hash(s)); // Add any custom kbuild flags for (unsigned i = 0; i < s.kbuildflags.size(); i++) @@ -282,21 +290,10 @@ find_stapconf_hash (systemtap_session& s, const hash& base) } -void -find_hash (systemtap_session& s, const string& script) -{ - hash base; - get_base_hash(s, base); - find_stapconf_hash(s, base); - find_script_hash(s, script, base); -} - - string find_tracequery_hash (systemtap_session& s, const vector<string>& headers) { - hash h; - get_base_hash(s, h); + hash h(get_base_hash(s)); // Add the tracepoint headers to the computed hash for (size_t i = 0; i < headers.size(); ++i) @@ -321,8 +318,7 @@ find_tracequery_hash (systemtap_session& s, const vector<string>& headers) string find_typequery_hash (systemtap_session& s, const string& name) { - hash h; - get_base_hash(s, h); + hash h(get_base_hash(s)); // Add the typequery name to distinguish the hash h.add(name); |