]> sourceware.org Git - systemtap.git/commitdiff
Better split kernel/user space address symbol lookups.
authorMark Wielaard <mjw@redhat.com>
Wed, 23 Jun 2010 19:07:33 +0000 (21:07 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 23 Jun 2010 19:12:59 +0000 (21:12 +0200)
* runtime/sym.c (_stp_mod_sec_lookup): Don't fall through to kernel module
  address search when we know to be looking for a user space module/vma.
* tapset/context-symbols.stp (probefunc): Clarify documentation.
  Use user_mode(CONTEXT->regs) check. Pass NULL for task to
  _stp_symbol_snprint().
 (probemod): Clarify documentation. Pass NULL for task to
 _stp_mod_sec_lookup().
 (modname): Likewise.
 (symname): Clarify documentation.
 (symdata): Likewise.

runtime/sym.c
tapset/context-symbols.stp

index b9db8dc9b6ac45b4c3bb20f13aa3854886adca1d..c746a758e3d83412b2ff62f19828a36974d66b94 100644 (file)
@@ -115,8 +115,7 @@ static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr,
                     m->sections[0].name, m->name, vm_start);
            return m;
          }
-      /* XXX should really not fallthrough, but sometimes current is passed
-             when it shouldn't - see probefunc() for example. */
+      return NULL;
     }
 
   for (midx = 0; midx < _stp_num_modules; midx++)
index 4335402eac4395c2c83230d49e60d1671947d820..8633c390f2e3dd643e84c1fab1ef0ac9503345b3 100644 (file)
@@ -50,8 +50,11 @@ function print_stack(stk:string) %{
  * General Syntax: probefunc:string()
  *
  * Description: This function returns the name of the function being probed.
- * Please note: this function is depreciated, please use symname() and/or
- * usymname().
+ * It will do this based on the probe point string as returned by pp().
+ * Please note: this function is deprecated, please use symname() and/or
+ * usymname(). This function might return a function name based on the
+ * current address of the task if that is in kernel space, but not for
+ * any user space addresses. Please use usymname(uaddr()) for that.
  */
 function probefunc:string () %{ /* pure */
        char *ptr, *start;
@@ -70,13 +73,8 @@ function probefunc:string () %{ /* pure */
                        *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), current, 0);
+       } else if (CONTEXT->regs && !user_mode(CONTEXT->regs)) {
+               _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs), NULL, 0);
                         if (THIS->__retvalue[0] == '.')  /* powerpc symbol has a dot*/
                                strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN);
        } else {
@@ -85,12 +83,12 @@ function probefunc:string () %{ /* pure */
 %}
 
 /**
- * sfunction probemod - Return the probe point's module name.
+ * sfunction probemod - Return the probe point's kernel module name.
  * 
  * General Syntax: probemod:string()
  * 
- * Description: This funciton returns the name of the module containing the 
- * probe point, if known.
+ * Description: This funciton returns the name of the kernel module
+ * containing the probe point, if known.
  */
 function probemod:string () %{ /* pure */
        char *ptr, *start;
@@ -106,7 +104,7 @@ function probemod:string () %{ /* pure */
                *dst = 0;
        } else if (CONTEXT->regs) {
                struct _stp_module *m;
-               m = _stp_mod_sec_lookup (REG_IP(CONTEXT->regs), current, NULL, NULL);
+               m = _stp_mod_sec_lookup (REG_IP(CONTEXT->regs), NULL, NULL, NULL);
                if (m && m->name)
                        strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN);
                else
@@ -126,7 +124,7 @@ function probemod:string () %{ /* pure */
  */
 function modname:string (addr: long) %{ /* pure */
        struct _stp_module *m;
-       m = _stp_mod_sec_lookup (THIS->addr, current, NULL, NULL);
+       m = _stp_mod_sec_lookup (THIS->addr, NULL, NULL, NULL);
        if (m && m->name)
           strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN);
        else
@@ -134,7 +132,7 @@ function modname:string (addr: long) %{ /* pure */
 %}
 
 /**
- * sfunction symname - Return the symbol associated with the given address.
+ * sfunction symname - Return the kernel symbol associated with the given address.
  *
  * General Syntax: symname:string(addr:long)
  * 
@@ -150,7 +148,7 @@ function symname:string (addr: long) %{ /* pure */
 %}
 
 /**
- * sfunction symdata - Return the symbol and module offset for the address.
+ * sfunction symdata - Return the kernel symbol and module offset for the address.
  *
  * General Syntax: symdata:string(addr:long)
  *
This page took 0.032145 seconds and 5 git commands to generate.