dongwo2772 2017-01-05 15:48
浏览 213
已采纳

找出谁启动了goroutine(pprof)

When examining the output of pprof I can see the stacktrace of a goroutine. However I'd like to know who started (spawned?) this goroutine, is this possible?

  • 写回答

1条回答 默认 最新

  • donglvmang8638 2017-01-05 17:51
    关注

    If you look at the endpoint /debug/pprof/goroutine?debug=2 you get a slightly different output for the stack traces:

    goroutine 859579 [running]:
    runtime/pprof.writeGoroutineStacks(0x176a0e0, 0xc43403a340, 0x178d740, 0x30)
        /usr/local/go/src/runtime/pprof/pprof.go:585 +0x79
    runtime/pprof.writeGoroutine(0x176a0e0, 0xc43403a340, 0x2, 0x0, 0xd)
        /usr/local/go/src/runtime/pprof/pprof.go:574 +0x44
    runtime/pprof.(*Profile).WriteTo(0x178f9e0, 0x176a0e0, 0xc43403a340, 0x2, 0xc43403a340, 0xc4587b5834)
        /usr/local/go/src/runtime/pprof/pprof.go:298 +0x341
    net/http/pprof.handler.ServeHTTP(0xc4587b5841, 0x9, 0x1771320, 0xc43403a340, 0xc49a7093b0)
        /usr/local/go/src/net/http/pprof/pprof.go:209 +0x1a6
    net/http/pprof.Index(0x1771320, 0xc43403a340, 0xc49a7093b0)
        /usr/local/go/src/net/http/pprof/pprof.go:221 +0x205
    net/http.HandlerFunc.ServeHTTP(0x12664a8, 0x1771320, 0xc43403a340, 0xc49a7093b0)
        /usr/local/go/src/net/http/server.go:1726 +0x44
    net/http.(*ServeMux).ServeHTTP(0x179dde0, 0x1771320, 0xc43403a340, 0xc49a7093b0)
        /usr/local/go/src/net/http/server.go:2022 +0x7f
    net/http.serverHandler.ServeHTTP(0xc46d06ed80, 0x1771320, 0xc43403a340, 0xc49a7093b0)
        /usr/local/go/src/net/http/server.go:2202 +0x7d
    net/http.(*conn).serve(0xc45dc83180, 0x17734a0, 0xc4942f0600)
        /usr/local/go/src/net/http/server.go:1579 +0x4b7
    created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2293 +0x44d
    

    That include the created by line at the end.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计