summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-03-20 16:35:06 -0700
committerJosh Stone <jistone@redhat.com>2009-03-20 16:42:04 -0700
commitb278033a7e4632a414502b63ba51fcce36f44f94 (patch)
treecfb00de74d5af2138837a8c96f1814aaa11ae8b4 /tapsets.cxx
parenta1c66a0f3d8795fbcf49ce936dee3c5645f0bfa6 (diff)
downloadsystemtap-steved-b278033a7e4632a414502b63ba51fcce36f44f94.tar.gz
systemtap-steved-b278033a7e4632a414502b63ba51fcce36f44f94.tar.xz
systemtap-steved-b278033a7e4632a414502b63ba51fcce36f44f94.zip
Cache the tracepoint query results
To use tracepoints, we build a "tracequery" module that compiles debuginfo for all available tracepoints in the user's kernel. That's a bit of a cumbersome step to do during pass-2 though. This change adds tracequery caching so we only need to compile it once.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx34
1 files changed, 33 insertions, 1 deletions
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);