]> sourceware.org Git - systemtap.git/commitdiff
2006-05-24 Josh Stone <joshua.i.stone@intel.com>
authorjistone <jistone>
Wed, 24 May 2006 19:17:13 +0000 (19:17 +0000)
committerjistone <jistone>
Wed, 24 May 2006 19:17:13 +0000 (19:17 +0000)
PR 2677
* sym.c (_stp_symbol_sprint_basic): New function that returns
just the symbol name, and doesn't bother with String.
* context.stp (probefunc): Use _stp_symbol_sprint_basic

runtime/ChangeLog
runtime/sym.c
tapset/ChangeLog
tapset/context.stp

index 197ac4485e7973047ac139ccbe87a3acc8dfe790..e093850bcc097319a6f74db398536908bcb86d70 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-24  Josh Stone  <joshua.i.stone@intel.com>
+
+       PR 2677
+       * sym.c (_stp_symbol_sprint_basic): New function that returns
+       just the symbol name, and doesn't bother with String.
+
 2006-05-24  Li Guanglei <guanglei@cn.ibm.com>
        * lket/b2a/Makefile.am, lket/b2a/Makefile.in,
        lket/b2a/README, lket/b2a/lket_b2a.c,
index 032d0e50a1f285ad8dbc5b42c0eabafe96c8f4d9..763af16d038c6fc5f1ec10f85c4f6c2c1630244d 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- linux-c -*- 
  * Symbolic Lookup Functions
  * Copyright (C) 2005 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
@@ -55,5 +56,36 @@ String _stp_symbol_sprint (String str, unsigned long address)
 
 #define _stp_symbol_print(address) _stp_symbol_sprint(_stp_stdout,address)
 
+
+/** Write addresses symbolically into a char buffer
+ * @param str Destination buffer
+ * @param len Length of destination buffer
+ * @param address The address to lookup.
+ * @note Symbolic lookups should not normally be done within
+ * a probe because it is too time-consuming. Use at module exit time.
+ */
+
+const char *_stp_symbol_sprint_basic (char *str, size_t len, unsigned long address)
+{ 
+    char *modname;
+    const char *name;
+    unsigned long offset, size;
+    char namebuf[KSYM_NAME_LEN+1];
+
+    if (len > KSYM_NAME_LEN) {
+        name = _stp_kallsyms_lookup(address, &size, &offset, &modname, str);
+        if (!name)
+            snprintf(str, len, "0x%lx", address);
+    } else {
+        name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
+        if (name)
+            strlcpy(str, namebuf, len);
+        else
+            snprintf(str, len, "0x%lx", address);
+    }
+
+    return str;
+}
+
 /** @} */
 #endif /* _SYM_C_ */
index 63323cc77e96c17b4b480fe210eabe7e23fc6e8d..1fc64c625db1307ac67f556c789b6b4fe833c6cf 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-24  Josh Stone  <joshua.i.stone@intel.com>
+
+       PR 2677
+       * context.stp (probefunc): Use _stp_symbol_sprint_basic
+
 2006-05-19  Li Guanglei <guanglei@cn.ibm.com>
 
        Patch from Mao Bibo (bibo.mao@intel.com)
index 9a46df1966b6b5356edf6b2694061ff36387cc04..0565d1b7e7255c07a04eb34df36f8bae9ea39e1c 100644 (file)
@@ -1,5 +1,6 @@
 // context tapset
 // Copyright (C) 2005, 2006 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
@@ -89,9 +90,7 @@ function pp:string () %{ /* pure */
 %}
 
 function probefunc:string () %{ /* pure */
-       char *dst, *ptr, *start;
-       String str;
-       int len = MAXSTRINGLEN;
+       char *ptr, *start;
 
        start = strstr(CONTEXT->probe_point, "function(\"");
        ptr = start + 10; 
@@ -99,28 +98,21 @@ function probefunc:string () %{ /* pure */
                start = strstr(CONTEXT->probe_point, "inline(\"");
                ptr = start + 8;
        }
+
        if (start) {
-               dst = THIS->__retvalue;
+               int len = MAXSTRINGLEN;
+               char *dst = THIS->__retvalue;
                while (*ptr != '@' && --len > 0 && *ptr)
                        *dst++ = *ptr++;
                *dst = 0;
+
        } else if (CONTEXT->regs) {
-               str  = _stp_string_init (0);
-               _stp_symbol_sprint(str, REG_IP(CONTEXT->regs));
-               start = strstr(_stp_string_ptr(str), " : ");
-               if (start) {
-                       dst = THIS->__retvalue;
-                       ptr = start+3;
-                       while (*ptr != '+' && --len > 0 && *ptr)
-                               *dst++ = *ptr++;
-                       *dst = 0;
-               }
-               else {
-                       strlcpy(THIS->__retvalue, _stp_string_ptr(str),MAXSTRINGLEN);
-               }
+               _stp_symbol_sprint_basic(THIS->__retvalue, MAXSTRINGLEN,
+                               REG_IP(CONTEXT->regs));
+
        } else {
-        THIS->__retvalue[0] = '\0';
-    }
+               THIS->__retvalue[0] = '\0';
+       }
 %}
 
 function is_return:long () %{ /* pure */
This page took 0.037076 seconds and 5 git commands to generate.