From d2f4d7286629da6e9f1b844beefb141a4d3ef2c3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 10 Dec 2008 20:39:45 +0100 Subject: PR6866: First pass at translating addresses to symbol names through vma. --- tapset/context-symbols.stp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 79645f4f..fbb51767 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -11,6 +11,9 @@ #ifndef STP_NEED_SYMBOL_DATA #define STP_NEED_SYMBOL_DATA 1 #endif +#ifndef STP_NEED_TASK_FINDER_VMA +#define STP_NEED_TASK_FINDER_VMA 1 +#endif %} /** @@ -93,3 +96,8 @@ function probemod:string () %{ /* pure */ THIS->__retvalue[0] = '\0'; } %} + +function symbolname:string (addr:long) %{ /* pure */ + _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr, + current); +%} -- cgit From 3a5153c5590a89d6c0b70fc2c13554190b8c3be8 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 15 Dec 2008 18:04:36 +0100 Subject: context-symbols.stp (probefunc): Call _stp_symbol_snprint with current task. --- tapset/context-symbols.stp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index fbb51767..bd9a93b9 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -11,9 +11,6 @@ #ifndef STP_NEED_SYMBOL_DATA #define STP_NEED_SYMBOL_DATA 1 #endif -#ifndef STP_NEED_TASK_FINDER_VMA -#define STP_NEED_TASK_FINDER_VMA 1 -#endif %} /** @@ -66,7 +63,7 @@ function probefunc:string () %{ /* pure */ #else ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)PAGE_OFFSET)) { #endif - _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs)); + _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs), current); if (THIS->__retvalue[0] == '.') /* powerpc symbol has a dot*/ strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN); } else { -- cgit From 920c7355ae85ccfb2df3b93b3703619891598dc1 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 16 Mar 2009 14:21:50 +1000 Subject: fixed format of non-grabbable comments (for Tapset Reference Guide), added tapsetdescription for man page generator (in development) --- tapset/context-symbols.stp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 46eab841..4a08ec60 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -6,7 +6,11 @@ // 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. - +// +// Context functions provide additional information about where an event occurred. These functions can +//provide information such as a backtrace to where the event occured and the current register values for the +//processor. +// %{ #ifndef STP_NEED_SYMBOL_DATA #define STP_NEED_SYMBOL_DATA 1 -- cgit From 83b85c2b0be729352bae4ea204d814b377b32fcf Mon Sep 17 00:00:00 2001 From: ddomingo Date: Tue, 17 Mar 2009 15:13:23 +1000 Subject: minor edits --- tapset/context-symbols.stp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 4a08ec60..babaa3ef 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -22,8 +22,9 @@ * @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 + * 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. @@ -40,9 +41,7 @@ function print_stack(stk:string) %{ %} /** - * sfunction probefunc - Function probed - * - * Return the probe point's function name, if known. + * sfunction probefunc - Return the probe point's function name, if known. */ function probefunc:string () %{ /* pure */ char *ptr, *start; @@ -76,9 +75,7 @@ function probefunc:string () %{ /* pure */ %} /** - * sfunction probemod - Module probed - * - * Return the probe point's module name, if known. + * sfunction probemod - Return the probe point's module name, if known. */ function probemod:string () %{ /* pure */ char *ptr, *start; -- cgit From d8ad52f9739264779d2efc7dad8b7e2cfe785868 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Tue, 17 Mar 2009 15:14:30 +1000 Subject: minor edits --- tapset/context-symbols.stp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index babaa3ef..a3aae408 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -18,7 +18,7 @@ %} // weirdness with print_stack, argument appears in build as undescribed /** - * sfunction print_stack - Print out stack from string + * 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, -- cgit From b2b336288ce9e92a21efe7dcd314f604bc97be29 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 2 Apr 2009 18:42:38 +0200 Subject: PR6580: Implement symname, symdata and modname context functions. This adds a couple of the suggested context/stack revamp functions from PR6580. In particular it replaces the symbolname() function that sneaked in with the pr6866 branch merge with the suggested symname(). * runtime/sym.c (_stp_mod_sec_lookup): Make section optional. (_stp_symbol_snprint): Provide a way to get optional module info. * tapset/context-symbols.stp: Replace symbolname() with symname(), add modname() and symdata(). (probemod): Implement pc based fallback. * tapset/context-unwind.stp (caller): Adjust for _stp_symbol_snprint change. * testsuite/systemtap.context/usymbols.exp: Use new symname. * testsuite/buildok/modname.stp: New test. * testsuite/buildok/symdata.stp: Likewise. * testsuite/buildok/symname.stp: Likewise. --- tapset/context-symbols.stp | 60 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 4c200aa8..66d9fea2 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -66,7 +66,7 @@ function probefunc:string () %{ /* pure */ #else ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)PAGE_OFFSET)) { #endif - _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs), current); + _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs), current, 0); if (THIS->__retvalue[0] == '.') /* powerpc symbol has a dot*/ strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN); } else { @@ -89,13 +89,59 @@ function probemod:string () %{ /* pure */ while (*ptr != '"' && --len && *ptr) *dst++ = *ptr++; *dst = 0; - } else { - /* XXX: need a PC- and symbol-table-based fallback. */ - THIS->__retvalue[0] = '\0'; - } + } else if (CONTEXT->regs) { + struct _stp_module *m; + m = _stp_mod_sec_lookup (REG_IP(CONTEXT->regs), current, NULL); + if (m && m->name) + strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN); + else + strlcpy (THIS->__retvalue, "", MAXSTRINGLEN); + } else + strlcpy (THIS->__retvalue, "", MAXSTRINGLEN); %} -function symbolname:string (addr:long) %{ /* pure */ +/** + * sfunction modname - Return the kernel module name loaded at the address. + * @addr: The address. + * + * Description: Returns the module name associated with the given + * address if known. If not known it will return the string "". + * If the address was not in a kernel module, but in the kernel itself, + * then the string "kernel" will be returned. + */ +function modname:string (addr: long) %{ /* pure */ + struct _stp_module *m; + m = _stp_mod_sec_lookup (THIS->addr, current, NULL); + if (m && m->name) + strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN); + else + strlcpy (THIS->__retvalue, "", MAXSTRINGLEN); +%} + +/** + * sfunction symname - Return the symbol associated with the given address. + * @addr: The address to translate. + * + * Description: Returns the (function) symbol name associated with the + * given address if known. If not known it will return the hex string + * representation of addr. + */ +function symname:string (addr: long) %{ /* pure */ + _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr, + current, 0); +%} + +/** + * sfunction symdata - Return the symbol and module offset for the address. + * @addr: The address to translate. + * + * Description: Returns the (function) symbol name associated with the + * given address if known, plus the module name (between brackets) and + * the offset inside the module, plus the size of the symbol function. + * If any element is not known it will be ommitted and if the symbol name + * is unknown it will return the hex string for the given address. + */ +function symdata:string (addr: long) %{ /* pure */ _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr, - current); + current, 1); %} -- cgit From fc204b30292a3a5f1aa602171dc44d937cb2c20f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 7 Apr 2009 12:25:53 +0200 Subject: Create usymname and usymdata variant that trigger STP_NEED_VMA_TRACKER. * tapset/context-symbols.stp (syname, symdata): Pass NULL for kernel address. * tapset/ucontext-symbols.stp: New file defining usymname and usymdata. * testsuite/systemtap.context/usymbols.exp: Use usymname, remove STP_NEED_VMA_TRACKER hack. * testsuite/buildok/usymdata.stp: New test. * testsuite/buildok/usymname.stp: Likewise. --- tapset/context-symbols.stp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 66d9fea2..783f1b7b 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -128,7 +128,7 @@ function modname:string (addr: long) %{ /* pure */ */ function symname:string (addr: long) %{ /* pure */ _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr, - current, 0); + NULL, 0); %} /** @@ -143,5 +143,5 @@ function symname:string (addr: long) %{ /* pure */ */ function symdata:string (addr: long) %{ /* pure */ _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr, - current, 1); + NULL, 1); %} -- cgit From 6094e1992123454047c79ce724475c49e834d218 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 21 Apr 2009 16:45:31 +0200 Subject: Remove documentation weirdness FIXME in tapset print_stack(). Weirdness was fixed in commit d4db5608. * tapset/context-symbols.stp (print_stack): Remove FIXME. --- tapset/context-symbols.stp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tapset/context-symbols.stp') diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 783f1b7b..e4406d9b 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -16,10 +16,10 @@ #define STP_NEED_SYMBOL_DATA 1 #endif %} -// weirdness with print_stack, argument appears in build as undescribed + /** * sfunction print_stack - Print out stack from string. - * @stk: String with list of hexidecimal addresses. (FIXME) + * @stk: String with list of hexidecimal addresses. * * Perform a symbolic lookup of the addresses in the given string, * which is assumed to be the result of a prior call to -- cgit