[Lldb-commits] [lldb] 3c32695 - [lldb] [gdb-remote client] Avoid zero padding PID/TID in H packet
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 26 15:44:52 PDT 2021
Author: Michał Górny
Date: 2021-07-27T00:44:43+02:00
New Revision: 3c3269559ba9400224400b96c22b31812638de52
URL: https://github.com/llvm/llvm-project/commit/3c3269559ba9400224400b96c22b31812638de52
DIFF: https://github.com/llvm/llvm-project/commit/3c3269559ba9400224400b96c22b31812638de52.diff
LOG: [lldb] [gdb-remote client] Avoid zero padding PID/TID in H packet
Change SetCurrentThread*() logic not to include the zero padding
in PID/TID that was a side effect of 02ef0f5ab483. This should fix
problems caused by sending 64-bit integers to 32-bit servers. Reported
by Ted Woodward.
Differential Revision: https://reviews.llvm.org/D106832
Added:
Modified:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index a07a3f91c0c88..5e80317d5327c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2639,16 +2639,13 @@ GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(uint64_t tid,
packet.PutChar('H');
packet.PutChar(op);
- if (pid != LLDB_INVALID_PROCESS_ID) {
- packet.PutChar('p');
- packet.PutHex64(pid);
- packet.PutChar('.');
- }
+ if (pid != LLDB_INVALID_PROCESS_ID)
+ packet.Printf("p%" PRIx64 ".", pid);
if (tid == UINT64_MAX)
packet.PutCString("-1");
else
- packet.PutHex64(tid);
+ packet.Printf("%" PRIx64, tid);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response)
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 781809297990a..07733962738c3 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -98,7 +98,7 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteRegisterNoSuffix) {
});
Handle_QThreadSuffixSupported(server, false);
- HandlePacket(server, "Hg0000000000000047", "OK");
+ HandlePacket(server, "Hg47", "OK");
HandlePacket(server, "P4=" + one_register_hex, "OK");
ASSERT_TRUE(write_result.get());
@@ -143,7 +143,7 @@ TEST_F(GDBRemoteCommunicationClientTest, SaveRestoreRegistersNoSuffix) {
return client.SaveRegisterState(tid, save_id);
});
Handle_QThreadSuffixSupported(server, false);
- HandlePacket(server, "Hg0000000000000047", "OK");
+ HandlePacket(server, "Hg47", "OK");
HandlePacket(server, "QSaveRegisterState", "1");
ASSERT_TRUE(async_result.get());
EXPECT_EQ(1u, save_id);
More information about the lldb-commits
mailing list