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

Closed
brendangregg opened this issue Jun 8, 2019 · 0 comments · Fixed by #828
Closed

Support golang arguments #740

brendangregg opened this issue Jun 8, 2019 · 0 comments · Fixed by #828
Labels
enhancement New feature or request, changes on existing features

Comments

@brendangregg
Copy link
Member

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.

@mmarchini mmarchini added the enhancement New feature or request, changes on existing features label Jul 24, 2019
@fbs fbs closed this as completed in #828 Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request, changes on existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants