From ce91eebdf6c262a0235bdd2d3ad3acd0805bf02a Mon Sep 17 00:00:00 2001 From: Kent Sebastian Date: Fri, 31 Jul 2009 14:45:10 -0400 Subject: PR10204: Place userspace markers in systemtap itself * cache.cxx (add_to_cache,clean_cache): add static markers * main.cxx (main): likewise * runtime/staprun/common.c (send_request): likewise * runtime/staprun/mainloop.c (stp_main_loop): likewise * runtime/staprun/staprun.c (remove_module): likewise * runtime/staprun/staprun.h: include sdt.h * runtime/staprun/staprun_funcs.c (insert_module): likewise * util.cxx (stap_system): likewise * tapset/stap_staticmarkers.stp: new file --- cache.cxx | 8 ++++++++ main.cxx | 26 ++++++++++++++++++++++++++ runtime/staprun/common.c | 1 + runtime/staprun/mainloop.c | 1 + runtime/staprun/staprun.c | 1 + runtime/staprun/staprun.h | 3 +++ runtime/staprun/staprun_funcs.c | 1 + util.cxx | 4 ++++ 8 files changed, 45 insertions(+) diff --git a/cache.cxx b/cache.cxx index bfe2b527..99b88000 100644 --- a/cache.cxx +++ b/cache.cxx @@ -10,6 +10,7 @@ #include "session.h" #include "cache.h" #include "util.h" +#include "sys/sdt.h" #include #include #include @@ -59,6 +60,7 @@ add_to_cache(systemtap_session& s) } string module_src_path = s.tmpdir + "/" + s.module_name + ".ko"; + STAP_PROBE2(stap, cache__add__module, module_src_path.c_str(), s.hash_path.c_str()); if (s.verbose > 1) clog << "Copying " << module_src_path << " to " << s.hash_path << endl; if (copy_file(module_src_path.c_str(), s.hash_path.c_str()) != 0) @@ -79,6 +81,8 @@ add_to_cache(systemtap_session& s) string module_signature_src_path = module_src_path; module_signature_src_path += ".sgn"; + STAP_PROBE2(stap, cache__add__nss, module_signature_src_path.c_str(), module_signature_dest_path.c_str()); + if (s.verbose > 1) clog << "Copying " << module_signature_src_path << " to " << module_signature_dest_path << endl; if (copy_file(module_signature_src_path.c_str(), module_signature_dest_path.c_str()) != 0) @@ -97,6 +101,7 @@ add_to_cache(systemtap_session& s) c_dest_path.resize(c_dest_path.size() - 3); c_dest_path += ".c"; + STAP_PROBE2(stap, cache__add__source, s.translated_source.c_str(), c_dest_path.c_str()); if (s.verbose > 1) clog << "Copying " << s.translated_source << " to " << c_dest_path << endl; @@ -241,6 +246,8 @@ get_from_cache(systemtap_session& s) clog << "Pass 4: using cached " << s.hash_path << endl; } + STAP_PROBE2(stap, cache__get, c_src_path.c_str(), s.hash_path.c_str()); + return true; } @@ -341,6 +348,7 @@ clean_cache(systemtap_session& s) if ( (r_cache_size / 1024 / 1024) < cache_mb_max) //convert r_cache_size to MiB break; + STAP_PROBE1(stap, cache__clean, (i->path).c_str()); //remove this (*i) cache_entry, add to removed list i->unlink(); r_cache_size -= i->size; diff --git a/main.cxx b/main.cxx index 6a9444de..2c1b1c68 100644 --- a/main.cxx +++ b/main.cxx @@ -21,6 +21,7 @@ #include "coveragedb.h" #include "git_version.h" #include "rpm_finder.h" +#include "sys/sdt.h" #include #include @@ -820,6 +821,8 @@ main (int argc, char * const argv []) // PASS 0: setting up s.verbose = s.perpass_verbose[0]; + STAP_PROBE1(stap, pass0__start, &s); + // For PR1477, we used to override $PATH and $LC_ALL and other stuff // here. We seem to use complete pathnames in @@ -871,12 +874,15 @@ main (int argc, char * const argv []) // and reasonably timely exit. setup_signals(&handle_interrupt); + STAP_PROBE1(stap, pass0__end, &s); + struct tms tms_before; times (& tms_before); struct timeval tv_before; gettimeofday (&tv_before, NULL); // PASS 1a: PARSING USER SCRIPT + STAP_PROBE1(stap, pass1a__start, &s); struct stat user_file_stat; int user_file_stat_rc = -1; @@ -928,6 +934,8 @@ main (int argc, char * const argv []) version_suffixes.push_back (""); // PASS 1b: PARSING LIBRARY SCRIPTS + STAP_PROBE1(stap, pass1b__start, &s); + for (unsigned i=0; i (int)sizeof(buf)) { _err("exceeded maximum send_request size.\n"); diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c index 7125a7bb..45b142bc 100644 --- a/runtime/staprun/mainloop.c +++ b/runtime/staprun/mainloop.c @@ -485,6 +485,7 @@ int stp_main_loop(void) type = *(uint32_t *) recvbuf; data = (void *)(recvbuf + sizeof(uint32_t)); nb -= sizeof(uint32_t); + STAP_PROBE3(staprun, recv__ctlmsg, type, data, nb); switch (type) { #if STP_TRANSPORT_VERSION == 1 diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c index 42b72ff1..7069cab3 100644 --- a/runtime/staprun/staprun.c +++ b/runtime/staprun/staprun.c @@ -192,6 +192,7 @@ static int remove_module(const char *name, int verb) close_ctl_channel(); dbug(2, "removing module %s\n", name); + STAP_PROBE1(staprun, remove__module, name); ret = delete_module (name, 0); if (ret != 0) { err("Error removing module '%s': %s.\n", name, strerror(errno)); diff --git a/runtime/staprun/staprun.h b/runtime/staprun/staprun.h index 3c9dab3f..1c9aece8 100644 --- a/runtime/staprun/staprun.h +++ b/runtime/staprun/staprun.h @@ -38,6 +38,9 @@ /* Include config.h to pick up dependency for --prefix usage. */ #include "config.h" +/* For STAP_PROBE in staprun.c, staprun_funcs.c, mainloop.c and common.c */ +#include "sys/sdt.h" + extern void eprintf(const char *fmt, ...); extern void switch_syslog(const char *name); diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c index 781bb999..c19dc3ba 100644 --- a/runtime/staprun/staprun_funcs.c +++ b/runtime/staprun/staprun_funcs.c @@ -94,6 +94,7 @@ int insert_module(const char *path, const char *special_options, char **options) return -1; } + STAP_PROBE1(staprun, insert__module, path); /* Actually insert the module */ ret = init_module(file, sbuf.st_size, opts); saved_errno = errno; diff --git a/util.cxx b/util.cxx index 5c05a1dd..23deb37b 100644 --- a/util.cxx +++ b/util.cxx @@ -16,6 +16,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "util.h" +#include "sys/sdt.h" #include #include @@ -303,12 +304,14 @@ static pid_t spawned_pid = 0; int stap_system(const char *command) { + STAP_PROBE1(stap, stap_system__start, command); const char * argv[] = { "sh", "-c", command, NULL }; int ret, status; spawned_pid = 0; ret = posix_spawn(&spawned_pid, "/bin/sh", NULL, NULL, const_cast(argv), environ); + STAP_PROBE2(stap, stap_system__spawn, ret, spawned_pid); if (ret == 0) { if (waitpid(spawned_pid, &status, 0) == spawned_pid) @@ -316,6 +319,7 @@ stap_system(const char *command) else ret = errno; } + STAP_PROBE1(stap, stap_system__complete, ret); spawned_pid = 0; return ret; } -- cgit