diff options
-rw-r--r-- | hash.cxx | 18 | ||||
-rw-r--r-- | hash.h | 1 | ||||
-rw-r--r-- | session.h | 1 | ||||
-rw-r--r-- | tapsets.cxx | 34 |
4 files changed, 53 insertions, 1 deletions
@@ -237,4 +237,22 @@ find_hash (systemtap_session& s, const string& script) find_script_hash(s, script, base); } + +void +find_tracequery_hash (systemtap_session& s) +{ + hash h; + get_base_hash(s, h); + + // The basic hash should be good enough for the tracepoint query module + + // Get the directory path to store our cached module + string result, hashdir; + h.result(result); + if (!create_hashdir(s, result, hashdir)) + return; + + s.tracequery_path = hashdir + "/tracequery_" + result + ".ko"; +} + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ @@ -35,5 +35,6 @@ public: }; void find_hash (systemtap_session& s, const std::string& script); +void find_tracequery_hash (systemtap_session& s); /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ @@ -117,6 +117,7 @@ struct systemtap_session std::string cache_path; std::string hash_path; std::string stapconf_path; + std::string tracequery_path; // dwarfless operation bool consult_symtab; diff --git a/tapsets.cxx b/tapsets.cxx index bc567491..e9ade595 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -18,6 +18,7 @@ #include "buildrun.h" #include "dwarf_wrappers.h" #include "auto_free.h" +#include "hash.h" #include <cstdlib> #include <algorithm> @@ -9993,12 +9994,43 @@ tracepoint_builder::init_dw(systemtap_session& s) if (dw != NULL) return true; + if (s.use_cache) + { + // see if the cached module exists + find_tracequery_hash(s); + if (!s.tracequery_path.empty()) + { + int fd = open(s.tracequery_path.c_str(), O_RDONLY); + if (fd != -1) + { + if (s.verbose > 2) + clog << "Pass 2: using cached " << s.tracequery_path << endl; + + dw = new dwflpp(s); + dw->setup_user(s.tracequery_path); + close(fd); + return true; + } + } + } + + // no cached module, time to make it string tracequery_ko; int rc = make_tracequery(s, tracequery_ko); if (rc != 0) return false; - // TODO cache tracequery.ko + if (s.use_cache) + { + // try to save tracequery in the cache + if (s.verbose > 2) + clog << "Copying " << tracequery_ko + << " to " << s.tracequery_path << endl; + if (copy_file(tracequery_ko.c_str(), + s.tracequery_path.c_str()) != 0) + cerr << "Copy failed (\"" << tracequery_ko << "\" to \"" + << s.tracequery_path << "\"): " << strerror(errno) << endl; + } dw = new dwflpp(s); dw->setup_user(tracequery_ko); |