On Wed, Mar 13, 2024 at 8:04 AM 'Grant Seltzer Richman' via golang-nuts <golang-nuts@googlegroups.com> wrote: > > I've been using the `Table.PCToLine` method to resolve program counters > (extracted via bpf) into functions with their file names and line numbers. > > It appears that this breaks when i'm testing it on a binary that has cgo > enabled. It does not fix it by compiling the binary statically. > > Another issue I have with this API is that creating the Table requires > passing the `.gosymtab` which of course is empty. Cgo binaries don't even > have it so I just pass an empty slice. > > Does anyone have alternatives to this package or possible explanations to why > these issues exist?
When using cgo the final executable is generated by the C linker. If that process uses -fpie, as is the default on some systems, PCToLine may not work. Have you tried using runtime.FuncForPC? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVL1om9vxqe0d3SHKg8L0J-Djp5VSxA%2BB-fEjWaWQNN0A%40mail.gmail.com.