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

help: how to use gofuncgraph correctly #2

Closed
hitzhangjie opened this issue Aug 17, 2023 · 5 comments
Closed

help: how to use gofuncgraph correctly #2

hitzhangjie opened this issue Aug 17, 2023 · 5 comments

Comments

@hitzhangjie
Copy link

I have a golang program:

package main

import "time"

func main() {
  time.Sleep(time.Second)
}

then build go build -o main main.go

then run:

$ gofuncgraph --uprobe-wildcards='main.main' ./main 
found 3 uprobes, large number of uprobes (>1000) need long time for attaching and detaching, continue? [Y/n]
Y
INFO[0003] start tracing                                
^C
INFO[0009] start detachin

After 1 second, there's nothing output, I have to ctrl+c to terminate. I want to see the timecost duration execution of main.main.
Please help.

@hitzhangjie hitzhangjie changed the title help: how to solve the problem, required flag "uprobe-wildcards" not set help: how to use gofuncgraph correctly Aug 17, 2023
@jschwinger233
Copy link
Owner

$ sudo gofuncgraph --uprobe-wildcards 'main.main' ./gofunc_issue_2 'main.main'
found 3 uprobes, large number of uprobes (>1000) need long time for attaching and detaching, continue? [Y/n]
y
INFO[0002] start tracing                                

17 19:33:08.6581           main.main() { runtime.main+519 ?:?
17 19:33:09.6582 001.0001  } main.main+39 /home/gray/src/github.com/jschwinger233/proving-ground/gofunc_issue_2/main.go:7
^CINFO[0030] start detaching 

Steps:

  1. sudo gofuncgraph --uprobe-wildcards 'main.main' ./main 'main.main'
  2. in another terminal: ./main

Probably you thought gofuncgraph would execute the command automatically, it actually merely traces the binary, and you'll have to run the command manually.

Sorry for the misunderstanding, I've always been too lazy to work out an up-to-date and user-friendly documentation.

@jschwinger233
Copy link
Owner

BTW your tech blog helped me before, thanks a lot for those high-quality articles regarding ELF and debugger. 👍

@jschwinger233
Copy link
Owner

To be clear, the execution order is not required: in this case we have to run gofuncgraph ahead of ./main, otherwise we'll miss the invocation of main.main function.

For another scenario, for instance, if we'd like to trace grpc-related APIs inside a running daemon, just run gofuncgraph to attach the binary, then we can collect information from running process without disruption.

@hitzhangjie
Copy link
Author

hitzhangjie commented Aug 17, 2023

Thanks very much. It works.

@hitzhangjie
Copy link
Author

hitzhangjie commented Aug 17, 2023

I'm learning how to use ebpf and cilium.
gofuncgraph is not only a very nice tool but also a good learning material. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants