Skip to content

Commit 3e727c2

Browse files
[lldb][thread] Log breakpoints and addresses when printing ThreadPLans at ShouldStop
1 parent f4418fb commit 3e727c2

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lldb/source/Target/Thread.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,19 +805,31 @@ bool Thread::ShouldStop(Event *event_ptr) {
805805
SetShouldRunBeforePublicStop(false);
806806

807807
if (log) {
808+
auto &sc =
809+
GetStackFrameAtIndex(0)->GetSymbolContext(eSymbolContextEverything);
810+
auto *funcname = sc.GetFunctionName(Mangled::ePreferMangled).AsCString();
808811
LLDB_LOGF(log,
809812
"Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
810-
", pc = 0x%16.16" PRIx64,
813+
", pc = 0x%16.16" PRIx64 " (%s)",
811814
__FUNCTION__, static_cast<void *>(this), GetID(), GetProtocolID(),
812815
GetRegisterContext() ? GetRegisterContext()->GetPC()
813-
: LLDB_INVALID_ADDRESS);
816+
: LLDB_INVALID_ADDRESS,
817+
funcname);
814818
LLDB_LOGF(log, "^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
815819
StreamString s;
816820
s.IndentMore();
817821
GetProcess()->DumpThreadPlansForTID(
818822
s, GetID(), eDescriptionLevelVerbose, true /* internal */,
819823
false /* condense_trivial */, true /* skip_unreported */);
820824
LLDB_LOGF(log, "Plan stack initial state:\n%s", s.GetData());
825+
s.Clear();
826+
auto &external_bps = this->CalculateTarget()->GetBreakpointList(false);
827+
for (const auto &bp : external_bps.Breakpoints())
828+
bp->GetDescription(&s, lldb::DescriptionLevel::eDescriptionLevelFull);
829+
auto &internal_bps = this->CalculateTarget()->GetBreakpointList(true);
830+
for (const auto &bp : internal_bps.Breakpoints())
831+
bp->GetDescription(&s, lldb::DescriptionLevel::eDescriptionLevelFull);
832+
LLDB_LOGF(log, "Current breakpoints:\n%s", s.GetData());
821833
}
822834

823835
// The top most plan always gets to do the trace log...
@@ -993,6 +1005,14 @@ bool Thread::ShouldStop(Event *event_ptr) {
9931005
LLDB_LOGF(log, "Plan stack final state:\n%s", s.GetData());
9941006
LLDB_LOGF(log, "vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
9951007
should_stop);
1008+
s.Clear();
1009+
auto &external_bps = this->CalculateTarget()->GetBreakpointList(false);
1010+
for (const auto &bp : external_bps.Breakpoints())
1011+
bp->GetDescription(&s, lldb::DescriptionLevel::eDescriptionLevelFull);
1012+
auto &internal_bps = this->CalculateTarget()->GetBreakpointList(true);
1013+
for (const auto &bp : internal_bps.Breakpoints())
1014+
bp->GetDescription(&s, lldb::DescriptionLevel::eDescriptionLevelFull);
1015+
LLDB_LOGF(log, "Current breakpoints:\n%s", s.GetData());
9961016
}
9971017
return should_stop;
9981018
}

lldb/source/Target/ThreadPlanStepOut.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,24 +237,22 @@ void ThreadPlanStepOut::GetDescription(Stream *s,
237237
s->Printf("Stepping out by stepping through inlined function.");
238238
else {
239239
s->Printf("Stepping out from ");
240+
s->Printf("address 0x%" PRIx64 " ", (uint64_t)m_step_from_insn);
240241
Address tmp_address;
241242
if (tmp_address.SetLoadAddress(m_step_from_insn, &GetTarget())) {
242243
tmp_address.Dump(s, &m_process, Address::DumpStyleResolvedDescription,
243244
Address::DumpStyleLoadAddress);
244-
} else {
245-
s->Printf("address 0x%" PRIx64 "", (uint64_t)m_step_from_insn);
246245
}
247246

248247
// FIXME: find some useful way to present the m_return_id, since there may
249248
// be multiple copies of the
250249
// same function on the stack.
251250

252251
s->Printf(" returning to frame at ");
252+
s->Printf("address 0x%" PRIx64 " ", (uint64_t)m_return_addr);
253253
if (tmp_address.SetLoadAddress(m_return_addr, &GetTarget())) {
254254
tmp_address.Dump(s, &m_process, Address::DumpStyleResolvedDescription,
255255
Address::DumpStyleLoadAddress);
256-
} else {
257-
s->Printf("address 0x%" PRIx64 "", (uint64_t)m_return_addr);
258256
}
259257

260258
if (level == eDescriptionLevelVerbose)

0 commit comments

Comments
 (0)