Skip to content

lldb/Instrumentation: NFC-ish use GetFrameCodeAddressForSymbolication() #2879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,14 @@ InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
StackFrameSP responsible_frame;
for (unsigned I = 0; I < thread_sp->GetStackFrameCount(); ++I) {
StackFrameSP frame = thread_sp->GetStackFrameAtIndex(I);
Address addr = frame->GetFrameCodeAddress();
Address addr = frame->GetFrameCodeAddressForSymbolication();
if (addr.GetModule() == runtime_module_sp) // Skip PCs from the runtime.
continue;

// The first non-runtime frame is responsible for the bug.
if (!responsible_frame)
responsible_frame = frame;

// First frame in stacktrace should point to a real PC, not return address.
if (I != 0 && trace->GetSize() == 0) {
addr.Slide(-1);
}

lldb::addr_t PC = addr.GetLoadAddress(&target);
trace->AddItem(StructuredData::ObjectSP(new StructuredData::Integer(PC)));
}
Expand Down Expand Up @@ -365,8 +360,11 @@ InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
info->GetObjectForDotSeparatedPath("tid");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;

HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
ThreadSP new_thread_sp(history_thread);
// We gather symbolication addresses above, so no need for HistoryThread to
// try to infer the call addresses.
bool pcs_are_call_addresses = true;
ThreadSP new_thread_sp = std::make_shared<HistoryThread>(
*process_sp, tid, PCs, pcs_are_call_addresses);

// Save this in the Process' ExtendedThreadList so a strong pointer retains
// the object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ StructuredData::ObjectSP InstrumentationRuntimeUBSan::RetrieveReportData(
StructuredData::Array *trace = new StructuredData::Array();
auto trace_sp = StructuredData::ObjectSP(trace);
for (unsigned I = 0; I < thread_sp->GetStackFrameCount(); ++I) {
const Address FCA =
thread_sp->GetStackFrameAtIndex(I)->GetFrameCodeAddress();
const Address FCA = thread_sp->GetStackFrameAtIndex(I)
->GetFrameCodeAddressForSymbolication();
if (FCA.GetModule() == runtime_module_sp) // Skip PCs from the runtime.
continue;

Expand Down Expand Up @@ -324,8 +324,11 @@ InstrumentationRuntimeUBSan::GetBacktracesFromExtendedStopInfo(
info->GetObjectForDotSeparatedPath("tid");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;

HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
ThreadSP new_thread_sp(history_thread);
// We gather symbolication addresses above, so no need for HistoryThread to
// try to infer the call addresses.
bool pcs_are_call_addresses = true;
ThreadSP new_thread_sp = std::make_shared<HistoryThread>(
*process_sp, tid, PCs, pcs_are_call_addresses);
std::string stop_reason_description = GetStopReasonDescription(info);
new_thread_sp->SetName(stop_reason_description.c_str());

Expand Down