[Lldb-commits] [lldb] Don't count all the frames just to skip the current inlined ones. (PR #80918)

via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 7 11:31:03 PST 2024


================
@@ -608,11 +608,10 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
   StackFrameSP parent_frame = nullptr;
   addr_t return_pc = LLDB_INVALID_ADDRESS;
   uint32_t current_frame_idx = current_frame->GetFrameIndex();
-  uint32_t num_frames = thread->GetStackFrameCount();
-  for (uint32_t parent_frame_idx = current_frame_idx + 1;
-       parent_frame_idx < num_frames; ++parent_frame_idx) {
+
+  for (uint32_t parent_frame_idx = current_frame_idx + 1;;parent_frame_idx++) {
----------------
jimingham wrote:

I tried this, but I don't think it makes things any clearer.   This isn't a simple loop, it has another break, and a continue.  You end up having to cache IsInline before you reset the parent_frame and that hides where the important next frame part of the code goes.  That's just awkward.  
I think this version is clearer.  The first thing the loop does is fetch the next frame and, checks if it is null as the signal that the stack walk is done.  The way I wrote it keeps those operations right next to one another which I think is easier to read..

https://github.com/llvm/llvm-project/pull/80918


More information about the lldb-commits mailing list