This is an archive of the discontinued LLVM Phabricator instance.

lldb/Instrumentation: NFC-ish use GetFrameCodeAddressForSymbolication()
ClosedPublic

Authored by friss on Apr 22 2021, 11:06 AM.

Details

Summary

A couple of our Instrumentation runtimes were gathering backtraces,
storing it in a StructuredData array and later creating a HistoryThread
using this data. By deafult HistoryThread will consider the history PCs
as return addresses and thus will substract 1 from them to go to the
call address.

This is usually correct, but it's also wasteful as when we gather the
backtraces ourselves, we have much better information to decide how
to backtrace and symbolicate. This patch uses the new
GetFrameCodeAddressForSymbolication() to gather the PCs that should
be used for symbolication and configures the HistoryThread to just
use those PCs as-is.

(The MTC plugin was actaully applying a -1 itself and then the
HistoryThread would do it again, so this actaully fixes a bug there.)

rdar://77027680

Diff Detail

Event Timeline

friss requested review of this revision.Apr 22 2021, 11:06 AM
friss created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 11:06 AM
JDevlieghere added inline comments.Apr 22 2021, 11:44 AM
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
271–273
friss updated this revision to Diff 339746.Apr 22 2021, 11:57 AM

Use make_shared

JDevlieghere accepted this revision.Apr 22 2021, 12:09 PM

Thanks for addressing my critical feedback. LGTM.

This revision is now accepted and ready to land.Apr 22 2021, 12:09 PM
This revision was landed with ongoing or failed builds.Apr 22 2021, 1:33 PM
This revision was automatically updated to reflect the committed changes.
friss marked an inline comment as done.
shafik added a subscriber: shafik.Apr 22 2021, 1:41 PM
shafik added inline comments.
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
273

A nitpick but you could have also done:

ThreadSP new_thread_sp = std::make_shared<HistoryThread>(
     *process_sp, tid, PCs, true /*pcs_are_call_addresses*/);

Otherwise I would have made pcs_are_call_addresses a constant since you are using purely for documentation.

teemperor added inline comments.
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
273

I think the format /*pc_are_call_addresses=*/true); is what LLVM is using (with that format clang-tidy will check that the argument fits the parameter name).