How to inspect the variables of user space functions in systemtap?

Jincheng Miao

I met a problem when inspecting the local variables of user space application in systemtap.

I write a test.c like this:

#include <stdio.h>

int func(int *p, int val)
{
        printf("p=%p val=%d\n", p, val);
        return 1;
}

int main()
{
        int a = 7;
        func(&a, a);
        return 0;
}

and compile it with -g

# gcc -g -o test test.c

Systemtap can see the variable of func(): p and val

# stap -L 'process("./test").function("func")'
process("/home/ryan/Public/test").function("func@/home/ryan/Public/test.c:3") $p:int* $val:int

So I use this stp to watch the variables:

# stap -e 'probe process("./test").function("func") {printf("%s(%p, %d)\n", probefunc(), $p, $val)}'

But the local variables are not right in the result when test program executed, it shows:

func(0x0, 0)

I am using fedora19 with:

kernel-3.11.9-200.fc19.x86_64
systemtap-sdt-devel-2.3-1.fc19.x86_64
systemtap-2.3-1.fc19.x86_64
systemtap-client-2.3-1.fc19.x86_64
systemtap-devel-2.3-1.fc19.x86_64
systemtap-runtime-2.3-1.fc19.x86_64
gcc-4.8.2-7.fc19.x86_64

Could someone meet this problem or give me a solution?

fche

.function probes are defined to fire at entry to the function. If you're looking for values of local variables, you need to use .statement probes, identifying the source-file:line-number. In this case though, you're looking for parameters to a function (which happened to be based on another function's locals). In this case, the .function probe is appropriate.

You appear to be hitting a GCC bug. In plain -g mode (ironically), dwarf debuginfo is sometimes inaccurate for incoming function parameters. Try "gcc -g -O" or "gcc -g -O2" instead. Systemtap prologue-searching (stap -P) might help. See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51358, https://sourceware.org/bugzilla/show_bug.cgi?id=13420

In case the "stap -P" doesn't help, you may need to resort to statement-level probing after all:

probe process("./test").statement("[email protected]:5") { println($$parms) }

(line :5 refers to the printf)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to do user-space probing using debug info in systemtap

From Dev

PDB: How to inspect local variables of functions in nested stack frames?

From Dev

How to inspect variables after Traceback?

From Dev

How to free components like struct and functions in User space program?

From Dev

SystemTap script to profile latency of functions

From Dev

How to inspect the javascript functions and its arguments

From Dev

How do I inspect Pelican variables

From Dev

How can I inspect cmake internal variables?

From Dev

How do you inspect CSS variables in the browser?

From Dev

how to get syscall document in systemtap

From Dev

How to understand "$location" in a Systemtap script?

From Dev

Capturing user-space variables at "perf" events

From Dev

Linux timer in user-space and shared variables

From Dev

JQuery debugging: how do I inspect the attached functions?

From Dev

JQuery debugging: how do I inspect the attached functions?

From Dev

Python Inspect and Functions

From Dev

Inspect WebdriverIO spec variables

From Dev

How limit the storage space for a user?

From Dev

How to share global variables (arrays) in an OpenCL kernel with several user defined functions

From Dev

In Python2.7 how to use variables from main script and other user defined functions

From Dev

How to use variables in callback functions?

From Dev

How to bring variables into functions - Python

From Dev

Using user-space functions like sprintf in the kernel, or not?

From Dev

Using user-space functions like sprintf in the kernel, or not?

From Dev

How do remove / inspect what uses so many disk space on my root partition?

From Dev

Is it possible to pass environment variables from child to parent in user space?

From Dev

Using gdb to inspect environment variables

From Dev

How to remove space when combining variables in PowerShell

From Dev

How to setup a per-user private space

Related Related

  1. 1

    How to do user-space probing using debug info in systemtap

  2. 2

    PDB: How to inspect local variables of functions in nested stack frames?

  3. 3

    How to inspect variables after Traceback?

  4. 4

    How to free components like struct and functions in User space program?

  5. 5

    SystemTap script to profile latency of functions

  6. 6

    How to inspect the javascript functions and its arguments

  7. 7

    How do I inspect Pelican variables

  8. 8

    How can I inspect cmake internal variables?

  9. 9

    How do you inspect CSS variables in the browser?

  10. 10

    how to get syscall document in systemtap

  11. 11

    How to understand "$location" in a Systemtap script?

  12. 12

    Capturing user-space variables at "perf" events

  13. 13

    Linux timer in user-space and shared variables

  14. 14

    JQuery debugging: how do I inspect the attached functions?

  15. 15

    JQuery debugging: how do I inspect the attached functions?

  16. 16

    Python Inspect and Functions

  17. 17

    Inspect WebdriverIO spec variables

  18. 18

    How limit the storage space for a user?

  19. 19

    How to share global variables (arrays) in an OpenCL kernel with several user defined functions

  20. 20

    In Python2.7 how to use variables from main script and other user defined functions

  21. 21

    How to use variables in callback functions?

  22. 22

    How to bring variables into functions - Python

  23. 23

    Using user-space functions like sprintf in the kernel, or not?

  24. 24

    Using user-space functions like sprintf in the kernel, or not?

  25. 25

    How do remove / inspect what uses so many disk space on my root partition?

  26. 26

    Is it possible to pass environment variables from child to parent in user space?

  27. 27

    Using gdb to inspect environment variables

  28. 28

    How to remove space when combining variables in PowerShell

  29. 29

    How to setup a per-user private space

HotTag

Archive