summaryrefslogtreecommitdiff
path: root/lldb/source/Target/StackFrameList.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2020-03-09 14:10:41 +0100
committerPavel Labath <pavel@labath.sk>2020-03-09 14:13:22 +0100
commitc0b1af6878444f075a17d87f523bc6be3343db35 (patch)
tree11c9b19c64b0cfe82220bd59fd6cbd8d1b544919 /lldb/source/Target/StackFrameList.cpp
parent6ba0a4ec3bbfe71050b7b5c87f46820f3500e211 (diff)
[lldb] Return Unwinder& from Thread::GetUnwinder
The function always returns a valid object. Let the return type reflect that, and remove some null checks.
Diffstat (limited to 'lldb/source/Target/StackFrameList.cpp')
-rw-r--r--lldb/source/Target/StackFrameList.cpp64
1 files changed, 28 insertions, 36 deletions
diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp
index 0047697f7070..e8e72203e204 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -218,17 +218,14 @@ void StackFrameList::SetCurrentInlinedDepth(uint32_t new_depth) {
}
void StackFrameList::GetOnlyConcreteFramesUpTo(uint32_t end_idx,
- Unwind *unwinder) {
+ Unwind &unwinder) {
assert(m_thread.IsValid() && "Expected valid thread");
assert(m_frames.size() <= end_idx && "Expected there to be frames to fill");
if (end_idx < m_concrete_frames_fetched)
return;
- if (!unwinder)
- return;
-
- uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
+ uint32_t num_frames = unwinder.GetFramesUpTo(end_idx);
if (num_frames <= end_idx + 1) {
// Done unwinding.
m_concrete_frames_fetched = UINT32_MAX;
@@ -425,7 +422,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
if (m_frames.size() > end_idx || GetAllFramesFetched())
return;
- Unwind *unwinder = m_thread.GetUnwinder();
+ Unwind &unwinder = m_thread.GetUnwinder();
if (!m_show_inlined_frames) {
GetOnlyConcreteFramesUpTo(end_idx, unwinder);
@@ -463,9 +460,8 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
RegisterContextSP reg_ctx_sp(m_thread.GetRegisterContext());
if (reg_ctx_sp) {
- const bool success = unwinder &&
- unwinder->GetFrameInfoAtIndex(
- idx, cfa, pc, behaves_like_zeroth_frame);
+ const bool success = unwinder.GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame);
// There shouldn't be any way not to get the frame info for frame
// 0. But if the unwinder can't make one, lets make one by hand
// with the SP as the CFA and see if that gets any further.
@@ -484,9 +480,8 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
}
} else {
- const bool success = unwinder &&
- unwinder->GetFrameInfoAtIndex(
- idx, cfa, pc, behaves_like_zeroth_frame);
+ const bool success =
+ unwinder.GetFrameInfoAtIndex(idx, cfa, pc, behaves_like_zeroth_frame);
if (!success) {
// We've gotten to the end of the stack.
SetAllFramesFetched();
@@ -669,31 +664,28 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
// GetFramesUpTo.
frame_sp = m_frames[idx];
} else {
- Unwind *unwinder = m_thread.GetUnwinder();
- if (unwinder) {
- addr_t pc, cfa;
- bool behaves_like_zeroth_frame = (idx == 0);
- if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc,
- behaves_like_zeroth_frame)) {
- const bool cfa_is_valid = true;
- frame_sp = std::make_shared<StackFrame>(
- m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
- StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
-
- Function *function =
- frame_sp->GetSymbolContext(eSymbolContextFunction).function;
- if (function) {
- // When we aren't showing inline functions we always use the top
- // most function block as the scope.
- frame_sp->SetSymbolContextScope(&function->GetBlock(false));
- } else {
- // Set the symbol scope from the symbol regardless if it is nullptr
- // or valid.
- frame_sp->SetSymbolContextScope(
- frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol);
- }
- SetFrameAtIndex(idx, frame_sp);
+ addr_t pc, cfa;
+ bool behaves_like_zeroth_frame = (idx == 0);
+ if (m_thread.GetUnwinder().GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame)) {
+ const bool cfa_is_valid = true;
+ frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
+ StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
+
+ Function *function =
+ frame_sp->GetSymbolContext(eSymbolContextFunction).function;
+ if (function) {
+ // When we aren't showing inline functions we always use the top
+ // most function block as the scope.
+ frame_sp->SetSymbolContextScope(&function->GetBlock(false));
+ } else {
+ // Set the symbol scope from the symbol regardless if it is nullptr
+ // or valid.
+ frame_sp->SetSymbolContextScope(
+ frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol);
}
+ SetFrameAtIndex(idx, frame_sp);
}
}
} else if (original_idx == 0) {