proc/gdbserial: add logging when Thread.Location will fail (#1937)

Add logging for Issue #1927. The bug happens during the call to
api.ConvertThread, returning an error will not suffice since
ConvertThread will not surface it.

Updates #1927
This commit is contained in:
Alessandro Arzilli 2020-03-19 20:28:27 +01:00 committed by GitHub
parent e1cfd72795
commit 0cfd52787f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1267,6 +1267,11 @@ func (t *Thread) Location() (*proc.Location, error) {
if err != nil {
return nil, err
}
if pcreg, ok := regs.(*gdbRegisters).regs[regnamePC]; !ok {
t.p.conn.log.Errorf("thread %d could not find RIP register", t.ID)
} else if len(pcreg.value) < t.p.bi.Arch.PtrSize() {
t.p.conn.log.Errorf("thread %d bad length for RIP register: %d", t.ID, len(pcreg.value))
}
pc := regs.PC()
f, l, fn := t.p.bi.PCToLine(pc)
return &proc.Location{PC: pc, File: f, Line: l, Fn: fn}, nil