This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add --stack option to `target symbols add` command
ClosedPublic

Authored by JDevlieghere on Sep 17 2021, 3:57 PM.

Details

Summary

Currently you can ask the target symbols add command to locate the debug symbols for the current frame. This patch add an options to do that for the whole call stack.

Diff Detail

Event Timeline

JDevlieghere requested review of this revision.Sep 17 2021, 3:57 PM
JDevlieghere created this revision.
kastiglione added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4268–4271

Is this missing a return?

4281–4282

we don't have an iterator for this?

kastiglione added inline comments.Sep 17 2021, 4:05 PM
lldb/source/Commands/CommandObjectTarget.cpp
4301–4302

do you need the separate variable? can it be:

flush |= true;
JDevlieghere marked 2 inline comments as done.Sep 17 2021, 4:19 PM
JDevlieghere added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4268–4271

Yep!

4281–4282

Not currently, no. I looked at StackFrameList in case it was just a matter of adding a LockingAdaptedIterable, but unsurprisingly, stack frames are computed rather than stored in a list. We'd need to implement a custom iterator that keeps track of the index and calls GetStackFrameAtIndex under the hood, which is definitely something for a separate patch.

4301–4302

I want flush to be true only if at least one frame requires a flush.

JDevlieghere marked 2 inline comments as done.
kastiglione added inline comments.Sep 17 2021, 5:07 PM
lldb/source/Commands/CommandObjectTarget.cpp
4301–4302

my suggestion still achieves that.

Instead of:

bool current_frame_flush = false;
if (DownloadObjectAndSymbolFile(module_spec, target, result,
                                current_frame_flush))
  symbols_found = true;

flush |= current_frame_flush;

Inline the current_frame_flush variable:

if (DownloadObjectAndSymbolFile(module_spec, target, result,
                                current_frame_flush))
  flush |= true;

This makes flush only true when one frame needs it.

kastiglione added inline comments.Sep 17 2021, 5:10 PM
lldb/source/Commands/CommandObjectTarget.cpp
4300

It seems this is call is synchronous? A separate improvement would be to perform the unique downloads in parallel.

JDevlieghere marked an inline comment as done.Sep 17 2021, 5:15 PM
JDevlieghere added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4301–4302

That relies on the assumption that flush is true iff DownloadObjectAndSymbolFilereturn true (and the same for AddModuleSymbols). Looking at the code that does indeed seem to be the case, but then I'd rather see the API refactored to remove the flush output variable instead of relying on an implementation-specific assumption here.

shafik added a subscriber: shafik.Sep 20 2021, 8:57 AM

Does it make sense to add a test for this? It looks like we have two basic tests for add-dsym already.

JDevlieghere marked an inline comment as done.
  • Rebase
  • Add test
kastiglione accepted this revision.Sep 20 2021, 6:22 PM
kastiglione added inline comments.
lldb/source/Commands/CommandObjectTarget.cpp
4301–4302

thanks, makes sense. I had overlooked that current_frame_flush is also an output parameter.

This revision is now accepted and ready to land.Sep 20 2021, 6:22 PM
This revision was landed with ongoing or failed builds.Sep 21 2021, 11:08 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 11:08 PM