kkcode0 created this revision.
Herald added a project: All.
kkcode0 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143698
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Thread.cpp
Index: lldb/source/Target/Thread.cpp
===================================================================
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1647,7 +1647,6 @@
void Thread::SettingsTerminate() {}
lldb::addr_t Thread::GetThreadPointer() {
- auto tid = this->GetProtocolID();
RegisterContext *reg_ctx = this->GetRegisterContext().get();
auto tp = reg_ctx->GetThreadPointer();
return tp;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1497,10 +1497,6 @@
num_thread_ids = m_thread_ids.size();
}
- for(auto& tid: m_thread_ids) {
- (void)m_gdb_comm.GetQGetTLSAddr(tid, 0, 0);
- }
-
ThreadList old_thread_list_copy(old_thread_list);
if (num_thread_ids > 0) {
for (size_t i = 0; i < num_thread_ids; ++i) {
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -89,7 +89,8 @@
GDBRemoteCommunicationClient &gdb_comm(
((ProcessGDBRemote *)process)->GetGDBRemote());
uint64_t tid = thread->GetProtocolID();
- return gdb_comm.GetQGetTLSAddr(tid);
+ // Return thread pointer here, offset and link_map will be filled by GetThreadLocalData in DYLD
+ return gdb_comm.GetQGetTLSAddr(tid, LLDB_INVALID_ADDRESS /* offset */, LLDB_INVALID_ADDRESS /* lm */);
}
bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info,
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -2121,14 +2121,16 @@
return SendErrorResponse(8);
llvm::SmallVector<llvm::StringRef, 16> argv;
s.split(argv, ',');
- lldb::tid_t tid = StringExtractor(argv[0]).GetU64(0, 16);
- NativeThreadProtocol* ntp= m_current_process->GetThreadByID(tid);
+ lldb::tid_t tid = StringExtractor(argv[0]).GetU64(LLDB_INVALID_ADDRESS, 16);
+ lldb::addr_t offset = StringExtractor(argv[1]).GetU64(LLDB_INVALID_ADDRESS, 16);
+ lldb::addr_t lm = StringExtractor(argv[2]).GetU64(LLDB_INVALID_ADDRESS, 16);
+ NativeThreadProtocol *ntp = m_current_process->GetThreadByID(tid);
NativeRegisterContext ®_ctx = ntp->GetRegisterContext();
lldb::addr_t tls_addr = LLDB_INVALID_ADDRESS;
StreamGDBRemote response;
if(!reg_ctx.ReadThreadPointer(tls_addr).Fail()) {
response.PutHex64(tls_addr, lldb::eByteOrderBig);
- return SendPacketNoLock(response.GetString());
+ return SendPacketNoLock(response.GetString());
} else
return SendErrorResponse(8);
}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -446,9 +446,7 @@
/// one value in the offsets field.
llvm::Optional<QOffsets> GetQOffsets();
- bool GetQGetTLSAddr(lldb::tid_t tid, lldb::addr_t offset, lldb::addr_t lms);
-
- lldb::addr_t GetQGetTLSAddr(lldb::tid_t tid);
+ lldb::addr_t GetQGetTLSAddr(lldb::tid_t tid, lldb::addr_t offset, lldb::addr_t lms);
bool GetModuleInfo(const FileSpec &module_file_spec,
const ArchSpec &arch_spec, ModuleSpec &module_spec);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -3759,14 +3759,7 @@
return std::nullopt;
}
-std::unordered_map<lldb::tid_t, lldb::addr_t> tid_to_tp;
-lldb::addr_t GDBRemoteCommunicationClient::GetQGetTLSAddr(lldb::tid_t tid) {
- if (tid_to_tp.count(tid))
- return tid_to_tp[tid];
- return -1;
-}
-
-bool GDBRemoteCommunicationClient::GetQGetTLSAddr(lldb::tid_t tid, lldb::addr_t offset, lldb::addr_t lm) {
+lldb::addr_t GDBRemoteCommunicationClient::GetQGetTLSAddr(lldb::tid_t tid, lldb::addr_t offset, lldb::addr_t lm) {
StreamString packet;
packet.PutCString("qGetTLSAddr:");
packet.PutHex64(tid, lldb::eByteOrderBig);
@@ -3777,18 +3770,15 @@
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response) !=
PacketResult::Success)
- return false;
+ return LLDB_INVALID_ADDRESS;
if (response.IsErrorResponse())
- return false;
+ return LLDB_INVALID_ADDRESS;
if (response.IsUnsupportedResponse())
- return false;
- llvm::StringRef ref = response.GetStringRef();
- uint64_t addr=-1;
- ref.consumeInteger(16, addr);
- Log *log(GetLog(GDBRLog::Process | GDBRLog::Packets));
- LLDB_LOG(log, "here is tls addrkamlesh:%s",ref.str().c_str());
- tid_to_tp[tid] = addr;// std::stoull(ref.str());
- return true;
+ return LLDB_INVALID_ADDRESS;
+ llvm::StringRef ref = response.GetStringRef();
+ uint64_t addr = LLDB_INVALID_ADDRESS;
+ ref.consumeInteger(16, addr);
+ return addr;
}
bool GDBRemoteCommunicationClient::GetModuleInfo(
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits