summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Sebastian <ksebasti@redhat.com>2009-07-31 14:45:10 -0400
committerKent Sebastian <ksebasti@redhat.com>2009-07-31 14:45:10 -0400
commitce91eebdf6c262a0235bdd2d3ad3acd0805bf02a (patch)
tree7ca9eef90de8b29a1a977530d623ec7240740db5
parentf1312b2c2bc1ec7b0475a251f27a2f75779f4ccb (diff)
downloadsystemtap-steved-ce91eebdf6c262a0235bdd2d3ad3acd0805bf02a.tar.gz
systemtap-steved-ce91eebdf6c262a0235bdd2d3ad3acd0805bf02a.tar.xz
systemtap-steved-ce91eebdf6c262a0235bdd2d3ad3acd0805bf02a.zip
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
-rw-r--r--cache.cxx8
-rw-r--r--main.cxx26
-rw-r--r--runtime/staprun/common.c1
-rw-r--r--runtime/staprun/mainloop.c1
-rw-r--r--runtime/staprun/staprun.c1
-rw-r--r--runtime/staprun/staprun.h3
-rw-r--r--runtime/staprun/staprun_funcs.c1
-rw-r--r--util.cxx4
8 files changed, 45 insertions, 0 deletions
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 <cerrno>
#include <string>
#include <fstream>
@@ -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 <iostream>
#include <fstream>
@@ -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<s.include_path.size(); i++)
{
// now iterate upon it
@@ -1015,6 +1023,8 @@ main (int argc, char * const argv [])
<< "Try again with another '--vp 1' option."
<< endl;
+ STAP_PROBE1(stap, pass1__end, &s);
+
if (rc || s.last_pass == 1 || pending_interrupts) goto cleanup;
times (& tms_before);
@@ -1022,6 +1032,7 @@ main (int argc, char * const argv [])
// PASS 2: ELABORATION
s.verbose = s.perpass_verbose[1];
+ STAP_PROBE1(stap, pass2__start, &s);
rc = semantic_pass (s);
if (s.listing_mode || (rc == 0 && s.last_pass == 2))
@@ -1076,12 +1087,15 @@ main (int argc, char * const argv [])
/* Print out list of missing files */
missing_rpm_list_print(s);
+ STAP_PROBE1(stap, pass2__end, &s);
+
if (rc || s.listing_mode || s.last_pass == 2 || pending_interrupts) goto cleanup;
// PASS 3: TRANSLATION
s.verbose = s.perpass_verbose[2];
times (& tms_before);
gettimeofday (&tv_before, NULL);
+ STAP_PROBE1(stap, pass3__start, &s);
rc = translate_pass (s);
@@ -1105,12 +1119,15 @@ main (int argc, char * const argv [])
<< "Try again with another '--vp 001' option."
<< endl;
+ STAP_PROBE1(stap, pass3__end, &s);
+
if (rc || s.last_pass == 3 || pending_interrupts) goto cleanup;
// PASS 4: COMPILATION
s.verbose = s.perpass_verbose[3];
times (& tms_before);
gettimeofday (&tv_before, NULL);
+ STAP_PROBE1(stap, pass4__start, &s);
rc = compile_pass (s);
if (rc == 0 && s.last_pass == 4)
@@ -1172,6 +1189,8 @@ main (int argc, char * const argv [])
}
}
+ STAP_PROBE1(stap, pass4__end, &s);
+
if (rc || s.last_pass == 4 || pending_interrupts) goto cleanup;
@@ -1183,6 +1202,7 @@ pass_5:
// NB: this message is a judgement call. The other passes don't emit
// a "hello, I'm starting" message, but then the others aren't interactive
// and don't take an indefinite amount of time.
+ STAP_PROBE1(stap, pass5__start, &s);
if (s.verbose) clog << "Pass 5: starting run." << endl;
rc = run_pass (s);
times (& tms_after);
@@ -1198,9 +1218,13 @@ pass_5:
// if (rc) goto cleanup;
+ STAP_PROBE1(stap, pass5__end, &s);
+
// PASS 6: cleaning up
cleanup:
+ STAP_PROBE1(stap, pass6__start, &s);
+
// update the database information
if (!rc && s.tapset_compile_coverage && !pending_interrupts) {
#ifdef HAVE_LIBSQLITE3
@@ -1232,6 +1256,8 @@ pass_5:
}
}
+ STAP_PROBE1(stap, pass6__end, &s);
+
return (rc||pending_interrupts) ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index 5c4a8431..afe96606 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -450,6 +450,7 @@ int send_request(int type, void *data, int len)
char buf[1024];
int rc = 0;
+ STAP_PROBE3(stapio, send__ctlmsg, type, data, len);
/* Before doing memcpy, make sure 'buf' is big enough. */
if ((len + 4) > (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 <stdexcept>
#include <cerrno>
@@ -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<char **>(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;
}