summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--tapset/context-symbols.stp95
-rw-r--r--tapset/context-unwind.stp71
-rw-r--r--tapset/context.stp136
-rw-r--r--translate.cxx10
5 files changed, 185 insertions, 138 deletions
diff --git a/ChangeLog b/ChangeLog
index 3874d620..eb256fd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-28 Elliott Baron <ebaron@redhat.com>
+
+ PR 6965.
+ * translate.cxx (dump_unwindsyms): Output #ifdef for
+ symbol table.
+ * tapsets/context.stp: moved functions requiring symbols
+ to tapsets/context-symbols.stp and those requiring both
+ symbols and unwinder to tapsets/context-unwind.stp.
+ * tapsets/context-symbols.h: New file.
+ * tapsets/context-unwind.h: New file.
+
2008-11-28 Frank Ch. Eigler <fche@elastic.org>
PR 5376.
diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp
new file mode 100644
index 00000000..eb5a5014
--- /dev/null
+++ b/tapset/context-symbols.stp
@@ -0,0 +1,95 @@
+// context-symbols tapset
+// Copyright (C) 2005, 2006, 2007 Red Hat Inc.
+// Copyright (C) 2006 Intel Corporation.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+%{
+#ifndef NEED_SYMBOL_DATA
+#define NEED_SYMBOL_DATA 1
+#endif
+%}
+
+/**
+ * sfunction print_stack - Print out stack from string
+ * @stk: String with list of hexidecimal addresses. (FIXME)
+ *
+ * Perform a symbolic lookup of the addresses in the given string,
+ * which is assumed to be the result of a prior call to
+ * backtrace().
+ * Print one line per address, including the address, the
+ * name of the function containing the address, and an estimate of
+ * its position within that function. Return nothing.
+ */
+function print_stack(stk:string) %{
+ char *ptr = THIS->stk;
+ char *tok = strsep(&ptr, " ");
+ while (tok && *tok) {
+ _stp_print_char(' ');
+ _stp_symbol_print (simple_strtol(tok, NULL, 16));
+ _stp_print_char('\n');
+ tok = strsep(&ptr, " ");
+ }
+%}
+
+/**
+ * sfunction probefunc - Function probed
+ *
+ * Return the probe point's function name, if known.
+ */
+function probefunc:string () %{ /* pure */
+ char *ptr, *start;
+
+ start = strstr(CONTEXT->probe_point, "function(\"");
+ ptr = start + 10;
+ if (!start) {
+ start = strstr(CONTEXT->probe_point, "inline(\"");
+ ptr = start + 8;
+ }
+
+ if (start) {
+ int len = MAXSTRINGLEN;
+ char *dst = THIS->__retvalue;
+ while (*ptr != '@' && --len > 0 && *ptr)
+ *dst++ = *ptr++;
+ *dst = 0;
+
+ } else if (CONTEXT->regs &&
+#if defined (__ia64__)
+ ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)KERNEL_START)) {
+#else
+ ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)PAGE_OFFSET)) {
+#endif
+ _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs));
+ if (THIS->__retvalue[0] == '.') /* powerpc symbol has a dot*/
+ strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN);
+ } else {
+ THIS->__retvalue[0] = '\0';
+ }
+%}
+
+/**
+ * sfunction probemod - Module probed
+ *
+ * Return the probe point's module name, if known.
+ */
+function probemod:string () %{ /* pure */
+ char *ptr, *start;
+
+ start = strstr(CONTEXT->probe_point, "module(\"");
+ ptr = start + 8;
+
+ if (start) {
+ int len = MAXSTRINGLEN;
+ char *dst = THIS->__retvalue;
+ while (*ptr != '"' && --len && *ptr)
+ *dst++ = *ptr++;
+ *dst = 0;
+ } else {
+ /* XXX: need a PC- and symbol-table-based fallback. */
+ THIS->__retvalue[0] = '\0';
+ }
+%}
diff --git a/tapset/context-unwind.stp b/tapset/context-unwind.stp
new file mode 100644
index 00000000..c53de8f0
--- /dev/null
+++ b/tapset/context-unwind.stp
@@ -0,0 +1,71 @@
+// context-unwind tapset
+// Copyright (C) 2005, 2006, 2007 Red Hat Inc.
+// Copyright (C) 2006 Intel Corporation.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+%{
+#ifndef STP_USE_DWARF_UNWINDER
+#define STP_USE_DWARF_UNWINDER 1
+#endif
+#ifndef NEED_SYMBOL_DATA
+#define NEED_SYMBOL_DATA 1
+#endif
+%}
+
+/**
+ * sfunction print_backtrace - Print stack back trace
+ *
+ * Equivalent to <command>print_stack(backtrace())</command>,
+ * except that deeper stack nesting may be supported. Return nothing.
+ */
+function print_backtrace () %{
+ if (CONTEXT->regs) {
+ _stp_stack_print(CONTEXT->regs, 1, CONTEXT->pi, MAXTRACE);
+ } else {
+ _stp_printf("Systemtap probe: %s\n", CONTEXT->probe_point);
+ }
+%}
+
+/**
+ * sfunction backtrace - Hex backtrace of current stack
+ *
+ * Return a string of hex addresses that are a backtrace of the
+ * stack. It may be truncated due to maximum string length.
+ */
+function backtrace:string () %{ /* pure */
+ if (CONTEXT->regs)
+ _stp_stack_snprint (THIS->__retvalue, MAXSTRINGLEN, CONTEXT->regs, 0, CONTEXT->pi, MAXTRACE);
+ else
+ strlcpy (THIS->__retvalue, "", MAXSTRINGLEN);
+%}
+
+/**
+ * sfunction caller - Return name and address of calling function
+ *
+ * Return the address and name of the calling function.
+ * <emphasis>Works only for return probes at this time.</emphasis>
+ */
+function caller:string() %{ /* pure */
+ if (CONTEXT->pi)
+ _stp_symbol_snprint( THIS->__retvalue, MAXSTRINGLEN,
+ (unsigned long)_stp_ret_addr_r(CONTEXT->pi));
+ else
+ strlcpy(THIS->__retvalue,"unknown",MAXSTRINGLEN);
+%}
+
+/**
+ * sfunction caller_addr - Return caller address
+ *
+ * Return the address of the calling function.
+ * <emphasis> Works only for return probes at this time.</emphasis>
+ */
+function caller_addr:long () %{ /* pure */
+ if (CONTEXT->pi)
+ THIS->__retvalue = (int64_t)(long)_stp_ret_addr_r(CONTEXT->pi);
+ else
+ THIS->__retvalue = 0;
+%} \ No newline at end of file
diff --git a/tapset/context.stp b/tapset/context.stp
index 7505c607..c737edd0 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -7,7 +7,6 @@
// Public License (GPL); either version 2, or (at your option) any
// later version.
-
/**
* sfunction print_regs - Print a register dump.
*/
@@ -18,33 +17,6 @@ function print_regs () %{
%}
/**
- * sfunction print_backtrace - Print stack back trace
- *
- * Equivalent to <command>print_stack(backtrace())</command>,
- * except that deeper stack nesting may be supported. Return nothing.
- */
-function print_backtrace () %{
- if (CONTEXT->regs) {
- _stp_stack_print(CONTEXT->regs, 1, CONTEXT->pi, MAXTRACE);
- } else {
- _stp_printf("Systemtap probe: %s\n", CONTEXT->probe_point);
- }
-%}
-
-/**
- * sfunction backtrace - Hex backtrace of current stack
- *
- * Return a string of hex addresses that are a backtrace of the
- * stack. It may be truncated due to maximum string length.
- */
-function backtrace:string () %{ /* pure */
- if (CONTEXT->regs)
- _stp_stack_snprint (THIS->__retvalue, MAXSTRINGLEN, CONTEXT->regs, 0, CONTEXT->pi, MAXTRACE);
- else
- strlcpy (THIS->__retvalue, "", MAXSTRINGLEN);
-%}
-
-/**
* sfunction execname - Execname of current processes
*
* Return the name of the current process.
@@ -149,28 +121,6 @@ function cpu:long () %{ /* pure */
%}
/**
- * sfunction print_stack - Print out stack from string
- * @stk: String with list of hexidecimal addresses. (FIXME)
- *
- * Perform a symbolic lookup of the addresses in the given string,
- * which is assumed to be the result of a prior call to
- * backtrace().
- * Print one line per address, including the address, the
- * name of the function containing the address, and an estimate of
- * its position within that function. Return nothing.
- */
-function print_stack(stk:string) %{
- char *ptr = THIS->stk;
- char *tok = strsep(&ptr, " ");
- while (tok && *tok) {
- _stp_print_char(' ');
- _stp_symbol_print (simple_strtol(tok, NULL, 16));
- _stp_print_char('\n');
- tok = strsep(&ptr, " ");
- }
-%}
-
-/**
* sfunction pp - Current probe point
*
* Return the probe point associated with the currently running
@@ -181,65 +131,6 @@ function pp:string () %{ /* pure */
%}
/**
- * sfunction probefunc - Function probed
- *
- * Return the probe point's function name, if known.
- */
-function probefunc:string () %{ /* pure */
- char *ptr, *start;
-
- start = strstr(CONTEXT->probe_point, "function(\"");
- ptr = start + 10;
- if (!start) {
- start = strstr(CONTEXT->probe_point, "inline(\"");
- ptr = start + 8;
- }
-
- if (start) {
- int len = MAXSTRINGLEN;
- char *dst = THIS->__retvalue;
- while (*ptr != '@' && --len > 0 && *ptr)
- *dst++ = *ptr++;
- *dst = 0;
-
- } else if (CONTEXT->regs &&
-#if defined (__ia64__)
- ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)KERNEL_START)) {
-#else
- ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)PAGE_OFFSET)) {
-#endif
- _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs));
- if (THIS->__retvalue[0] == '.') /* powerpc symbol has a dot*/
- strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN);
- } else {
- THIS->__retvalue[0] = '\0';
- }
-%}
-
-/**
- * sfunction probemod - Module probed
- *
- * Return the probe point's module name, if known.
- */
-function probemod:string () %{ /* pure */
- char *ptr, *start;
-
- start = strstr(CONTEXT->probe_point, "module(\"");
- ptr = start + 8;
-
- if (start) {
- int len = MAXSTRINGLEN;
- char *dst = THIS->__retvalue;
- while (*ptr != '"' && --len && *ptr)
- *dst++ = *ptr++;
- *dst = 0;
- } else {
- /* XXX: need a PC- and symbol-table-based fallback. */
- THIS->__retvalue[0] = '\0';
- }
-%}
-
-/**
* sfunction registers_valid - Register information valid
*
* Return 1 if register() and u_register() can be used
@@ -341,30 +232,3 @@ function stack_unused:long () %{ /* pure */
THIS->__retvalue = (long)&a & (THREAD_SIZE-1);
%}
-/**
- * sfunction caller_addr - Return caller address
- *
- * Return the address of the calling function.
- * <emphasis> Works only for return probes at this time.</emphasis>
- */
-function caller_addr:long () %{ /* pure */
- if (CONTEXT->pi)
- THIS->__retvalue = (int64_t)(long)_stp_ret_addr_r(CONTEXT->pi);
- else
- THIS->__retvalue = 0;
-%}
-
-/**
- * sfunction caller - Return name and address of calling function
- *
- * Return the address and name of the calling function.
- * <emphasis>Works only for return probes at this time.</emphasis>
- */
-function caller:string() %{ /* pure */
- if (CONTEXT->pi)
- _stp_symbol_snprint( THIS->__retvalue, MAXSTRINGLEN,
- (unsigned long)_stp_ret_addr_r(CONTEXT->pi));
- else
- strlcpy(THIS->__retvalue,"unknown",MAXSTRINGLEN);
-%}
-
diff --git a/translate.cxx b/translate.cxx
index 43299791..8f47ca92 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -1289,7 +1289,7 @@ c_unparser::emit_module_exit ()
<< "atomic_read (& ((struct context *)per_cpu_ptr(contexts, i))->busy)) "
<< "holdon = 1;";
// NB: we run at least one of these during the shutdown sequence:
- o->newline () << "yield ();"; // aka schedule() and then some
+ o->newline () << "yield ();"; // aka schedule() and then some
o->newline(-2) << "} while (holdon);";
// cargo cult epilogue
@@ -4601,6 +4601,9 @@ dump_unwindsyms (Dwfl_Module *m,
c->output << "struct _stp_symbol "
<< "_stp_module_" << stpmod_idx<< "_symbols_" << secidx << "[] = {" << endl;
+ // Only include symbols if they will be used
+ c->output << "#ifdef NEED_SYMBOL_DATA" << endl;
+
// 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++)
{
@@ -4610,6 +4613,9 @@ dump_unwindsyms (Dwfl_Module *m,
c->output << " { 0x" << hex << it->first-extra_offset << dec
<< ", " << lex_cast_qstring (it->second) << " }," << endl;
}
+
+ c->output << "#endif" << endl;
+
c->output << "};" << endl;
}
@@ -4675,7 +4681,7 @@ dump_unwindsyms (Dwfl_Module *m,
c->output << ".build_id_len = 0, " << endl;
//initialize the note section representing unloaded
- c->output << ".notes_sect = 0," << endl;
+ c->output << ".notes_sect = 0," << endl;
c->output << "};" << endl << endl;