]> sourceware.org Git - systemtap.git/commitdiff
PR12276: add functions [u]symfile and [u]symline
authorAbegail Jakop <ajakop@redhat.com>
Mon, 22 Dec 2014 21:58:44 +0000 (16:58 -0500)
committerAbegail Jakop <ajakop@redhat.com>
Mon, 22 Dec 2014 21:58:44 +0000 (16:58 -0500)
runtime/sym.c: in _stp_snprint_addr(), add in the ability to return
the linenumber or the filename.
tapset/linux/[u]context-symbols.stp: added functions [u]symline and
[u]symfile. fixed spelling mistake with pragma:myproc-unprivileged

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

index 8c2ea2c59bdb313eefe662e50a31dd719ece13c8..42fdee5bc2764ea1d1f9820a65346d59c01f6332 100644 (file)
@@ -761,7 +761,7 @@ static int _stp_snprint_addr(char *str, size_t len, unsigned long address,
         modname = slash+1;
   }
 
-  if (flags & _STP_SYM_LINENUMBER) {
+  if ((flags & _STP_SYM_LINENUMBER) || (flags & _STP_SYM_FILENAME)) {
       linenumber = _stp_linenumber_lookup (address, task, &filename,
                                            (int) (flags & _STP_SYM_FILENAME));
   }
@@ -873,17 +873,25 @@ static int _stp_snprint_addr(char *str, size_t len, unsigned long address,
 #endif
     } else if ((flags & _STP_SYM_LINENUMBER) && linenumber) {
         if (flags & _STP_SYM_FILENAME) {
-          if (filename)
+          if (filename) {
+            /* filename, linenumber */
             return _stp_snprintf(str, len, "%s%s:%u%s%s", prestr,
                  filename, (int64_t) linenumber, exstr, poststr);
-          else
+          } else {
+            /* filename=??, linenumber */
             return _stp_snprintf(str, len, "%s??:%u%s%s", prestr,
                  (int64_t) linenumber, exstr, poststr);
+          }
         } else {
-            return _stp_snprintf(str, len, "%s%u%s%s", prestr,
-                 (int64_t) linenumber, exstr, poststr);
+          /* linenumber */
+          return _stp_snprintf(str, len, "%s%u%s%s", prestr,
+               (int64_t) linenumber, exstr, poststr);
         }
-    } else {
+    } else if ((flags & _STP_SYM_FILENAME) && filename) {
+      /* filename */
+      return _stp_snprintf(str, len, "%s%s%s%s", prestr,
+           filename, exstr, poststr);
+    }else {
       /* no names, hex only */
       return _stp_snprintf(str, len, "%s%p%s%s", prestr,
                           (int64_t) address, exstr, poststr);
index 5622b4ba6eecdde0e1e9abbbb857a6cb29be17c8..e2fe40272ba2ba663b245c5e98c97379f6978123 100644 (file)
@@ -314,3 +314,31 @@ function symfileline:string (addr:long) %{
   _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
                     _STP_SYM_LINENUMBER + _STP_SYM_FILENAME, NULL);
 %}
+
+/**
+ * sfunction usymfile - Return the file name of a given address.
+ * @addr: The address to translate.
+ *
+ * Description: Returns the file name of the  given address, if known. If the
+ * file name cannot be found, the hex string representation of the address
+ * will be returned.
+ */
+function symfile:string (addr:long) %{
+/* pure */ /* pragma:symbols */ /* pragma:lines */
+  _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
+                    _STP_SYM_FILENAME, NULL);
+%}
+
+/**
+ * sfunction usymline - Return the line number of an address.
+ * @addr: The address to translate.
+ *
+ * Description: Returns the (approximate) line number of the given address, if
+ * known. If the line number cannot be found, the hex string representation of
+ * the address will be returned.
+ */
+function symline:string (addr:long) %{
+/* pure */ /* pragma:symbols */ /* pragma:lines */
+  _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
+                    _STP_SYM_LINENUMBER, NULL);
+%}
index 25796a675e75387d476cf264d2da3888e75b91f4..c04b49984644334a3ecfd217030881a727b1b168 100644 (file)
@@ -181,7 +181,35 @@ function sprint_usyms (callers:string) {
  * found, the hex string representation of the address will be returned.
  */
 function usymfileline:string (addr:long) %{
-/* pure */ /* myproc-unpriveleged */ /* pragma:symbols */ /* pragma:vma */ /* pragma:lines */
+/* pure */ /* myproc-unprivileged */ /* pragma:symbols */ /* pragma:vma */ /* pragma:lines */
   _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
                     _STP_SYM_LINENUMBER + _STP_SYM_FILENAME, current);
 %}
+
+/**
+ * sfunction usymfile - Return the file name of a given address.
+ * @addr: The address to translate.
+ *
+ * Description: Returns the file name of the  given address, if known. If the
+ * file name cannot be found, the hex string representation of the address
+ * will be returned.
+ */
+function usymfile:string (addr:long) %{
+/* pure */ /* myproc-unprivileged */ /* pragma:symbols */ /* pragma:vma */ /* pragma:lines */
+  _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
+                    _STP_SYM_FILENAME, current);
+%}
+
+/**
+ * sfunction usymline - Return the line number of an address.
+ * @addr: The address to translate.
+ *
+ * Description: Returns the (approximate) line number of the given address, if
+ * known. If the line number cannot be found, the hex string representation of
+ * the address will be returned.
+ */
+function usymline:string (addr:long) %{
+/* pure */ /* myproc-unprivileged */ /* pragma:symbols */ /* pragma:vma */ /* pragma:lines */
+  _stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
+                    _STP_SYM_LINENUMBER, current);
+%}
This page took 0.03619 seconds and 5 git commands to generate.