This is an archive of the discontinued LLVM Phabricator instance.

Delay loading of qProcessInfo-informed binaries until later in the Process setup
ClosedPublic

Authored by jasonmolenda on Jan 17 2023, 3:22 PM.

Details

Summary

I handle two types of binary specification in qProcessInfo -- the main-binary-{uuid,address,slide} and binary-addresses -- so the remote stub can tell lldb to discover/load binaries when we connect.

I did this loading in ProcessGDBRemote::DoConnectRemote() which is very early in process setup, e.g. we don't have threads yet. This caused problems for one group that has a python script in the dSYM and need a more fully set up process.

This patch moves this binary loading from DoConnectRemote() to DidLaunchOrAttach() where we're nearly done setting up the Process. There's a method, MaybeLoadExecutableModule which reads the load address of the main binary from the remote stub (maybge on linux or something) and sets the load address in the Target; I added my new LoadStubBinaries() method next to that one in DidLaunchOrAttach(). I originally thought to simply add the code to MaybeLoadExecutableModule but then the method was doing two completely unrelated things and it would only serve to confuse people in the future I think.

I don't know of a particularly good reviewer on this one, but I'll add Jim without thinking of a better choice offhand.

Diff Detail

Event Timeline

jasonmolenda created this revision.Jan 17 2023, 3:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2023, 3:22 PM
jasonmolenda requested review of this revision.Jan 17 2023, 3:22 PM

This seems okay to me, I can't see why you would be required to fill in the "main binary" or "extra binaries" when we're just stopping for the attach. We shouldn't need them till we've decided we're launched or attached and need to print any info about that.

But given that it was at one point important to call LoadStubBinaries AFTER you had a process, you should leave a comment saying why it is important to wait till you have a process before reading in more binaries.

Add a comment about the intentional placement of binary loading/load address setting in DidLaunchOrAttach to address Jim's feedback.

JDevlieghere accepted this revision.Jan 18 2023, 11:18 AM

LGMT

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

I know you just moved this code, but I don't think I've ever seen anyone write llvm::StringRef() instead of "".

1007–1008

I think the word "use" is missing at the end of line 1007.

1019–1020

I suspect you meant to replace "in this Process/Target" with "in the process of loading it"?

This revision is now accepted and ready to land.Jan 18 2023, 11:18 AM

Thanks for the feedback Jonas, updated patch.