sigprofNonGo() and sigprofNonGoPC() in go runtime

49 views
Skip to first unread message

p...@uber.com

unread,
Jun 27, 2019, 2:14:02 AM6/27/19
to golang-nuts
Hi folks,

I am wondering when and how sigprofNonGo() and sigprofNonGoPC() are invoked during pprof CPU profiling (pprof.StartCPUProfile(...)). I had thought they would be invoked when user C code (invoked via cgo) is being profiled? But in my experiments, it never happened.

Best

Ian Lance Taylor

unread,
Jun 27, 2019, 2:28:31 AM6/27/19
to p...@uber.com, golang-nuts
On Wed, Jun 26, 2019 at 11:13 PM psu via golang-nuts
<golan...@googlegroups.com> wrote:
>
> I am wondering when and how sigprofNonGo() and sigprofNonGoPC() are invoked during pprof CPU profiling (pprof.StartCPUProfile(...)). I had thought they would be invoked when user C code (invoked via cgo) is being profiled? But in my experiments, it never happened.

The two functions are only used if a SIGPROF arrives for a thread that
was started by C that is running C code. So you will only see them if
your C code starts new threads. For a thread that was started by Go
the profiler will normally record just the Go stack trace. If you
want to collect a C traceback in addition to the Go traceback you can
call runtime.SetCgoTraceback (only supported on amd64 running Darwin
or FreeBSD or GNU/Linux); the easiest way to do that is to import
github.com/ianlancetaylor/cgosymbolizer (completely unsupported but it
usually works).

Ian
Reply all
Reply to author
Forward
0 new messages