https://github.com/xusheng6 updated https://github.com/llvm/llvm-project/pull/102873
>From 73c98df4baef99f96d9c67113ba2ed0d972e5a04 Mon Sep 17 00:00:00 2001 From: Xusheng <xush...@vector35.com> Date: Mon, 20 Mar 2023 20:24:11 +0800 Subject: [PATCH 1/3] [lldb] Claim to support swbreak and hwbreak packets when debugging a gdbremote --- .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 2 +- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 74e392249a94eb..d8b17a8ff59baf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -353,7 +353,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { // build the qSupported packet std::vector<std::string> features = {"xmlRegisters=i386,arm,mips,arc", "multiprocess+", "fork-events+", - "vfork-events+"}; + "vfork-events+", "swbreak+", "hwbreak+"}; StreamString packet; packet.PutCString("qSupported"); for (uint32_t i = 0; i < features.size(); ++i) { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 6f9c2cc1e4b4e8..b8fe8fdc9b8742 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2349,6 +2349,9 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { if (!value.getAsInteger(0, addressing_bits)) { addressable_bits.SetHighmemAddressableBits(addressing_bits); } + } else if (key.compare("swbreak") == 0 || key.compare("hwbreak") == 0) { + // There is nothing needs to be done for swbreak or hwbreak since + // the value is expected to be empty } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = UINT32_MAX; if (!key.getAsInteger(16, reg)) >From 1db7c14528bb709921a0d6607c2118477c8de500 Mon Sep 17 00:00:00 2001 From: Xusheng <xush...@vector35.com> Date: Mon, 12 Aug 2024 18:37:40 +0800 Subject: [PATCH 2/3] Fix format --- .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index d8b17a8ff59baf..83ba27783da471 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -352,8 +352,11 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { // build the qSupported packet std::vector<std::string> features = {"xmlRegisters=i386,arm,mips,arc", - "multiprocess+", "fork-events+", - "vfork-events+", "swbreak+", "hwbreak+"}; + "multiprocess+", + "fork-events+", + "vfork-events+", + "swbreak+", + "hwbreak+"}; StreamString packet; packet.PutCString("qSupported"); for (uint32_t i = 0; i < features.size(); ++i) { >From 2d085e46c50f1c909ce5b90dd34d6c47832564d0 Mon Sep 17 00:00:00 2001 From: Xusheng <xush...@vector35.com> Date: Mon, 12 Aug 2024 18:43:36 +0800 Subject: [PATCH 3/3] Put the condition as the last one and update comment --- .../source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index b8fe8fdc9b8742..e467577ab2b4f0 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2349,13 +2349,14 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) { if (!value.getAsInteger(0, addressing_bits)) { addressable_bits.SetHighmemAddressableBits(addressing_bits); } - } else if (key.compare("swbreak") == 0 || key.compare("hwbreak") == 0) { - // There is nothing needs to be done for swbreak or hwbreak since - // the value is expected to be empty } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) { uint32_t reg = UINT32_MAX; if (!key.getAsInteger(16, reg)) expedited_register_map[reg] = std::string(std::move(value)); + } else if (key.compare("swbreak") == 0 || key.compare("hwbreak") == 0) { + // 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) } } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits