// 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 */
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;
+ }
}
};
tapset_compile_coverage = false;
need_uprobes = false;
need_unwind = false;
+ need_symbols = false;
uprobes_path = "";
consult_symtab = false;
ignore_vmlinux = false;
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;
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
// 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
* 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) {
* 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;
* 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(\"");
* 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);
%}
* 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);
%}
//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
* 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);
%}
* 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);
%}
// 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.
* 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);
%}
* 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);
%}
* 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) {
* 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;
// 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!
*
* 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);
%}
* 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);
* 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);
%}
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;
}
}
}
<< "_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";