Skip to content

Commit db223b7

Browse files
committed
Do qProcessInfo-hint binary loading later in Process setup
The remote stub may give lldb hints about binaries to be loaded, especially in a firmware type environment, and relay those hints in the qProcessInfo response. The binary loading was done very early in Process setup, before we had any threads, and this made it complicated for people to write dSYM python scripts which need access to a thread. Delay the binary loading until a bit later in the Process startup. Differential Revision: https://reviews.llvm.org/D141972 rdar://104235301
1 parent 5d98dc7 commit db223b7

File tree

2 files changed

+57
-52
lines changed

2 files changed

+57
-52
lines changed

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -555,58 +555,6 @@ Status ProcessGDBRemote::DoConnectRemote(llvm::StringRef remote_url) {
555555
}
556556
}
557557

558-
// The remote stub may know about the "main binary" in
559-
// the context of a firmware debug session, and can
560-
// give us a UUID and an address/slide of where the
561-
// binary is loaded in memory.
562-
UUID standalone_uuid;
563-
addr_t standalone_value;
564-
bool standalone_value_is_offset;
565-
if (m_gdb_comm.GetProcessStandaloneBinary(
566-
standalone_uuid, standalone_value, standalone_value_is_offset)) {
567-
ModuleSP module_sp;
568-
569-
if (standalone_uuid.IsValid()) {
570-
const bool force_symbol_search = true;
571-
const bool notify = true;
572-
DynamicLoader::LoadBinaryWithUUIDAndAddress(
573-
this, llvm::StringRef(), standalone_uuid, standalone_value,
574-
standalone_value_is_offset, force_symbol_search, notify);
575-
}
576-
}
577-
578-
// The remote stub may know about a list of binaries to
579-
// force load into the process -- a firmware type situation
580-
// where multiple binaries are present in virtual memory,
581-
// and we are only given the addresses of the binaries.
582-
// Not intended for use with userland debugging when we
583-
// a DynamicLoader plugin that knows how to find the loaded
584-
// binaries and will track updates as binaries are added.
585-
586-
std::vector<addr_t> bin_addrs = m_gdb_comm.GetProcessStandaloneBinaries();
587-
if (bin_addrs.size()) {
588-
UUID uuid;
589-
const bool value_is_slide = false;
590-
for (addr_t addr : bin_addrs) {
591-
const bool notify = true;
592-
// First see if this is a special platform
593-
// binary that may determine the DynamicLoader and
594-
// Platform to be used in this Process/Target in the
595-
// process of loading it.
596-
if (GetTarget()
597-
.GetDebugger()
598-
.GetPlatformList()
599-
.LoadPlatformBinaryAndSetup(this, addr, notify))
600-
continue;
601-
602-
const bool force_symbol_search = true;
603-
// Second manually load this binary into the Target.
604-
DynamicLoader::LoadBinaryWithUUIDAndAddress(
605-
this, llvm::StringRef(), uuid, addr, value_is_slide,
606-
force_symbol_search, notify);
607-
}
608-
}
609-
610558
const StateType state = SetThreadStopInfo(response);
611559
if (state != eStateInvalid) {
612560
SetPrivateState(state);
@@ -1007,6 +955,9 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
1007955
}
1008956
}
1009957

958+
// Target and Process are reasonably initailized;
959+
// load any binaries we have metadata for / set load address.
960+
LoadStubBinaries();
1010961
MaybeLoadExecutableModule();
1011962

1012963
// Find out which StructuredDataPlugins are supported by the debug monitor.
@@ -1028,6 +979,59 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
1028979
}
1029980
}
1030981

982+
void ProcessGDBRemote::LoadStubBinaries() {
983+
// The remote stub may know about the "main binary" in
984+
// the context of a firmware debug session, and can
985+
// give us a UUID and an address/slide of where the
986+
// binary is loaded in memory.
987+
UUID standalone_uuid;
988+
addr_t standalone_value;
989+
bool standalone_value_is_offset;
990+
if (m_gdb_comm.GetProcessStandaloneBinary(standalone_uuid, standalone_value,
991+
standalone_value_is_offset)) {
992+
ModuleSP module_sp;
993+
994+
if (standalone_uuid.IsValid()) {
995+
const bool force_symbol_search = true;
996+
const bool notify = true;
997+
DynamicLoader::LoadBinaryWithUUIDAndAddress(
998+
this, "", standalone_uuid, standalone_value,
999+
standalone_value_is_offset, force_symbol_search, notify);
1000+
}
1001+
}
1002+
1003+
// The remote stub may know about a list of binaries to
1004+
// force load into the process -- a firmware type situation
1005+
// where multiple binaries are present in virtual memory,
1006+
// and we are only given the addresses of the binaries.
1007+
// Not intended for use with userland debugging, when we use
1008+
// a DynamicLoader plugin that knows how to find the loaded
1009+
// binaries, and will track updates as binaries are added.
1010+
1011+
std::vector<addr_t> bin_addrs = m_gdb_comm.GetProcessStandaloneBinaries();
1012+
if (bin_addrs.size()) {
1013+
UUID uuid;
1014+
const bool value_is_slide = false;
1015+
for (addr_t addr : bin_addrs) {
1016+
const bool notify = true;
1017+
// First see if this is a special platform
1018+
// binary that may determine the DynamicLoader and
1019+
// Platform to be used in this Process and Target.
1020+
if (GetTarget()
1021+
.GetDebugger()
1022+
.GetPlatformList()
1023+
.LoadPlatformBinaryAndSetup(this, addr, notify))
1024+
continue;
1025+
1026+
const bool force_symbol_search = true;
1027+
// Second manually load this binary into the Target.
1028+
DynamicLoader::LoadBinaryWithUUIDAndAddress(this, llvm::StringRef(), uuid,
1029+
addr, value_is_slide,
1030+
force_symbol_search, notify);
1031+
}
1032+
}
1033+
}
1034+
10311035
void ProcessGDBRemote::MaybeLoadExecutableModule() {
10321036
ModuleSP module_sp = GetTarget().GetExecutableModule();
10331037
if (!module_sp)

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ class ProcessGDBRemote : public Process,
374374
bool UpdateThreadIDList();
375375

376376
void DidLaunchOrAttach(ArchSpec &process_arch);
377+
void LoadStubBinaries();
377378
void MaybeLoadExecutableModule();
378379

379380
Status ConnectToDebugserver(llvm::StringRef host_port);

0 commit comments

Comments
 (0)