jemalloc not showing line numbers of go code with cgo

255 views Asked by At

I am using jemalloc using cgo in Go. I also want to get the heap profiles. Currently, I am getting the profiles, but it does not show the corresponding go code.

package main

/*
#cgo LDFLAGS: /usr/local/lib/libjemalloc.a -L/usr/local/lib -Wl,-rpath,/usr/local/lib -ljemalloc -lm -lstdc++ -pthread -ldl
#include <stdlib.h>
#include <jemalloc/jemalloc.h>
*/
import "C"
import (
    "unsafe"
)

func main() {
    _ = C.je_calloc(C.size_t(100<<20), 1)
    opt := C.CString("prof.dump")
    defer C.free(unsafe.Pointer(opt))
    C.je_mallctl(opt, nil, nil, nil, 0)
}

If I build it using go build example.go and then see the profile using jeprof ./example test.349341.0.m0.heap --lines, I get this output on doing top.

Total: 112.0 MB
   112.0 100.0% 100.0%    112.0 100.0% _cgo_16ec00d2dd82_Cfunc_je_calloc /tmp/go-build/cgo-gcc-prolog:65
     0.0   0.0% 100.0%    112.0 100.0% runtime.asmcgocall /usr/local/go/src/runtime/asm_amd64.s:655

What is the correct way to get the lines from the corresponding go code? Thanks in advance.

0

There are 0 answers