diff options
author | xusheng <xusheng@vector35.com> | 2024-08-13 22:28:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-13 15:28:35 +0100 |
commit | 5dbec8c6ce473352cac2d89d6a5b81f65182df59 (patch) | |
tree | d5a1a45efb483641d2591c074c2bf826b66b3b46 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | 40897638837fdc5d64d8932fd892f3b9a687ee84 (diff) | |
download | llvm-5dbec8c6ce473352cac2d89d6a5b81f65182df59.zip llvm-5dbec8c6ce473352cac2d89d6a5b81f65182df59.tar.gz llvm-5dbec8c6ce473352cac2d89d6a5b81f65182df59.tar.bz2 |
[lldb] Claim to support swbreak and hwbreak packets when debugging a gdbremote (#102873)
This fixes https://github.com/llvm/llvm-project/issues/56125 and
https://github.com/vadimcn/codelldb/issues/666, as well as the
downstream issue in our binary ninja debugger:
https://github.com/Vector35/debugger/issues/535
Basically, lldb does not claim to support the `swbreak` packet so the
gdbserver would not use it. As a result, the gdbserver always sends the
unmodified program counter value which, on systems like x86, causes the
program counter to be off-by-one (or otherwise wrong). For reference,
the lldb-server always sends the modified program counter value so it
works perfectly with lldb.
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Stop-Reply-Packets.html#swbreak-stop-reason
No new code is added to add support `swbreak`, since the way lldb works
already expects the remote to have adjusted the program counter. The
change just lets the gdbserver know that lldb supports it, so that it
will send the adjusted program counter.
To test this PR, you can use lldb to connect to a gdbserver running on
e.g., Ubuntu 22.04, and see the program counter is off-by-one without
the patch. With the patch, things work as expected
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 6f9c2cc..c7ce368 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2354,6 +2354,9 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { if (!key.getAsInteger(16, reg)) expedited_register_map[reg] = std::string(std::move(value)); } + // swbreak and hwbreak are also expected keys, but we don't need to + // change our behaviour for them because lldb always expects the remote + // to adjust the program counter (if relevant, e.g., for x86 targets) } if (stop_pid != LLDB_INVALID_PROCESS_ID && stop_pid != pid) { |