aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectFrame.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2023-05-23 11:13:36 -0700
committerJim Ingham <jingham@apple.com>2023-07-06 16:19:19 -0700
commit2b0c8865421287a30ddda0f459f17f76bfeb1358 (patch)
treed84ecd66f97cef06e8a9b71a44559dc78b2034e4 /lldb/source/Commands/CommandObjectFrame.cpp
parenta4a26374aa11d48ac6bf65c78c2aaf8f16414287 (diff)
downloadllvm-2b0c8865421287a30ddda0f459f17f76bfeb1358.zip
llvm-2b0c8865421287a30ddda0f459f17f76bfeb1358.tar.gz
llvm-2b0c8865421287a30ddda0f459f17f76bfeb1358.tar.bz2
Refine the reporting mechanism for interruption.
Also, make it possible for new Targets which haven't been added to the TargetList yet to check for interruption, and add a few more places in building modules where we can check for interruption. Differential Revision: https://reviews.llvm.org/D154542
Diffstat (limited to 'lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index db31b15..3f68425 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -326,21 +326,29 @@ protected:
}
} else if (*m_options.relative_frame_offset > 0) {
// I don't want "up 20" where "20" takes you past the top of the stack
- // to produce
- // an error, but rather to just go to the top. So I have to count the
- // stack here...
- const uint32_t num_frames = thread->GetStackFrameCount();
- if (static_cast<int32_t>(num_frames - frame_idx) >
- *m_options.relative_frame_offset)
- frame_idx += *m_options.relative_frame_offset;
+ // to produce an error, but rather to just go to the top. OTOH, start
+ // by seeing if the requested frame exists, in which case we can avoid
+ // counting the stack here...
+ const uint32_t frame_requested = frame_idx
+ + *m_options.relative_frame_offset;
+ StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_requested);
+ if (frame_sp)
+ frame_idx = frame_requested;
else {
- if (frame_idx == num_frames - 1) {
- // If we are already at the top of the stack, just warn and don't
- // reset the frame.
- result.AppendError("Already at the top of the stack.");
- return false;
- } else
- frame_idx = num_frames - 1;
+ // The request went past the stack, so handle that case:
+ const uint32_t num_frames = thread->GetStackFrameCount();
+ if (static_cast<int32_t>(num_frames - frame_idx) >
+ *m_options.relative_frame_offset)
+ frame_idx += *m_options.relative_frame_offset;
+ else {
+ if (frame_idx == num_frames - 1) {
+ // If we are already at the top of the stack, just warn and don't
+ // reset the frame.
+ result.AppendError("Already at the top of the stack.");
+ return false;
+ } else
+ frame_idx = num_frames - 1;
+ }
}
}
} else {