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