pkg/proc: enable basic debug functionality for stripped ELF binaries (#3408)

We used to parse the .gopclntab section but removed support in favor of
simply using DWARF debug information, due to lack of C symbols among
other reasons. This makes it impossible to debug stripped binaries,
which some distrubutions ship by default.

Add back in basic support for .gopclntab which survives if the binary
is stripped, allowing for rudimentary debugging such as basic
program navigation, tracing, etc...
This commit is contained in:
Derek Parker
2023-06-14 04:23:46 -07:00
committed by GitHub
parent 7d8f47674b
commit ccf17a6f42
11 changed files with 184 additions and 186 deletions

View File

@ -535,7 +535,7 @@ func (g *G) StartLoc(tgt *Target) Location {
if fn == nil {
return Location{PC: g.StartPC}
}
f, l := fn.cu.lineInfo.PCToLine(fn.Entry, fn.Entry)
f, l := tgt.BinInfo().EntryLineForFunc(fn)
return Location{PC: fn.Entry, File: f, Line: l, Fn: fn}
}