[Lldb-commits] [PATCH] D150236: Thread::GetStackFrameCount should forestall interruption
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 9 17:08:48 PDT 2023
jingham created this revision.
jingham added reviewers: JDevlieghere, mib, bulbazord.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
We can't let GetStackFrameCount get interrupted or it will give the wrong answer. Plus, it's useful in some places to have a way to force the full stack to be created even in the face of interruption. Moreover, most of the time when you're just getting frames, you don't need to know the number of frames in the stack to start with. You just keep calling `Thread::GetStackFrameAtIndex(index++)` and when you get a null StackFrameSP back, you're done. That's also more amenable to interruption if you are doing some work frame by frame.
So this patch makes GetStackFrameCount always return the full count, suspending interruption. I also went through all the places that use GetStackFrameCount to make sure that they really needed the full stack walk. In many cases, they did not. For instance `frame select -r 10` was getting the number of frames just to check whether `cur_frame_idx + 10` was within the stack. It's better in that case to see if that frame exists first, since that doesn't force a full stack walk, and only deal with walking off the end of the stack if it doesn't...
I also added a test for some of these behaviors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150236
Files:
lldb/include/lldb/Target/StackFrameList.h
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Target/StackFrameList.cpp
lldb/test/API/functionalities/bt-interrupt/Makefile
lldb/test/API/functionalities/bt-interrupt/TestInterruptBacktrace.py
lldb/test/API/functionalities/bt-interrupt/main.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150236.520862.patch
Type: text/x-patch
Size: 9018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230510/a6baff84/attachment-0001.bin>
More information about the lldb-commits
mailing list