dwarf/frame: handle unknown opcodes more gracefully (#4037)

Instead of panic'ing on unknown opcodes (there are a few around which
gdb handles) report an error and continue as if the FDE did not exist.

Fixes #4035
This commit is contained in:
Alessandro Arzilli
2025-06-25 19:12:20 +02:00
committed by GitHub
parent 50a45f1b07
commit 26806dcaf3
3 changed files with 25 additions and 12 deletions

View File

@ -508,16 +508,20 @@ func (it *stackIterator) appendInlineCalls(callback func(Stackframe) bool, frame
// it.regs.CFA; the caller has to eventually switch it.regs when the iterator
// advances to the next frame.
func (it *stackIterator) advanceRegs() (callFrameRegs op.DwarfRegisters, ret uint64, retaddr uint64) {
logger := logflags.StackLogger()
fde, err := it.bi.frameEntries.FDEForPC(it.pc)
var framectx *frame.FrameContext
if _, nofde := err.(*frame.ErrNoFDEForPC); nofde {
framectx = it.bi.Arch.fixFrameUnwindContext(nil, it.pc, it.bi)
} else {
framectx = it.bi.Arch.fixFrameUnwindContext(fde.EstablishFrame(it.pc), it.pc, it.bi)
fctxt, err := fde.EstablishFrame(it.pc)
if err != nil {
logger.Errorf("Error executing Frame Debug Entry for PC %x: %v", it.pc, err)
}
framectx = it.bi.Arch.fixFrameUnwindContext(fctxt, it.pc, it.bi)
}
logger := logflags.StackLogger()
logger.Debugf("advanceRegs at %#x", it.pc)
cfareg, err := it.executeFrameRegRule(0, framectx.CFA, 0)