[英]`go tool pprof` - how to specify source when using go modules?
I switched to go modules recently and I can't seem to make pprof
recognize the source files.我最近切换到 go 模块,但似乎无法让
pprof
识别源文件。 Maybe someone here knows how to?也许这里有人知道怎么做?
I tried using the -source_path
and -trim_path
options but I can't figure it out how to make it work.我尝试使用
-source_path
和-trim_path
选项,但我不知道如何使它工作。
Interestingly, typing o
in the interactive mode of pprof
shows the the trim_path
option but not the source_path
.有趣的是,在
pprof
的交互模式下键入o
pprof
显示trim_path
选项,但不显示source_path
。
Just to be sure: pprof
does work with local modules and showing their sources in the stack traces, right?可以肯定的是:
pprof
确实与本地模块pprof
工作并在堆栈跟踪中显示它们的来源,对吗?
It does work, I just figured it out.它确实有效,我只是想通了。
You need to use both -trim_path
and -source_path
together.您需要同时使用
-trim_path
和-source_path
。
-source_path
should be set to the absolute path to your source code. -source_path
应设置为源代码的绝对路径。
-trim_path
should be set to the path that go tool pprof
is saying the code should be at. -trim_path
应该设置为go tool pprof
所说的代码应该在的路径。
So if pprof is saying the path does not exist at /abc/your/code/main.go
then set the trim path to /abc/your/code/
make sure that the -source_path
contains the main.go though.因此,如果 pprof 说 /abc/your/code/main.go 中不存在路径,
/abc/your/code/main.go
修剪路径设置为/abc/your/code/
确保-source_path
包含 main.go。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.