[lldb] [gdb-remote client] Refactor SetCurrentThread*()
authorMichał Górny <mgorny@moritz.systems>
Wed, 14 Apr 2021 09:56:09 +0000 (11:56 +0200)
committerMichał Górny <mgorny@moritz.systems>
Fri, 2 Jul 2021 12:36:17 +0000 (14:36 +0200)
commit02ef0f5ab483875b7b6b38e24b245e4fd4053959
tree15c7dddea23d10ff4821633cb9acafe52978d9e6
parentcdca1785d35f41ef154d7271bf97c4d1d0e69995
[lldb] [gdb-remote client] Refactor SetCurrentThread*()

Refactor SetCurrentThread() and SetCurrentThreadForRun() to reduce code
duplication and simplify it.  Both methods now call common
SendSetCurrentThreadPacket() that implements the common protocol
exchange part (the only variable is sending `Hg` vs `Hc`) and returns
the selected TID.  The logic is rewritten to use a StreamString
instead of snprintf().

A side effect of the change is that thread-id sent is now zero-padded.
However, this should not have practical impact on the server as both
forms are equivalent.

Differential Revision: https://reviews.llvm.org/D100459
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp