Page MenuHomeFreeBSD

Fix KGDB backtrace on ARM
ClosedPublic

Authored by wma on Apr 15 2016, 11:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 8:11 AM
Unknown Object (File)
Wed, Apr 17, 8:08 AM
Unknown Object (File)
Feb 15 2024, 1:18 AM
Unknown Object (File)
Dec 20 2023, 1:52 AM
Unknown Object (File)
Dec 15 2023, 11:38 AM
Unknown Object (File)
Dec 14 2023, 2:16 AM
Unknown Object (File)
Nov 25 2023, 11:22 AM
Unknown Object (File)
Nov 24 2023, 11:24 PM
Subscribers

Details

Summary
Modify trapframe decoding to properly analyze trapframe.

Provide method for fixup_pc. It happens, that in some kernel
functions, the GDB stack frame decoder cannot determine both
func name and frame size. This is because these functions
either contain invalid instruction, or their format does
not match standard schema. Detect that scenarios and move
PC accordingly to jump into known function schema, which
GDB is able to parse.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

wma retitled this revision from to Fix KGDB backtrace on ARM.
wma updated this object.
wma edited the test plan for this revision. (Show Details)
wma added reviewers: imp, zbb, ian, jhb, kib.
wma set the repository for this revision to rS FreeBSD src repository - subversion.

Did you tried to upstream this, or at least add the patch to jhb' collection of the pending gdb patches.

In-tree gdb probably have not a bright future, unfortunately.

gnu/usr.bin/gdb/kgdb/trgt_arm.c
275 ↗(On Diff #15257)

A comment about mask/value of the bits should be made. In fact, I do not understand why do you exclude bits 29 and 27 from the comparision. What is the instruction set which you are trying to catch there ?

No, I didn't try to upstream this by any means. It's just some KGDB hacks and I'm not sure if these are generic enough to be pushed into GDB core.

gnu/usr.bin/gdb/kgdb/trgt_arm.c
275 ↗(On Diff #15257)

Sure, I'll add a comment. Basically, I want to match a non-linked branch instruction. It seems I should mask it with 0xfa000000, thanks.

gnu/usr.bin/gdb/kgdb/trgt_arm.c
275 ↗(On Diff #15257)

I still do not understand the mask. According to the table "A5-21 Branch, branch with link, and block data transfer instructions", the cond must be 0xf, bits 27-26 must have the values "1 0", and the op is 10xxxx. For me, it sounds as if the mask must be 0xff000000, what I miss ?

wma edited edge metadata.
wma added inline comments.
gnu/usr.bin/gdb/kgdb/trgt_arm.c
275 ↗(On Diff #15257)

No, you're absolutelt right. Im just dumb :) Fixed the mask as it should be, thanks.

gnu/usr.bin/gdb/kgdb/trgt_arm.c
290 ↗(On Diff #15333)

But isn't cond always 0xf for the branch and link instruction ? I.e., why do you compare with 0xEa000000, and not with 0xfa000000 ?

gnu/usr.bin/gdb/kgdb/trgt_arm.c
290 ↗(On Diff #15333)

The cond 0xf is rsvd as per documentation. The "always" condition is 0xe, so that's the case here. See a dump below:

Disasm:
0xc1188198 <panic+28>: str r1, [sp]
(kgdb)
0xc118819c <panic+32>: mov lr, pc
(kgdb)
0xc11881a0 <panic+36>: b 0xc11881a4 <vpanic>
(kgdb)
0xc11881a4 <vpanic>: push {r4, r5, r6, r7, r8, r9, r11, lr}
(kgdb)
0xc11881a8 <vpanic+4>: add r11, sp, #24 ; 0x18

Memory dump:
0xc1188198 <panic+28>: 0xe58d1000
(kgdb)
0xc118819c <panic+32>: 0xe1a0e00f
(kgdb)
0xc11881a0 <panic+36>: 0xeaffffff
(kgdb)
0xc11881a4 <vpanic>: 0xe92d4bf0
(kgdb)
0xc11881a8 <vpanic+4>: 0xe28db018

Applied wrong patch last time.

zbb edited edge metadata.
This revision is now accepted and ready to land.Apr 20 2016, 5:48 PM
This revision was automatically updated to reflect the committed changes.