]> sourceware.org Git - systemtap.git/commitdiff
Be more explicit about when the session needs symbol data. pragma:symbols.
authorMark Wielaard <mjw@redhat.com>
Thu, 11 Aug 2011 16:53:01 +0000 (18:53 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 11 Aug 2011 16:53:01 +0000 (18:53 +0200)
Introduce /* pragma:symbols */ which is added to those tapset functions
that use print_addr or print_stack with symbol resolving. Now we no longer
have to output the symbol tables at translate time if unnecessary.
Although we could do even less work (see the new comment in translate.cxx).

elaborate.cxx
session.cxx
session.h
tapset/context-symbols.stp
tapset/context-unwind.stp
tapset/ucontext-symbols.stp
tapset/ucontext-unwind.stp
translate.cxx

index d137cc5c18c857f39a484f75169d9d7b190607cb..486c508ff32b4fbce8f16914262cd2042199444e 100644 (file)
@@ -1201,8 +1201,8 @@ semantic_pass_conditions (systemtap_session & sess)
 // necessary initialization of code needed by the embedded code functions.
 
 // This is only for pragmas that don't have any other side-effect than
-// needing some initialization at module init time. Currently only handles
-// /* pragma:vma */ and /* pragma:unwind */.
+// needing some initialization at module init time. Currently handles
+// /* pragma:vma */ /* pragma:unwind */ /* pragma:symbol */
 
 // /* pragma:uprobes */ is handled during the typeresolution_info pass.
 // /* pure */, /* unprivileged */. /* myproc-unprivileged */ and /* guru */
@@ -1233,8 +1233,17 @@ public:
        if (session.verbose > 2)
          clog << _F("Turning on unwind support, pragma:unwind found in %s",
                    current_function->name.c_str()) << endl;
-      session.need_unwind = true;
-    }
+       session.need_unwind = true;
+      }
+
+    if (! session.need_symbols
+       && c->code.find("/* pragma:symbols */") != string::npos)
+      {
+       if (session.verbose > 2)
+         clog << _F("Turning on symbol data collecting, pragma:symbols found in %s",
+                   current_function->name.c_str()) << endl;
+       session.need_symbols = true;
+      }
   }
 };
 
index b54ea386635abde4f07c119feccfa5951a61e8df..b875f30df52447482c8eda8aba0beaeffc6ee48f 100644 (file)
@@ -124,6 +124,7 @@ systemtap_session::systemtap_session ():
   tapset_compile_coverage = false;
   need_uprobes = false;
   need_unwind = false;
+  need_symbols = false;
   uprobes_path = "";
   consult_symtab = false;
   ignore_vmlinux = false;
@@ -284,6 +285,7 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   tapset_compile_coverage = other.tapset_compile_coverage;
   need_uprobes = false;
   need_unwind = false;
+  need_symbols = false;
   uprobes_path = "";
   consult_symtab = other.consult_symtab;
   ignore_vmlinux = other.ignore_vmlinux;
index 9845d4c50da0c44ee9e3f9f3b019ca4cd430f9ec..30db53ee257649552e72237fdc887ed5f13ce69e 100644 (file)
--- a/session.h
+++ b/session.h
@@ -170,6 +170,7 @@ public:
   bool tapset_compile_coverage;
   bool need_uprobes;
   bool need_unwind;
+  bool need_symbols;
   std::string uprobes_path;
   std::string uprobes_hash;
   bool load_only; // flight recorder mode
index e20cf3ed1cb01c74b5182b033d675661663307ef..64401f69f2890d4873507e4336934797ac536c42 100644 (file)
@@ -1,5 +1,5 @@
 // context-symbols tapset
-// Copyright (C) 2005-2008 Red Hat Inc.
+// Copyright (C) 2005-2008, 2011 Red Hat Inc.
 // Copyright (C) 2006 Intel Corporation.
 //
 // This file is part of systemtap, and is free software.  You can
 //provide information such as a backtrace to where the event occurred and the current register values for the 
 //processor.
 // </tapsetdescription>
-%{
-#ifndef STP_NEED_SYMBOL_DATA
-#define STP_NEED_SYMBOL_DATA 1
-#endif
-%}
 
 /**
  *  sfunction print_stack - Print out kernel stack from string
@@ -30,7 +25,7 @@
  *  name  of the function containing the address, and an estimate of
  *  its position within that function.  Return nothing.
  */
-function print_stack(stk:string) %{
+function print_stack(stk:string) %{ /* pragma:symbols */
        char *ptr = THIS->stk;
        char *tok = strsep(&ptr, " ");
        while (tok && *tok) {
@@ -57,7 +52,7 @@ function print_stack(stk:string) %{
  * truncated to MAXSTRINGLEN, to print fuller and richer stacks use
  * print_stack.
  */
-function sprint_stack:string(stk:string) %{ /* pure */
+function sprint_stack:string(stk:string) %{ /* pure */ /* pragma:symbols */
        char *ptr = THIS->stk;
        char *tok = strsep(&ptr, " ");
        char *str = THIS->__retvalue;
@@ -87,7 +82,7 @@ function sprint_stack:string(stk:string) %{ /* pure */
  * usymname(). This function might return a function name based on the
  * current address if the probe point context couldn't be parsed.
  */
-function probefunc:string () %{ /* pure */
+function probefunc:string () %{ /* pure */ /* pragma:symbols */
        char *ptr, *start;
 
        start = strstr(CONTEXT->probe_point, "function(\"");
@@ -173,7 +168,7 @@ function modname:string (addr: long) %{ /* pure */
  * given address if known. If not known it will return the hex string
  * representation of addr.
  */
-function symname:string (addr: long) %{ /* pure */
+function symname:string (addr: long) %{ /* pure */ /* pragma:symbols */
         _stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
                           _STP_SYM_SYMBOL, NULL);
 %}
@@ -190,7 +185,7 @@ function symname:string (addr: long) %{ /* pure */
  * omitted and if the symbol name is unknown it will return the hex
  * string for the given address.
  */
-function symdata:string (addr: long) %{ /* pure */
+function symdata:string (addr: long) %{ /* pure */ /* pragma:symbols */
        _stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
                          _STP_SYM_DATA, NULL);
 %}
index fb25555adf59e8cf317ac54fe70c2f564cfa0f15..441f0c0b095467025eb02e1b6ec45506acdc38d5 100644 (file)
 //provide information such as a backtrace to where the event occurred and the current register values for the 
 //processor.
 // </tapsetdescription>
-%{
-#ifndef STP_NEED_SYMBOL_DATA
-#define STP_NEED_SYMBOL_DATA 1
-#endif
-%}
 
 /**
  *  sfunction print_backtrace - Print stack back trace
@@ -24,7 +19,8 @@
  *  except that deeper stack nesting may be supported.
  *  The function does not return a value.
  */
-function print_backtrace () %{ /* pragma:unwind */
+function print_backtrace () %{
+       /* pragma:unwind */ /* pragma:symbols */
        _stp_stack_print(CONTEXT, _STP_SYM_FULL, _STP_STACK_KERNEL);
 %}
 
@@ -43,7 +39,8 @@ function print_backtrace () %{ /* pragma:unwind */
  * but more efficient (no need to translate between hex strings and
  * final backtrace string).
  */
-function sprint_backtrace:string () %{ /* pure */ /* pragma:unwind */
+function sprint_backtrace:string () %{
+       /* pure */ /* pragma:unwind */ /* pragma:symbols */
        _stp_stack_sprint (THIS->__retvalue, MAXSTRINGLEN,
                           CONTEXT, _STP_SYM_SIMPLE, _STP_STACK_KERNEL);
 %}
index fe3d442b71636f4bb52f10ac28187f8ef326987f..4d9acc6a618c8a49e14477b53f253bafd87e6518 100644 (file)
 // the function symbol of an address.
 // </tapsetdescription>
 
-%{
-#ifndef STP_NEED_SYMBOL_DATA
-#define STP_NEED_SYMBOL_DATA 1
-#endif
-%}
-
 /**
  * sfunction usymname - Return the symbol of an address in the current task. EXPERIMENTAL!
  * @addr: The address to translate.
@@ -28,7 +22,7 @@
  * representation of addr.
  */
 function usymname:string (addr: long) %{
-/* pure */ /* myproc-unprivileged */ /* pragma:vma */
+/* pure */ /* myproc-unprivileged */ /* pragma:vma */ /* pragma:symbols */
         _stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
                           _STP_SYM_SYMBOL, current);
 %}
@@ -46,7 +40,7 @@ function usymname:string (addr: long) %{
  * unknown it will return the hex string for the given address.
  */
 function usymdata:string (addr: long) %{
-/* pure */ /* myproc-unprivileged */ /* pragma:vma */
+/* pure */ /* myproc-unprivileged */ /* pragma:vma */ /* pragma:symbols */
         _stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
                           _STP_SYM_DATA, current);
 %}
@@ -64,7 +58,7 @@ function usymdata:string (addr: long) %{
  *  its position within that function.  Return nothing.
  */
 function print_ustack(stk:string) %{
-/* myproc-unprivileged */ /* pragma:vma */
+/* myproc-unprivileged */ /* pragma:vma */ /* pragma:symbols */
         char *ptr = THIS->stk;
         char *tok = strsep(&ptr, " ");
         while (tok && *tok) {
@@ -92,7 +86,7 @@ function print_ustack(stk:string) %{
  * truncated to MAXSTRINGLEN, to print fuller and richer stacks use
  * print_ustack.
  */
-function sprint_ustack:string(stk:string) %{ /* pure */
+function sprint_ustack:string(stk:string) %{ /* pure */ /* pragma:symbols */
        char *ptr = THIS->stk;
        char *tok = strsep(&ptr, " ");
        char *str = THIS->__retvalue;
index 99178c547bc411d55189b34555ffaa4630d6f2e1..f85ab940af9d3703b7cd2625010b57c2c338c749 100644 (file)
@@ -6,12 +6,6 @@
 // Public License (GPL); either version 2, or (at your option) any
 // later version.
 
-%{
-#ifndef STP_NEED_SYMBOL_DATA
-#define STP_NEED_SYMBOL_DATA 1
-#endif
-%}
-
 /**
  * sfunction print_ubacktrace - Print stack back trace for current task. EXPERIMENTAL!
  *
@@ -22,7 +16,7 @@
  * shared libraries not mentioned in the current script run stap with
  * -d /path/to/exe-or-so and/or add --ldd to load all needed unwind data.
  */
-function print_ubacktrace () %{ /* pragma:unwind */
+function print_ubacktrace () %{ /* pragma:unwind */ /* pragma:symbols */
 /* myproc-unprivileged */ /* pragma:uprobes */ /* pragma:vma */
     _stp_stack_print(CONTEXT, _STP_SYM_FULL, _STP_STACK_USER);
 %}
@@ -46,7 +40,7 @@ function print_ubacktrace () %{ /* pragma:unwind */
  * shared libraries not mentioned in the current script run stap with
  * -d /path/to/exe-or-so and/or add --ldd to load all needed unwind data.
  */
-function sprint_ubacktrace:string () %{ /* pragma:unwind */
+function sprint_ubacktrace:string () %{ /* pragma:unwind */ /* pragma:symbols */
 /* pure */ /* myproc-unprivileged */ /* pragma:uprobes */ /* pragma:vma */
     _stp_stack_sprint (THIS->__retvalue, MAXSTRINGLEN, CONTEXT,
                        _STP_SYM_SIMPLE, _STP_STACK_USER);
@@ -63,7 +57,7 @@ function sprint_ubacktrace:string () %{ /* pragma:unwind */
  * shared libraries not mentioned in the current script run stap with
  * -d /path/to/exe-or-so and/or add --ldd to load all needed unwind data.
  */
-function print_ubacktrace_brief () %{ /* pragma:unwind */
+function print_ubacktrace_brief () %{ /* pragma:unwind */ /* pragma:symbols */
 /* myproc-unprivileged */ /* pragma:uprobes */ /* pragma:vma */
     _stp_stack_print(CONTEXT, _STP_SYM_BRIEF, _STP_STACK_USER);
 %}
index 85c697c53dde3023851108915c0ea405b2b690fd..f06b72b88ddac0d08b06c28cd3d2f53daee165e3 100644 (file)
@@ -5075,7 +5075,11 @@ dump_unwindsyms (Dwfl_Module *m,
                   seclist.push_back (make_pair(secname,size));
                }
 
-              (addrmap[secidx])[sym_addr] = name;
+              // If we don't actually need the symbols then we did all
+              // of the above just to get the section names... we can
+              // probably do that in some more efficient way...
+              if (c->session.need_symbols)
+                (addrmap[secidx])[sym_addr] = name;
             }
         }
     }
@@ -5193,19 +5197,22 @@ dump_unwindsyms (Dwfl_Module *m,
                 << "_stp_module_" << stpmod_idx<< "_symbols_" << secidx << "[] = {\n";
 
       // Only include symbols if they will be used
-      c->output << "#ifdef STP_NEED_SYMBOL_DATA\n";
-
-      // We write out a *sorted* symbol table, so the runtime doesn't have to sort them later.
-      for (addrmap_t::iterator it = addrmap[secidx].begin(); it != addrmap[secidx].end(); it++)
-        {
-          if (it->first < extra_offset)
-            continue; // skip symbols that occur before our chosen base address
+      if (c->session.need_symbols)
+       {
 
-          c->output << "  { 0x" << hex << it->first-extra_offset << dec
-                    << ", " << lex_cast_qstring (it->second) << " },\n";
-        }
+         // We write out a *sorted* symbol table, so the runtime doesn't
+         // have to sort them later.
+         for (addrmap_t::iterator it = addrmap[secidx].begin();
+              it != addrmap[secidx].end(); it++)
+           {
+             // skip symbols that occur before our chosen base address
+             if (it->first < extra_offset)
+               continue;
 
-      c->output << "#endif /* STP_NEED_SYMBOL_DATA */\n";
+             c->output << "  { 0x" << hex << it->first-extra_offset << dec
+                       << ", " << lex_cast_qstring (it->second) << " },\n";
+           }
+       }
 
       c->output << "};\n";
 
This page took 0.05107 seconds and 5 git commands to generate.