Page MenuHomeFreeBSD

arm64: gdb(4) stub
ClosedPublic

Authored by mhorne on Dec 22 2020, 6:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 19, 7:57 AM
Unknown Object (File)
Sep 24 2024, 7:59 PM
Unknown Object (File)
Sep 12 2024, 5:31 AM
Unknown Object (File)
Sep 5 2024, 5:02 AM
Unknown Object (File)
Aug 29 2024, 5:41 AM
Unknown Object (File)
Aug 17 2024, 6:39 PM
Unknown Object (File)
Aug 12 2024, 3:19 PM
Unknown Object (File)
Aug 9 2024, 12:02 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.