Page MenuHomeFreeBSD

arm64: gdb(4) stub
ClosedPublic

Authored by mhorne on Dec 22 2020, 6:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 10:46 PM
Unknown Object (File)
Mon, Apr 8, 11:07 PM
Unknown Object (File)
Sun, Apr 7, 11:02 PM
Unknown Object (File)
Mon, Apr 1, 4:45 PM
Unknown Object (File)
Mar 15 2024, 7:03 PM
Unknown Object (File)
Feb 10 2024, 2:31 AM
Unknown Object (File)
Dec 22 2023, 10:45 PM
Unknown Object (File)
Dec 12 2023, 2:17 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
rG FreeBSD src repository
Lint
Lint Not Applicable
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 (src).

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
171

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

sys/arm64/arm64/gdb_machdep.c
78

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

sys/conf/files.arm64
171

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

sys/conf/files.arm64
171

Oh yes, ignore that comment :)

sys/arm64/arm64/gdb_machdep.c
54–57

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

62

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

sys/arm64/include/gdb_machdep.h
78

Duplicate

82

Duplicate

sys/arm64/arm64/gdb_machdep.c
54–57

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?

62

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.