diff --git a/pkg/proc/bininfo.go b/pkg/proc/bininfo.go index 3deafc67..9ade7bdc 100644 --- a/pkg/proc/bininfo.go +++ b/pkg/proc/bininfo.go @@ -1443,16 +1443,19 @@ func loadBinaryInfoElf(bi *BinaryInfo, image *Image, path string, addr uint64, w bi.loadBuildID(image, elfFile) var debugInfoBytes []byte - image.dwarf, err = elfFile.DWARF() - if err != nil { + var dwerr error + image.dwarf, dwerr = elfFile.DWARF() + if dwerr != nil { var sepFile *os.File var serr error sepFile, dwarfFile, serr = bi.openSeparateDebugInfo(image, elfFile, bi.DebugInfoDirectories) if serr != nil { - fmt.Fprintln(os.Stderr, "Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.") + if len(bi.Images) <= 1 { + fmt.Fprintln(os.Stderr, "Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.") + } symTable, err := readPcLnTableElf(elfFile, path) if err != nil { - return fmt.Errorf("could not create symbol table from %s ", path) + return fmt.Errorf("could not read debug info (%v) and could not read go symbol table (%v)", dwerr, err) } image.symTable = symTable for _, f := range image.symTable.Funcs { diff --git a/pkg/proc/pclntab.go b/pkg/proc/pclntab.go index 34515332..a2f23b94 100644 --- a/pkg/proc/pclntab.go +++ b/pkg/proc/pclntab.go @@ -61,10 +61,9 @@ func readPcLnTableElf(exe *elf.File, path string) (*gosym.Table, error) { // Find .gopclntab by magic number even if there is no section label magic := magicNumber(bi.GoVersion) pclntabIndex := bytes.Index(tableData, magic) - if pclntabIndex < 0 { - return nil, fmt.Errorf("could not find magic number in %s ", path) + if pclntabIndex >= 0 { + tableData = tableData[pclntabIndex:] } - tableData = tableData[pclntabIndex:] addr := exe.Section(".text").Addr lineTable := gosym.NewLineTable(tableData, addr) symTable, err := gosym.NewTable([]byte{}, lineTable) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index 10f7876d..6c5065fb 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -3169,6 +3169,7 @@ func TestDebugStripped(t *testing.T) { // Currently only implemented for Linux ELF executables. // TODO(derekparker): Add support for Mach-O and PE. skipUnlessOn(t, "linux only", "linux") + skipOn(t, "does not work with PIE", "pie") withTestProcessArgs("testnextprog", t, "", []string{}, protest.LinkStrip, func(p *proc.Target, grp *proc.TargetGroup, f protest.Fixture) { setFunctionBreakpoint(p, t, "main.main") assertNoError(grp.Continue(), t, "Continue")