Page MenuHomeFreeBSD

arm64: gdb(4) stub
ClosedPublic

Authored by mhorne on Dec 22 2020, 6:00 PM.

Details

Summary

This adds the basic support required for debugging with gdb over remote serial protocol.

Includes register read/write for general purpose and status registers, but not floating point registers at this time.

The GDB register numbers are defined here: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/arch/aarch64.h;h=b75352461a412e74aa8e397507ff76a1824de1c7;hb=HEAD

Test Plan

Tested most common usage patterns, including: backtraces, listing/switching threads, setting breakpoints, inspecting/modifying kernel memory.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mhorne retitled this revision from Summary: to arm64: gdb(4) stub.Dec 22 2020, 6:06 PM
mhorne edited the summary of this revision. (Show Details)
mhorne edited the test plan for this revision. (Show Details)
mhorne added reviewers: andrew, arm64.
mhorne removed a subscriber: Contributor Reviews (base).

I will be on holiday for the next couple weeks, but posting this now in case anyone wants to look it over during that time. No rush to review.

jhb added a subscriber: jhb.

Adding @stevek as he is interested in this area.

An FYI rather than a review: I'm using these patches successfully on my RPi4, and it's proving invaluable. I'm eager to see these committed back to the main tree as soon as everyone feels ready.

sys/conf/files.arm64
170

We ought to move this to generic sys/conf/files

sys/arm64/arm64/gdb_machdep.c
77

Maybe worth a comment about updating both kdb_frame and the thrctx?

sys/conf/files.arm64
170

How do you mean? Currently it is no different than other machdep files and should only be included here.

sys/conf/files.arm64
170

Oh yes, ignore that comment :)

sys/arm64/arm64/gdb_machdep.c
53–56

I find some of these hard to follow when they are all on one line.

61

Does this work in gdb or does it show duplicate stack frames?

sys/arm64/include/gdb_machdep.h
77

Duplicate

81

Duplicate

sys/arm64/arm64/gdb_machdep.c
53–56

I agree, this style is a little odd but is used in other gdb_machdep implementations. I'm not attached to it however.

Do you find it any better if they were aligned like this?

61

It does work in gdb without duplicates. I believe the reason is that cpu_switch(), where the PC actually is for sleeping threads, doesn't construct a new stack frame.

For stopped threads, the same is true of savectx(), called in ipi_stop().

Remove duplicate function prototypes. Small changes to formatting and comments.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 8 2021, 6:54 PM
This revision was automatically updated to reflect the committed changes.