Debug Kit: Restore support for symbol lookup by remote memory access.

It's been broken since clone_area was changed to block cloning of
areas without B_CLONEABLE_AREA set on them. We here introduce a
B_DEBUG_MESSAGE_CLONE_AREA debug nub message, which clones the areas
of the debugged team for the debugger.

Also fix some bugs in SymbolLookup::_FindLoadedImageAt methods:
they didn't work properly when *next was NULL, so they would
always fail when iterating over the full list.

Note that this technically breaks libdebug.so and the debugger
protocol ABI. However, nothing out-of-tree that I know of uses
the private libdebug.so, and while GDB does use the debugger
protocol, it doesn't actually use any of the messages past
the first block, so it should still work after this.

Fixes #15251.

Change-Id: I71ccbee4afd17dae30d5dacbc7590d1e2175a90e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8821
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2025-01-13 18:03:52 +00:00
committed by waddlesplash
parent 7105c3f66d
commit 2c9560581b
9 changed files with 134 additions and 41 deletions
+15 -1
View File
@@ -165,6 +165,7 @@ typedef enum {
B_DEBUG_MESSAGE_GET_SIGNAL_MASKS, // the debugger is interested in
B_DEBUG_MESSAGE_SET_SIGNAL_HANDLER, // set/get the team's signal handler for
B_DEBUG_MESSAGE_GET_SIGNAL_HANDLER, // a signal
B_DEBUG_MESSAGE_CLONE_AREA, // clone a team area into the debugger team
B_DEBUG_MESSAGE_PREPARE_HANDOVER, // prepares the debugged team for being
// handed over to another debugger;
@@ -174,7 +175,7 @@ typedef enum {
B_DEBUG_START_PROFILER, // start/stop sampling
B_DEBUG_STOP_PROFILER, //
B_DEBUG_WRITE_CORE_FILE // write a core file
B_DEBUG_WRITE_CORE_FILE, // write a core file
} debug_nub_message;
// messages sent to the debugger
@@ -254,6 +255,18 @@ typedef struct {
int32 size; // the number of bytes actually written
} debug_nub_write_memory_reply;
// B_DEBUG_MESSAGE_CLONE_AREA
typedef struct {
port_id reply_port; // port to send the reply to
const void *address; // address within area to clone
} debug_nub_clone_area;
typedef struct {
area_id area; // the ID of the newly cloned area, or an error
const void *address; // corresponding address in clone
} debug_nub_clone_area_reply;
// B_DEBUG_MESSAGE_SET_TEAM_FLAGS
typedef struct {
@@ -445,6 +458,7 @@ typedef struct {
typedef union {
debug_nub_read_memory read_memory;
debug_nub_write_memory write_memory;
debug_nub_clone_area clone_area;
debug_nub_set_team_flags set_team_flags;
debug_nub_set_thread_flags set_thread_flags;
debug_nub_continue_thread continue_thread;