Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support golang arguments #740

Open
brendangregg opened this issue Jun 8, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@brendangregg
Copy link
Member

commented Jun 8, 2019

using gccgo, Go function arguments can be read using arg0...argN, as it follows the standard AMD64 ABI. Eg:

# bpftrace -e 'uprobe:/home/bgregg/func:main.add { printf("%d %d\n", arg0, arg1); }'
Attaching 1 probe...
42 13

But using Go gc, it follows the Plan9 stack convention where everything is placed on the stack. The same arguments can be read instead using:

# bpftrace -e 'uprobe:/home/bgregg/Lang/go/func:main*add { printf("%d %d\n", *(reg("sp") + 8), *(reg("sp") + 16)); }'
Attaching 1 probe...
42 13

This ticket is to suggest adding these aliases:

  • goarg0 == *(reg("sp") + 8)
  • goarg1 == *(reg("sp") + 16)
  • etc

Maybe better: call them sarg0, sarg1, ...: short for "stack argument", since Golang may not be the only runtime/compiler doing this.

@acj acj referenced a pull request that will close this issue Jul 16, 2019

Open

Add sargX alias to support Go function arguments #828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.