]> sourceware.org Git - systemtap.git/commitdiff
PR6580: reimplement straightforward legacy functions in terms of stack().
authorSerguei Makarov <smakarov@redhat.com>
Wed, 19 Sep 2012 20:34:23 +0000 (16:34 -0400)
committerSerguei Makarov <smakarov@redhat.com>
Wed, 19 Sep 2012 20:34:23 +0000 (16:34 -0400)
tapset/linux/context-caller.stp
tapset/linux/context-symbols.stp
tapset/linux/ucontext-symbols.stp

index ed67e9f2c54aaebe61865ce35ac079b046449aa1..366055bfd1fe0c6fb6e18da555975063d92a558a 100644 (file)
@@ -54,13 +54,4 @@ function caller:string() {
  *  Description: This function returns the address of the calling function. 
  *  Works only for return probes at this time.
  */
-function caller_addr:long () %{ /* pure */
-        if (CONTEXT->probe_type == _STP_PROBE_HANDLER_KRETPROBE)
-               STAP_RETVALUE = (int64_t)(long)_stp_ret_addr_r(CONTEXT->ips.krp.pi);
-#ifdef STAPCONF_UPROBE_GET_PC
-       else if (CONTEXT->probe_type == _STP_PROBE_HANDLER_URETPROBE)
-               STAP_RETVALUE = (int64_t)(long)_stp_ret_addr_r(CONTEXT->ips.ri);
-#endif
-        else
-               STAP_RETVALUE = 0;
-%}
+function caller_addr:long () { return stack(1) }
index 4cc7a6042a0be604848f55276c5ba67bb6db566d..6d759e9af5528e04bfe13e88943160c9f37e63f7 100644 (file)
@@ -54,15 +54,7 @@ function stack:long (n:long) {
  *  name  of the function containing the address, and an estimate of
  *  its position within that function.  Return nothing.
  */
-function print_stack(stk:string) %{ /* pragma:symbols */
-       char *ptr = STAP_ARG_stk;
-       char *tok = strsep(&ptr, " ");
-       while (tok && *tok) {
-               _stp_print_addr (simple_strtol(tok, NULL, 16),
-                                _STP_SYM_FULL, NULL);
-               tok = strsep(&ptr, " ");
-       }
-%}
+function print_stack(stk:string) { psyms(stk) }
 
 /**
  * sfunction sprint_stack - Return stack for kernel addresses from string
@@ -81,26 +73,7 @@ function print_stack(stk:string) %{ /* pragma:symbols */
  * truncated to MAXSTRINGLEN, to print fuller and richer stacks use
  * print_stack.
  */
-function sprint_stack:string(stk:string) %{ /* pure */ /* pragma:symbols */
-       char *ptr = STAP_ARG_stk;
-       char *tok = strsep(&ptr, " ");
-       char *str = STAP_RETVALUE;
-       size_t len = MAXSTRINGLEN - 1;
-       while (tok && *tok && len > 0) {
-               int s = _stp_snprint_addr(str, len,
-                                         simple_strtol(tok, NULL, 16),
-                                         _STP_SYM_SIMPLE, NULL);
-               len -= s;
-               str += s;
-               tok = strsep(&ptr, " ");
-       }
-
-        str--;
-        if (len > 0)
-                str[0] = '\0';
-        else
-                STAP_RETVALUE[MAXSTRINGLEN - 1] = '\0';
-%}
+function sprint_stack:string(stk:string) { return spsyms(stk) }
 
 /**
  * sfunction probefunc - Return the probe point's function name, if known
index da642e09e163b50103164e90822862b5cd4c20c7..8f698a6cbd4a6426db1485260df03fc7f5aab547 100644 (file)
@@ -85,16 +85,20 @@ function usymdata:string (addr: long) %{
  *  name  of the function containing the address, and an estimate of
  *  its position within that function.  Return nothing.
  */
-function print_ustack(stk:string) %{
-/* myproc-unprivileged */ /* pragma:vma */ /* pragma:symbols */
-        char *ptr = STAP_ARG_stk;
-        char *tok = strsep(&ptr, " ");
-        while (tok && *tok) {
-                _stp_print_addr(simple_strtol(tok, NULL, 16),
-                               _STP_SYM_FULL, current);
-                tok = strsep(&ptr, " ");
-        }
-%}
+function print_ustack(stk:string) { upsyms(stk) }
+
+/**
+ * sfunction upsyms - print usymdata() for all addresses in callers
+ *
+ * @callers: String with list of hexadecimal (user) addresses
+ */
+function upsyms (callers:string) {
+         sym = tokenize (callers, " ");
+         while (sym != "") {
+               println (usymdata (strtol(sym,16)));
+               sym = tokenize ("", " ");
+         }
+}
 
 /**
  * sfunction sprint_ustack - Return stack for the current task from string.
@@ -114,23 +118,25 @@ function print_ustack(stk:string) %{
  * truncated to MAXSTRINGLEN, to print fuller and richer stacks use
  * print_ustack.
  */
-function sprint_ustack:string(stk:string) %{ /* pure */ /* pragma:symbols */
-       char *ptr = STAP_ARG_stk;
-       char *tok = strsep(&ptr, " ");
-       char *str = STAP_RETVALUE;
-       size_t len = MAXSTRINGLEN - 1;
-       while (tok && *tok && len > 0) {
-               int s = _stp_snprint_addr(str, len,
-                                         simple_strtol(tok, NULL, 16),
-                                         _STP_SYM_SIMPLE, current);
-               len -= s;
-               str += s;
-               tok = strsep(&ptr, " ");
-       }
+function sprint_ustack:string(stk:string) { uspsyms(stk) }
 
-       str--;
-       if (len > 0)
-               str[0] = '\0';
-       else
-               STAP_RETVALUE[MAXSTRINGLEN - 1] = '\0';
-%}
+/**
+ * sfunction uspsyms - return usymdata() for all addresses in callers
+ *
+ * @callers: String with list of hexadecimal (user) addresses
+ *
+ * Note that the output will be truncated to MAXSTRINGLEN.
+ * A full stack can be dumped using upsyms().
+ */
+function uspsyms (callers:string) {
+         sym = tokenize (callers, " ");
+         foo = ""; l = 0
+         while (sym != "") {
+               // cleanly handle overflow instead of printing partial line:
+               line = usymdata (strtol(sym, 16)) . "\n"; l += strlen(line)
+               if (l > %{ MAXSTRINGLEN %}) break
+               foo .= line
+               sym = tokenize ("", " ")
+         }
+         return foo
+}
This page took 0.030292 seconds and 5 git commands to generate.