From e9737939bdde53cfd6a2a16f0bd6494a05634ce8 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 15 Aug 2008 11:49:29 +0100 Subject: small patch ... Hi guys, I append a trivial patch for systemtap. I guess the SUSE wiki page also needs updating to point out that it's broken in 11.0 by default, and that you require HEAD with Frank's buildrun.cxx fix for the mach-default include. My patch will hopefully make similar problems easier to find in future (for lovers of -v options ;-) HTH, Michael. --- ChangeLog | 8 ++++++++ buildrun.cxx | 6 +++++- configure.ac | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6886301..397308a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-15 Michael Meeks + + * configure.ac: suggest (SUSE) package name for dwfl. + + * buildrun.cxx (compile_pass): if extremely verbose, pass through + output from stap checks - helps to debug generic test compile + problems. + 2008-08-14 Dave Brolley PR 6834 diff --git a/buildrun.cxx b/buildrun.cxx index 159e1c6e..a265e4db 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -78,8 +78,12 @@ compile_pass (systemtap_session& s) if (s.verbose > 3) superverbose = "set -x;"; + string redirecterrors = "> /dev/null 2>&1"; + if (s.verbose > 6) + redirecterrors = ""; + o << "stap_check_gcc = $(shell " << superverbose << " if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo \"$(1)\"; else echo \"$(2)\"; fi)" << endl; - o << "stap_check_build = $(shell " << superverbose << " if $(CC) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(CFLAGS_KERNEL) $(EXTRA_CFLAGS) $(CFLAGS) -DKBUILD_BASENAME=\\\"" << s.module_name << "\\\" -Werror -S -o /dev/null -xc $(1) > /dev/null 2>&1 ; then echo \"$(2)\"; else echo \"$(3)\"; fi)" << endl; + o << "stap_check_build = $(shell " << superverbose << " if $(CC) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(CFLAGS_KERNEL) $(EXTRA_CFLAGS) $(CFLAGS) -DKBUILD_BASENAME=\\\"" << s.module_name << "\\\" -Werror -S -o /dev/null -xc $(1) " << redirecterrors << " ; then echo \"$(2)\"; else echo \"$(3)\"; fi)" << endl; o << "SYSTEMTAP_RUNTIME = \"" << s.runtime_path << "\"" << endl; diff --git a/configure.ac b/configure.ac index 6728ace7..5a5a0930 100644 --- a/configure.ac +++ b/configure.ac @@ -184,7 +184,7 @@ if test $build_elfutils = no; then # Need libdwfl-capable recent elfutils from Fedora save_LIBS="$LIBS" AC_CHECK_LIB(dw, dwfl_module_getsym,[],[ - AC_MSG_ERROR([missing elfutils development headers/libraries (dw 0.123+)])], + AC_MSG_ERROR([missing elfutils development headers/libraries (dw 0.123+) (libebl-devel may need to be installed)])], [-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf]) stap_LIBS="-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf" LIBS="$save_LIBS" -- cgit From a43ba4339f5b291d139e0be59bba4bc46c55ea25 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Aug 2008 12:21:22 -0400 Subject: PR6836: $$vars extensions, $$return --- ChangeLog | 9 ++++ NEWS | 5 +- stapprobes.5.in | 16 ++++-- tapsets.cxx | 121 +++++++++++++++++++++++++++--------------- testsuite/semok/thirtytwo.stp | 5 ++ 5 files changed, 108 insertions(+), 48 deletions(-) create mode 100755 testsuite/semok/thirtytwo.stp diff --git a/ChangeLog b/ChangeLog index 397308a7..ac800e8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-08-15 Frank Ch. Eigler + + PR 6836. + * tapsets.cxx (dwarf_var...visit_target_symbol): Show + "var=?" for unlocatable variables. Support $$return. + Make sure $$parms/etc. work in .return probes too. + * testsuite/semok/thirtytwo.stp: New test. + * NEWS, stapprobes.5.in: Document them. + 2008-08-15 Michael Meeks * configure.ac: suggest (SUSE) package name for dwfl. diff --git a/NEWS b/NEWS index 0cdc2aa3..d6d220a0 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,10 @@ - A formatted string representation of the variables, parameters, or local variables at a probe point is now supported via the special $$vars, - $$parms, and $$locals context variables. + $$parms, and $$locals context variables, which expand to a string + containing a list "var1=0xdead var2=0xbeef var3=?". (Here, var3 exists + but is for some reason unavailable.) In return probes only, $$return + expands to an empty string for a void function, or "$return=0xf00". * What's new in version 0.7 diff --git a/stapprobes.5.in b/stapprobes.5.in index c71f79d3..f1626166 100644 --- a/stapprobes.5.in +++ b/stapprobes.5.in @@ -334,6 +334,11 @@ $var\->field traversal to a structure's field. The indirection operator may be repeated to follow more levels of pointers. .TP +$return +is available in return probes only for functions that are declared +with a return value. +.TP +.TP $var[N] indexes into an array. The index is given with a literal number. @@ -344,12 +349,15 @@ sprintf("parm1=%x ... parmN=%x var1=%x ... varN=%x", parm1, ..., parmN, var1, ..., varN) .TP $$locals -expands to a character string that is equivalent to -sprintf("var1=%x ... varN=%x", var1, ..., varN) +expands to a subset of $$vars for only local variables. .TP $$parms -expands to a character string that is equivalent to -sprintf("parm1=%x ... parmN=%x", parm1, ..., parmN) +expands to a subset of $$vars for only function parameters. +.TP +$$return +is available in return probes only. It expands to a string that +is equivalent to sprintf("$return=%x", $return) +if the probed function has a return value, or else an empty string. .PP For ".return" probes, context variables other than the "$return" value itself are only available for the function call parameters. diff --git a/tapsets.cxx b/tapsets.cxx index 664dfb1f..1f7d2555 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4002,7 +4002,11 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) if (lvalue && !q.sess.guru_mode) throw semantic_error("write to target variable not permitted", e->tok); - if (q.has_return && e->base_name != "$return") + // See if we need to generate a new probe to save/access function + // parameters from a return probe. PR 1382. + if (q.has_return + && e->base_name != "$return" // not the special return-value variable handled below + && e->base_name != "$$return") // nor the other special variable handled below { if (lvalue) throw semantic_error("write to target variable not permitted in .return probes", e->tok); @@ -4287,7 +4291,8 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) if (e->base_name == "$$vars" || e->base_name == "$$parms" - || e->base_name == "$$locals") + || e->base_name == "$$locals" + || (q.has_return && (e->base_name == "$$return"))) { Dwarf_Die *scopes; if (dwarf_getscopes_die (scope_die, &scopes) == 0) @@ -4298,55 +4303,85 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) // Convert $$parms to sprintf of a list of parms and active local vars // which we recursively evaluate - token* tmp_tok = new token; - tmp_tok->type = tok_identifier; - tmp_tok->content = "sprintf"; - pf->tok = tmp_tok; + + // NB: we synthesize a new token here rather than reusing + // e->tok, because print_format::print likes to use + // its tok->content. + token* pf_tok = new token; + pf_tok->location = e->tok->location; + pf_tok->type = tok_identifier; + pf_tok->content = "sprint"; + + pf->tok = pf_tok; pf->print_to_stream = false; pf->print_with_format = true; pf->print_with_delim = false; pf->print_with_newline = false; pf->print_char = false; - Dwarf_Die result; - if (dwarf_child (&scopes[0], &result) == 0) - do - { - switch (dwarf_tag (&result)) - { - case DW_TAG_variable: - if (e->base_name == "$$parms") - continue; - break; - case DW_TAG_formal_parameter: - if (e->base_name == "$$locals") - continue; - break; - - default: - continue; - } + if (q.has_return && (e->base_name == "$$return")) + { + tsym->tok = e->tok; + tsym->base_name = "$return"; + + // Ignore any variable that isn't accessible. + tsym->saved_conversion_error = 0; + this->visit_target_symbol(tsym); // NB: throws nothing ... + if (tsym->saved_conversion_error) // ... but this is how we know it happened. + { - const char *diename = dwarf_diename (&result); - token* sym_tok = new token; - sym_tok->location = e->get_tok()->location; - sym_tok->type = tok_identifier; - sym_tok->content = diename; - tsym->tok = sym_tok; - tsym->base_name = "$"; - tsym->base_name += diename; - - // Ignore any variable that isn't accessible. - tsym->saved_conversion_error = 0; - this->visit_target_symbol(tsym); // NB: throws nothing ... - if (! tsym->saved_conversion_error) // ... but this is how we know it happened. + } + else + { + pf->raw_components += "$return"; + pf->raw_components += "=%#x "; + pf->args.push_back(*(expression**)this->targets.top()); + } + } + else + { + // non-.return probe: support $$parms, $$vars, $$locals + Dwarf_Die result; + if (dwarf_child (&scopes[0], &result) == 0) + do { - pf->raw_components += diename; - pf->raw_components += "=%#x "; - pf->args.push_back(*(expression**)this->targets.top()); + switch (dwarf_tag (&result)) + { + case DW_TAG_variable: + if (e->base_name == "$$parms") + continue; + break; + case DW_TAG_formal_parameter: + if (e->base_name == "$$locals") + continue; + break; + + default: + continue; + } + + const char *diename = dwarf_diename (&result); + tsym->tok = e->tok; + tsym->base_name = "$"; + tsym->base_name += diename; + + // Ignore any variable that isn't accessible. + tsym->saved_conversion_error = 0; + this->visit_target_symbol(tsym); // NB: throws nothing ... + if (tsym->saved_conversion_error) // ... but this is how we know it happened. + { + pf->raw_components += diename; + pf->raw_components += "=? "; + } + else + { + pf->raw_components += diename; + pf->raw_components += "=%#x "; + pf->args.push_back(*(expression**)this->targets.top()); + } } - } - while (dwarf_siblingof (&result, &result) == 0); + while (dwarf_siblingof (&result, &result) == 0); + } pf->components = print_format::string_to_components(pf->raw_components); provide (this, pf); @@ -4366,7 +4401,7 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) try { - if (q.has_return && e->base_name == "$return") + if (q.has_return && (e->base_name == "$return")) { ec->code = q.dw.literal_stmt_for_return (scope_die, addr, diff --git a/testsuite/semok/thirtytwo.stp b/testsuite/semok/thirtytwo.stp new file mode 100755 index 00000000..2a69b8cd --- /dev/null +++ b/testsuite/semok/thirtytwo.stp @@ -0,0 +1,5 @@ +#! stap -p2 + +# PR 6836 + +probe kernel.function("sys_open").return { log($$return . $$parms) } -- cgit From aa15b9f0167dfc87c3bd78e956005b0eacefbc98 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Aug 2008 14:43:03 -0400 Subject: extend callgraph example to use $$parms / $$return --- testsuite/systemtap.examples/ChangeLog | 5 ++++ .../systemtap.examples/general/para-callgraph.meta | 16 ++++-------- .../systemtap.examples/general/para-callgraph.stp | 26 ++++++++++--------- testsuite/systemtap.examples/index.html | 6 ++--- testsuite/systemtap.examples/index.txt | 17 ++++++------ testsuite/systemtap.examples/keyword-index.html | 12 ++++----- testsuite/systemtap.examples/keyword-index.txt | 30 ++++++++++++---------- testsuite/systemtap.examples/subsystem-index.html | 11 +++++--- testsuite/systemtap.examples/subsystem-index.txt | 23 +++++++++-------- 9 files changed, 78 insertions(+), 68 deletions(-) diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 682e44e5..af641ba7 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,8 @@ +2008-08-15 Frank Ch. Eigler + + * general/para-callgraph*: Extend. + * indexes: Regenerated. + 2008-08-11 Mark Wielaard * check.exp: Make sure that stderr gets redircted so warnings don't diff --git a/testsuite/systemtap.examples/general/para-callgraph.meta b/testsuite/systemtap.examples/general/para-callgraph.meta index 3ce4b648..740ed5ce 100644 --- a/testsuite/systemtap.examples/general/para-callgraph.meta +++ b/testsuite/systemtap.examples/general/para-callgraph.meta @@ -1,13 +1,7 @@ -title: Tracing Calls for Sections of Code +title: Callgraph tracing with arguments name: para-callgraph.stp -version: 1.0 -author: anonymous keywords: trace callgraph -subsystem: kernel -status: production -exit: user-controlled -output: trace -scope: system-wide -description: The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name. -test_check: stap -p4 para-callgraph.stp sys_read "*@fs/*.c" -test_installcheck: stap para-callgraph.stp sys_read "*@fs/*.c" -c "sleep 1" +subsystem: general +description: Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger. +test_check: stap -p4 para-callgraph.stp 'kernel.function("*@fs/proc*.c")' 'kernel.function("sys_read")' +test_installcheck: stap para-callgraph.stp 'kernel.function("*@fs/proc*.c")' 'kernel.function("sys_read")' -c 'cat /proc/sys/vm/*' diff --git a/testsuite/systemtap.examples/general/para-callgraph.stp b/testsuite/systemtap.examples/general/para-callgraph.stp index e28f5d6b..9abb00c2 100755 --- a/testsuite/systemtap.examples/general/para-callgraph.stp +++ b/testsuite/systemtap.examples/general/para-callgraph.stp @@ -1,22 +1,24 @@ #! /usr/bin/env stap -function trace(entry_p) { - if(tid() in trace) - printf("%s%s%s\n",thread_indent(entry_p), - (entry_p>0?"->":"<-"), - probefunc()) +function trace(entry_p, extra) { + %( $# > 1 %? if (tid() in trace) %) + printf("%s%s%s %s\n", + thread_indent (entry_p), + (entry_p>0?"->":"<-"), + probefunc (), + extra) } + +%( $# > 1 %? global trace -probe kernel.function(@1).call { - if (execname() == "stapio") next # skip our own helper process +probe $2.call { trace[tid()] = 1 - trace(1) } -probe kernel.function(@1).return { - trace(-1) +probe $2.return { delete trace[tid()] } +%) -probe kernel.function(@2).call { trace(1) } -probe kernel.function(@2).return { trace(-1) } +probe $1.call { trace(1, $$parms) } +probe $1.return { trace(-1, $$return) } diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 327e9ef9..d6b1c99b 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -47,9 +47,9 @@ subsystems: disk cpu, keywords: disk cpu use graph
  • general/helloworld.stp - SystemTap "Hello World" Program
    subsystems: none, keywords: simple

    A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits.

  • -
  • general/para-callgraph.stp - Tracing Calls for Sections of Code
    -subsystems: kernel, keywords: trace callgraph
    -

    The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

  • +
  • general/para-callgraph.stp - Callgraph tracing with arguments
    +subsystems: general, keywords: trace callgraph
    +

    Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.

  • io/disktop.stp - Summarize Disk Read/Write Traffic
    subsystems: disk, keywords: disk

    Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.

  • diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index aed6f457..1372afb0 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -16,14 +16,15 @@ subsystems: none, keywords: simple prints out "hello world" message and then immediately exits. -general/para-callgraph.stp - Tracing Calls for Sections of Code -subsystems: kernel, keywords: trace callgraph - - The script takes two arguments: the first argument is the function to - starts/stops the per thread call graph traces and the second argument - is the list of functions to generate trace information on. The script - prints out a timestap for the thread, the function name and pid, - followed by entry or exit symboly and function name. +general/para-callgraph.stp - Callgraph tracing with arguments +subsystems: general, keywords: trace callgraph + + Print a timed per-thread callgraph, complete with function parameters + and return values. The first parameter names the function probe + points to trace. The optional second parameter names the probe + points for trigger functions, which acts to enable tracing for only + those functions that occur while the current thread is nested within + the trigger. io/disktop.stp - Summarize Disk Read/Write Traffic diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 5d1c79e0..2825bc2e 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -49,9 +49,9 @@ subsystems: io, keywords: io backtrace

    CALLGRAPH

      -
    • general/para-callgraph.stp - Tracing Calls for Sections of Code
      -subsystems: kernel, keywords: trace callgraph
      -

      The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

    • +
    • general/para-callgraph.stp - Callgraph tracing with arguments
      +subsystems: general, keywords: trace callgraph
      +

      Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.

    CPU

      @@ -214,9 +214,9 @@ subsystems: syscall, keywords: syscall read write time io

    TRACE

      -
    • general/para-callgraph.stp - Tracing Calls for Sections of Code
      -subsystems: kernel, keywords: trace callgraph
      -

      The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

    • +
    • general/para-callgraph.stp - Callgraph tracing with arguments
      +subsystems: general, keywords: trace callgraph
      +

      Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.

    TRAFFIC

      diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index d2e20148..22065e76 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -13,14 +13,15 @@ subsystems: io, keywords: io backtrace = CALLGRAPH = -general/para-callgraph.stp - Tracing Calls for Sections of Code -subsystems: kernel, keywords: trace callgraph +general/para-callgraph.stp - Callgraph tracing with arguments +subsystems: general, keywords: trace callgraph - The script takes two arguments: the first argument is the function to - starts/stops the per thread call graph traces and the second argument - is the list of functions to generate trace information on. The script - prints out a timestap for the thread, the function name and pid, - followed by entry or exit symboly and function name. + Print a timed per-thread callgraph, complete with function parameters + and return values. The first parameter names the function probe + points to trace. The optional second parameter names the probe + points for trigger functions, which acts to enable tracing for only + those functions that occur while the current thread is nested within + the trigger. = CPU = @@ -395,14 +396,15 @@ subsystems: syscall, keywords: syscall read write time io = TRACE = -general/para-callgraph.stp - Tracing Calls for Sections of Code -subsystems: kernel, keywords: trace callgraph +general/para-callgraph.stp - Callgraph tracing with arguments +subsystems: general, keywords: trace callgraph - The script takes two arguments: the first argument is the function to - starts/stops the per thread call graph traces and the second argument - is the list of functions to generate trace information on. The script - prints out a timestap for the thread, the function name and pid, - followed by entry or exit symboly and function name. + Print a timed per-thread callgraph, complete with function parameters + and return values. The first parameter names the function probe + points to trace. The optional second parameter names the probe + points for trigger functions, which acts to enable tracing for only + those functions that occur while the current thread is nested within + the trigger. = TRAFFIC = diff --git a/testsuite/systemtap.examples/subsystem-index.html b/testsuite/systemtap.examples/subsystem-index.html index 9bdec0c8..0f2517ce 100644 --- a/testsuite/systemtap.examples/subsystem-index.html +++ b/testsuite/systemtap.examples/subsystem-index.html @@ -40,7 +40,7 @@

    Examples by Subsystem

    -

    CPU DISK IO KERNEL LOCKING NETWORK NONE SCHEDULER SIGNALS SYSCALL

    +

    CPU DISK GENERAL IO KERNEL LOCKING NETWORK NONE SCHEDULER SIGNALS SYSCALL

    CPU

    • general/graphs.stp - Graphing Disk and CPU Utilization
      @@ -56,6 +56,12 @@ subsystems: disk cpu, keywords: disk cpu use graph
      subsystems: disk, keywords: disk

      Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.

    +

    GENERAL

    +
      +
    • general/para-callgraph.stp - Callgraph tracing with arguments
      +subsystems: general, keywords: trace callgraph
      +

      Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.

    • +

    IO

    • io/io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
      @@ -73,9 +79,6 @@ subsystems: io, keywords: io

    KERNEL

      -
    • general/para-callgraph.stp - Tracing Calls for Sections of Code
      -subsystems: kernel, keywords: trace callgraph
      -

      The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name.

    • process/pf2.stp - Profile kernel functions
      subsystems: kernel, keywords: profiling

      The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.

    • diff --git a/testsuite/systemtap.examples/subsystem-index.txt b/testsuite/systemtap.examples/subsystem-index.txt index 98e75e98..d34ac64c 100644 --- a/testsuite/systemtap.examples/subsystem-index.txt +++ b/testsuite/systemtap.examples/subsystem-index.txt @@ -28,6 +28,19 @@ subsystems: disk, keywords: disk ten entries during that period. += GENERAL = + +general/para-callgraph.stp - Callgraph tracing with arguments +subsystems: general, keywords: trace callgraph + + Print a timed per-thread callgraph, complete with function parameters + and return values. The first parameter names the function probe + points to trace. The optional second parameter names the probe + points for trigger functions, which acts to enable tracing for only + those functions that occur while the current thread is nested within + the trigger. + + = IO = io/io_submit.stp - Tally Reschedule Reason During AIO io_submit Call @@ -61,16 +74,6 @@ subsystems: io, keywords: io = KERNEL = -general/para-callgraph.stp - Tracing Calls for Sections of Code -subsystems: kernel, keywords: trace callgraph - - The script takes two arguments: the first argument is the function to - starts/stops the per thread call graph traces and the second argument - is the list of functions to generate trace information on. The script - prints out a timestap for the thread, the function name and pid, - followed by entry or exit symboly and function name. - - process/pf2.stp - Profile kernel functions subsystems: kernel, keywords: profiling -- cgit From fd5747054ac2a5c90d209195c55e6310972f969a Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Aug 2008 14:46:27 -0400 Subject: PR6836: tweak $$return formatting --- ChangeLog | 8 ++++++++ NEWS | 2 +- stapprobes.5.in | 2 +- tapsets.cxx | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac800e8c..3a19ff26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-15 Frank Ch. Eigler + + PR 6836 + * tapsets.cxx (dwarf_var...visit_target_symbol): Emit + "return=0xf00" instead of "$return=0xf00" for $$return, + for consistency with other variables. + * NEWS, stapprobes.5.in: Update. + 2008-08-15 Frank Ch. Eigler PR 6836. diff --git a/NEWS b/NEWS index d6d220a0..ce3954cf 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,7 @@ $$parms, and $$locals context variables, which expand to a string containing a list "var1=0xdead var2=0xbeef var3=?". (Here, var3 exists but is for some reason unavailable.) In return probes only, $$return - expands to an empty string for a void function, or "$return=0xf00". + expands to an empty string for a void function, or "return=0xf00". * What's new in version 0.7 diff --git a/stapprobes.5.in b/stapprobes.5.in index f1626166..a3697d0d 100644 --- a/stapprobes.5.in +++ b/stapprobes.5.in @@ -356,7 +356,7 @@ expands to a subset of $$vars for only function parameters. .TP $$return is available in return probes only. It expands to a string that -is equivalent to sprintf("$return=%x", $return) +is equivalent to sprintf("return=%x", $return) if the probed function has a return value, or else an empty string. .PP For ".return" probes, context variables other than the "$return" diff --git a/tapsets.cxx b/tapsets.cxx index 1f7d2555..f661b7e4 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4333,7 +4333,7 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) } else { - pf->raw_components += "$return"; + pf->raw_components += "return"; pf->raw_components += "=%#x "; pf->args.push_back(*(expression**)this->targets.top()); } -- cgit From 986e98de88e5a55451aaf24a6ead7f44725124c1 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 15 Aug 2008 14:02:31 -0500 Subject: Change system-wide probes from 'process("*").begin' to 'process.begin'. 2008-08-15 David Smith * tapsets.cxx (utrace_builder::build): Change system-wide probes from 'process("*").begin' to 'process.begin'. (register_standard_tapsets): Add new 'process' binding. * stapprobes.5.in: Change system-wide probes from 'process("*").begin' to 'process.begin'. 2008-08-15 David Smith * systemtap.base/utrace_p4.exp: Change system-wide probes from 'process("*").begin' to 'process.begin'. --- ChangeLog | 8 ++++++++ stapprobes.5.in | 11 ++++++++--- tapsets.cxx | 29 ++++++++++++++++++----------- testsuite/ChangeLog | 5 +++++ testsuite/systemtap.base/utrace_p4.exp | 4 ++-- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac800e8c..c9156691 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-15 David Smith + + * tapsets.cxx (utrace_builder::build): Change system-wide probes + from 'process("*").begin' to 'process.begin'. + (register_standard_tapsets): Add new 'process' binding. + * stapprobes.5.in: Change system-wide probes + from 'process("*").begin' to 'process.begin'. + 2008-08-15 Frank Ch. Eigler PR 6836. diff --git a/stapprobes.5.in b/stapprobes.5.in index f1626166..4b2b4e2b 100644 --- a/stapprobes.5.in +++ b/stapprobes.5.in @@ -386,16 +386,22 @@ Additional user-space probing is available in the following forms: .SAMPLE process(PID).begin process("PATH").begin +process.begin process(PID).thread.begin process("PATH").thread.begin +process.thread.begin process(PID).end process("PATH").end +process.end process(PID).thread.end process("PATH").thread.end +process.thread.end process(PID).syscall process("PATH").syscall +process.syscall process(PID).syscall.return process("PATH").syscall.return +process.syscall.return process(PID).itrace process("PATH").itrace .ESAMPLE @@ -431,9 +437,8 @@ Note that names refer to executables that are searched the same way shells do: relative to the working directory if they contain a "/" character, otherwise in .BR $PATH . -A -.I PATH -of "*" means to probe all threads. +If a process probe is specified without a PID or PATH, all user +threads are probed. .SS PROCFS diff --git a/tapsets.cxx b/tapsets.cxx index 1f7d2555..60d9a377 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5945,7 +5945,6 @@ struct utrace_builder: public derived_probe_builder bool has_path = get_param (parameters, TOK_PROCESS, path); bool has_pid = get_param (parameters, TOK_PROCESS, pid); enum utrace_derived_probe_flags flags = UDPF_NONE; - assert (has_path || has_pid); if (has_null_param (parameters, TOK_THREAD)) { @@ -5966,23 +5965,23 @@ struct utrace_builder: public derived_probe_builder else if (has_null_param (parameters, TOK_END)) flags = UDPF_END; + // If we didn't get a path or pid, this means to probe everything. + // Convert this to a pid-based probe. + if (! has_path && ! has_pid) + { + has_path = false; + path.clear(); + has_pid = true; + pid = 0; + } // Validate pid. - if (has_pid) + else if (has_pid) { // We can't probe 'init' (pid 1). if (pid < 2) throw semantic_error ("process pid must be greater than 1", location->tok); } - // If we have a path whose value is "*", this means to probe - // everything. Convert this to a pid-based probe. - else if (has_path && path == "*") - { - has_path = false; - path.clear(); - has_pid = true; - pid = 0; - } // If we have a regular path, we need to validate it. else if (has_path) { @@ -8897,18 +8896,26 @@ register_standard_tapsets(systemtap_session & s) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_BEGIN) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_END) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_END) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_END) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) + ->bind(new utrace_builder ()); // itrace user-space probes s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index c6d86142..9c7f8fec 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-15 David Smith + + * systemtap.base/utrace_p4.exp: Change system-wide probes from + 'process("*").begin' to 'process.begin'. + 2008-08-13 Dave Brolley * lib/systemtap.exp (setup_systemtap_environment): client_path is now diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp index 081fee95..1467d9c8 100644 --- a/testsuite/systemtap.base/utrace_p4.exp +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -15,7 +15,7 @@ set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$sysc set syscall_return_script {"probe process(\"/bin/ls\").syscall.return { printf(\"|%d\", \$syscall) }"} set thread_begin_script {"probe process(\"/bin/ls\").thread.begin { print(\"ls thread.begin\") }"} set thread_end_script {"probe process(\"/bin/ls\").thread.end { print(\"ls thread.end\") }"} -set all_begin_script {"probe process(\"*\").begin { print(\"begin\") }"} +set all_begin_script {"probe process.begin { print(\"begin\") }"} set pid_begin_script {"probe process(123).begin { print(\"123 begin\") }"} set pid_end_script {"probe process(123).end { print(\"123 end\") }"} @@ -134,6 +134,6 @@ set TEST_NAME "UTRACE_P4_07" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" } else { - # Try compiling an begin script using a path of "*" + # Try compiling an system-wide begin script stap_compile $TEST_NAME 1 $all_begin_script } -- cgit From 8d4b1ab0732bd51e4b8f1e7cdb2550a9d67f21bc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 16 Aug 2008 21:20:03 +0200 Subject: Mention distro specific elfutils development sub-packages needed when not found. --- ChangeLog | 5 +++++ config.in | 3 --- configure | 23 ++++++++++++----------- configure.ac | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef5457a4..12786518 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-16 Mark Wielaard + + * configure.ac (build_elfutils): Mention possible distro + specific elfutils development sub-packages needed when not found. + 2008-08-15 David Smith * tapsets.cxx (utrace_builder::build): Change system-wide probes diff --git a/config.in b/config.in index 11232f02..5c1a3894 100644 --- a/config.in +++ b/config.in @@ -18,9 +18,6 @@ /* Define to 1 if you have the `dw' library (-ldw). */ #undef HAVE_LIBDW -/* Define to 1 if you have the `ebl' library (-lebl). */ -#undef HAVE_LIBEBL - /* Define to 1 if you have the `pfm' library (-lpfm). */ #undef HAVE_LIBPFM diff --git a/configure b/configure index be952838..ecf080bf 100755 --- a/configure +++ b/configure @@ -6605,7 +6605,7 @@ fi if test $build_elfutils = no; then - # Need libdwfl-capable recent elfutils from Fedora + # Need libdwfl-capable recent elfutils http://elfutils.fedorahosted.org/ save_LIBS="$LIBS" { echo "$as_me:$LINENO: checking for dwfl_module_getsym in -ldw" >&5 @@ -6678,8 +6678,8 @@ _ACEOF else - { { echo "$as_me:$LINENO: error: missing elfutils development headers/libraries (dw 0.123+)" >&5 -echo "$as_me: error: missing elfutils development headers/libraries (dw 0.123+)" >&2;} + { { echo "$as_me:$LINENO: error: missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)" >&5 +echo "$as_me: error: missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)" >&2;} { (exit 1); exit 1; }; } fi @@ -8455,21 +8455,22 @@ echo "$as_me: $ac_file is unchanged" >&6;} fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. +_am_arg=$ac_file _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $ac_file | $ac_file:* ) + $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || -$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X$ac_file : 'X\(//\)[^/]' \| \ - X$ac_file : 'X\(//\)$' \| \ - X$ac_file : 'X\(/\)' \| . 2>/dev/null || -echo X$ac_file | +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -8506,7 +8507,7 @@ echo "$as_me: executing $ac_file commands" >&6;} # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ diff --git a/configure.ac b/configure.ac index 5a5a0930..084e457c 100644 --- a/configure.ac +++ b/configure.ac @@ -181,10 +181,10 @@ AC_SUBST(elfutils_abs_srcdir, `AS_IF([test $build_elfutils = yes], [cd $with_elfutils && pwd])`) if test $build_elfutils = no; then - # Need libdwfl-capable recent elfutils from Fedora + # Need libdwfl-capable recent elfutils http://elfutils.fedorahosted.org/ save_LIBS="$LIBS" AC_CHECK_LIB(dw, dwfl_module_getsym,[],[ - AC_MSG_ERROR([missing elfutils development headers/libraries (dw 0.123+) (libebl-devel may need to be installed)])], + AC_MSG_ERROR([missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)])], [-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf]) stap_LIBS="-Wl,--start-group -ldw -lebl -Wl,--end-group -lelf" LIBS="$save_LIBS" -- cgit From 480f38d3275c87ac5b58a95dd127633babfc7374 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 18 Aug 2008 15:54:39 -0500 Subject: Add missing 'process' bindings. 2008-08-18 David Smith * tapsets.cxx (register_standard_tapsets): Add missing 'process.syscall' and 'process.syscall.return' bindings. --- ChangeLog | 5 +++++ tapsets.cxx | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 12786518..477f7d1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-18 David Smith + + * tapsets.cxx (register_standard_tapsets): Add missing + 'process.syscall' and 'process.syscall.return' bindings. + 2008-08-16 Mark Wielaard * configure.ac (build_elfutils): Mention possible distro diff --git a/tapsets.cxx b/tapsets.cxx index 9dcb4290..39fc0074 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -8916,21 +8916,24 @@ register_standard_tapsets(systemtap_session & s) ->bind(new utrace_builder ()); s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); - - // itrace user-space probes - s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") - ->bind(new itrace_builder ()); - s.pattern_root->bind_num(TOK_PROCESS)->bind("itrace") - ->bind(new itrace_builder ()); - s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_SYSCALL) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_SYSCALL) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_SYSCALL) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) + ->bind(new utrace_builder ()); + + // itrace user-space probes + s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") + ->bind(new itrace_builder ()); + s.pattern_root->bind_num(TOK_PROCESS)->bind("itrace") + ->bind(new itrace_builder ()); // marker-based parts s.pattern_root->bind(TOK_KERNEL)->bind_str(TOK_MARK) -- cgit From 930a1798154b9c1caf27009825b2b165ef577a1e Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 19 Aug 2008 12:12:06 -0500 Subject: PR 6841 fix. 2008-08-19 David Smith PR 6841 * tapsets.cxx (utrace_derived_probe_group::emit_probe_decl): Workaround utrace bug by quiescing threads before attaching a utrace syscall engine to them. (utrace_derived_probe_group::emit_module_decls): Emit quiesce handler. 2008-08-19 David Smith PR 6841 * task_finder.c (__stp_utrace_task_finder_target_quiesce): Quiesces thread before turning on syscall tracing. --- ChangeLog | 9 +++++++++ runtime/ChangeLog | 6 ++++++ runtime/task_finder.c | 4 ++-- tapsets.cxx | 30 +++++++++++++++++++++++++----- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 477f7d1e..6b4ffe32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-08-19 David Smith + + PR 6841 + * tapsets.cxx (utrace_derived_probe_group::emit_probe_decl): + Workaround utrace bug by quiescing threads before attaching a + utrace syscall engine to them. + (utrace_derived_probe_group::emit_module_decls): Emit quiesce + handler. + 2008-08-18 David Smith * tapsets.cxx (register_standard_tapsets): Add missing diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 58678de5..796f812c 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,9 @@ +2008-08-19 David Smith + + PR 6841 + * task_finder.c (__stp_utrace_task_finder_target_quiesce): + Quiesces thread before turning on syscall tracing. + 2008-08-14 Frank Ch. Eigler PR 6842. diff --git a/runtime/task_finder.c b/runtime/task_finder.c index 928b7087..d7450a41 100644 --- a/runtime/task_finder.c +++ b/runtime/task_finder.c @@ -317,7 +317,7 @@ __stp_get_mm_path(struct mm_struct *mm, char *buf, int buflen) | UTRACE_EVENT(SYSCALL_ENTRY) \ | UTRACE_EVENT(SYSCALL_EXIT)) -#define __STP_ATTACHED_TASK_VM_EVENTS (__STP_ATTACHED_TASK_VM_BASE_EVENTS \ +#define __STP_ATTACHED_TASK_VM_EVENTS (__STP_ATTACHED_TASK_BASE_EVENTS \ | UTRACE_ACTION_QUIESCE \ | UTRACE_EVENT(QUIESCE)) @@ -608,7 +608,7 @@ __stp_utrace_task_finder_target_quiesce(struct utrace_attached_engine *engine, { struct stap_task_finder_target *tgt = engine->data; - // Turn off quiesce handling. + // Turn off quiesce handling (and turn on syscall handling). utrace_set_flags(tsk, engine, __STP_ATTACHED_TASK_VM_BASE_EVENTS); if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) { diff --git a/tapsets.cxx b/tapsets.cxx index 39fc0074..36601b01 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6096,17 +6096,19 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, // For UDPF_SYSCALL/UDPF_SYSCALL_RETURN probes, the .report_death // handler isn't strictly necessary. However, it helps to keep - // our attaches/detaches symmetrical. + // our attaches/detaches symmetrical. Notice we're using quiesce + // as a workaround for bug 6841. case UDPF_SYSCALL: s.op->line() << " .flags=(UDPF_SYSCALL),"; - s.op->line() << " .ops={ .report_syscall_entry=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death },"; - s.op->line() << " .events=(UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .ops={ .report_syscall_entry=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; + s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; case UDPF_SYSCALL_RETURN: s.op->line() << " .flags=(UDPF_SYSCALL_RETURN),"; - s.op->line() << " .ops={ .report_syscall_exit=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death },"; - s.op->line() << " .events=(UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .ops={ .report_syscall_exit=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; + s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; + case UDPF_NONE: s.op->line() << " .flags=(UDPF_NONE),"; s.op->line() << " .ops={ },"; @@ -6228,6 +6230,24 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output handler function for SYSCALL_ENTRY and SYSCALL_EXIT events if (flags_seen[UDPF_SYSCALL] || flags_seen[UDPF_SYSCALL_RETURN]) { + s.op->newline() << "static u32 stap_utrace_probe_syscall_quiesce(struct utrace_attached_engine *engine, struct task_struct *tsk) {"; + s.op->indent(1); + s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; + + // Turn off quiesce handling and turn on either syscall entry + // or exit events. + s.op->newline() << "if (p->flags == UDPF_SYSCALL)"; + s.op->indent(1); + s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH));"; + s.op->indent(-1); + s.op->newline() << "else if (p->flags == UDPF_SYSCALL_RETURN)"; + s.op->indent(1); + s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH));"; + s.op->indent(-1); + + s.op->newline() << "return (UTRACE_ACTION_NEWSTATE | UTRACE_ACTION_RESUME);"; + s.op->newline(-1) << "}"; + s.op->newline() << "static u32 stap_utrace_probe_syscall(struct utrace_attached_engine *engine, struct task_struct *tsk, struct pt_regs *regs) {"; s.op->indent(1); s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; -- cgit From ef4042bd5adb8062c31789a9786bf558f5f11e9e Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 20 Aug 2008 12:33:13 -0500 Subject: Looks for both mmap and mmap2. 2008-08-20 David Smith * task_finder.c (__stp_utrace_task_finder_target_syscall_entry): Handles mmap2 (as well as mmap). (__stp_utrace_task_finder_target_syscall_exit): Ditto. * syscall.h: Added defines for mmap and mmap2. --- runtime/ChangeLog | 7 +++++++ runtime/syscall.h | 22 +++++++++++++++++----- runtime/task_finder.c | 11 +++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 796f812c..6dfd2ea2 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2008-08-20 David Smith + + * task_finder.c (__stp_utrace_task_finder_target_syscall_entry): + Handles mmap2 (as well as mmap). + (__stp_utrace_task_finder_target_syscall_exit): Ditto. + * syscall.h: Added defines for mmap and mmap2. + 2008-08-19 David Smith PR 6841 diff --git a/runtime/syscall.h b/runtime/syscall.h index 3d1034e6..24e93463 100644 --- a/runtime/syscall.h +++ b/runtime/syscall.h @@ -11,12 +11,14 @@ #define _SYSCALL_H_ #if defined(__i386__) || defined(CONFIG_IA32_EMULATION) -#define __MMAP_SYSCALL_NO_IA32 192 /* mmap2 */ +#define __MMAP_SYSCALL_NO_IA32 90 +#define __MMAP2_SYSCALL_NO_IA32 192 #define __MPROTECT_SYSCALL_NO_IA32 125 #define __MUNMAP_SYSCALL_NO_IA32 91 #define __MREMAP_SYSCALL_NO_IA32 163 # if !defined(CONFIG_IA32_EMULATION) #define MMAP_SYSCALL_NO(tsk) __MMAP_SYSCALL_NO_IA32 +#define MMAP2_SYSCALL_NO(tsk) __MMAP2_SYSCALL_NO_IA32 #define MPROTECT_SYSCALL_NO(tsk) __MPROTECT_SYSCALL_NO_IA32 #define MUNMAP_SYSCALL_NO(tsk) __MUNMAP_SYSCALL_NO_IA32 #define MREMAP_SYSCALL_NO(tsk) __MREMAP_SYSCALL_NO_IA32 @@ -25,13 +27,19 @@ #if defined(__x86_64__) #define __MMAP_SYSCALL_NO_X86_64 9 +/* x86_64 doesn't have a mmap2 system call. So, we'll use a number + * that doesn't map to a real system call. */ +#define __MMAP2_SYSCALL_NO_X86_64 ((unsigned long)-1) #define __MPROTECT_SYSCALL_NO_X86_64 10 #define __MUNMAP_SYSCALL_NO_X86_64 11 #define __MREMAP_SYSCALL_NO_X86_64 25 # if defined(CONFIG_IA32_EMULATION) -#define MMAP_SYSCALL_NO(tsk) ((test_tsk_thread_flag((tsk), TIF_IA32)) \ - ? __MMAP_SYSCALL_NO_IA32 \ +#define MMAP_SYSCALL_NO(tsk) ((test_tsk_thread_flag((tsk), TIF_IA32)) \ + ? __MMAP_SYSCALL_NO_IA32 \ : __MMAP_SYSCALL_NO_X86_64) +#define MMAP2_SYSCALL_NO(tsk) ((test_tsk_thread_flag((tsk), TIF_IA32)) \ + ? __MMAP2_SYSCALL_NO_IA32 \ + : __MMAP2_SYSCALL_NO_X86_64) #define MPROTECT_SYSCALL_NO(tsk) ((test_tsk_thread_flag((tsk), TIF_IA32)) \ ? __MPROTECT_SYSCALL_NO_IA32 \ : __MPROTECT_SYSCALL_NO_X86_64) @@ -51,13 +59,17 @@ #if defined(__powerpc__) #define MMAP_SYSCALL_NO(tsk) 90 +/* MMAP2 only exists on a 32-bit kernel. On a 64-bit kernel, we'll + * never see mmap2 (but that's OK). */ +#define MMAP2_SYSCALL_NO(tsk) 192 #define MPROTECT_SYSCALL_NO(tsk) 125 #define MUNMAP_SYSCALL_NO(tsk) 91 #define MREMAP_SYSCALL_NO(tsk) 163 #endif -#if !defined(MMAP_SYSCALL_NO) || !defined(MPROTECT_SYSCALL_NO) \ - || !defined(MUNMAP_SYSCALL_NO) || !defined(MREMAP_SYSCALL_NO) +#if !defined(MMAP_SYSCALL_NO) || !defined(MMAP2_SYSCALL_NO) \ + || !defined(MPROTECT_SYSCALL_NO) || !defined(MUNMAP_SYSCALL_NO) \ + || !defined(MREMAP_SYSCALL_NO) #error "Unimplemented architecture" #endif diff --git a/runtime/task_finder.c b/runtime/task_finder.c index d7450a41..b483cf23 100644 --- a/runtime/task_finder.c +++ b/runtime/task_finder.c @@ -717,6 +717,7 @@ __stp_utrace_task_finder_target_syscall_entry(struct utrace_attached_engine *eng // FIXME: do we need to handle mremap()? syscall_no = __stp_user_syscall_nr(regs); if (syscall_no != MMAP_SYSCALL_NO(tsk) + && syscall_no != MMAP2_SYSCALL_NO(tsk) && syscall_no != MPROTECT_SYSCALL_NO(tsk) && syscall_no != MUNMAP_SYSCALL_NO(tsk)) return UTRACE_ACTION_RESUME; @@ -815,6 +816,7 @@ __stp_utrace_task_finder_target_syscall_exit(struct utrace_attached_engine *engi // FIXME: do we need to handle mremap()? syscall_no = __stp_user_syscall_nr(regs); if (syscall_no != MMAP_SYSCALL_NO(tsk) + && syscall_no != MMAP2_SYSCALL_NO(tsk) && syscall_no != MPROTECT_SYSCALL_NO(tsk) && syscall_no != MUNMAP_SYSCALL_NO(tsk)) return UTRACE_ACTION_RESUME; @@ -841,10 +843,11 @@ __stp_utrace_task_finder_target_syscall_exit(struct utrace_attached_engine *engi "tsk %d found %s(0x%lx), returned 0x%lx\n", tsk->pid, ((syscall_no == MMAP_SYSCALL_NO(tsk)) ? "mmap" - : ((syscall_no == MPROTECT_SYSCALL_NO(tsk)) ? "mprotect" - : ((syscall_no == MUNMAP_SYSCALL_NO(tsk)) ? "munmap" - : "UNKNOWN"))), - arg0, rv); + : ((syscall_no == MMAP2_SYSCALL_NO(tsk)) ? "mmap2" + : ((syscall_no == MPROTECT_SYSCALL_NO(tsk)) ? "mprotect" + : ((syscall_no == MUNMAP_SYSCALL_NO(tsk)) ? "munmap" + : "UNKNOWN"))), + arg0, rv); #endif // Try to find the vma info we might have saved. -- cgit