【问题标题】:`go tool pprof` - how to specify source when using go modules?`go tool pprof` - 使用 go 模块时如何指定源?
【发布时间】:2020-01-04 15:22:46
【问题描述】:

我最近切换到 go 模块,但我似乎无法让 pprof 识别源文件。也许这里有人知道怎么做?

我尝试使用 -source_path-trim_path 选项,但我不知道如何使它工作。

有趣的是,在pprof 的交互模式下输入o 会显示trim_path 选项,但不会显示source_path

请确定:pprof 确实适用于 local 模块并在堆栈跟踪中显示它们的源代码,对吗?

【问题讨论】:

    标签: go pprof


    【解决方案1】:

    它确实有效,我只是想通了。

    您需要同时使用-trim_path-source_path

    -source_path 应设置为源代码的绝对路径。

    -trim_path 应该设置为go tool pprof 所说的代码应该在的路径。

    因此,如果 pprof 说路径在 /abc/your/code/main.go 不存在,则将修剪路径设置为 /abc/your/code/ 确保 -source_path 包含 main.go。

    【讨论】:

      猜你喜欢
      • 2023-02-20
      • 2022-01-15
      • 2015-08-14
      • 2019-05-30
      • 2015-09-25
      • 1970-01-01
      • 2014-04-07
      • 2019-02-04
      • 2019-04-30
      相关资源
      最近更新 更多