[Lldb-commits] [lldb] [lldb][debugserver] Expedite the stopped frame's stack memory in jThreadsInfo (PR #212706)
Yao Qi via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 31 04:10:18 PDT 2026
================
@@ -2733,6 +2733,76 @@ static void ReadStackMemory(nub_process_t pid, nub_thread_t tid,
}
}
+// The size of each per-side stack window we expedite. 512 is sized to cover
+// the common case (locals and params sit within a few hundred bytes) while
+// bounding the per-frame cost to 1K bytes regardless of frame size.
+static const nub_size_t k_expedite_stack_window = 512;
+
+// A single contiguous chunk of expedited memory.
+struct ExpeditedMemory {
+ nub_addr_t addr;
+ std::vector<uint8_t> bytes;
+};
+
+// Read the innermost frame's stack memory so that examining its local variables
+// at a public stop is served from the expedited cache instead of generating one
+// memory-read packet.
+//
+// We produce either:
+//
+// - one chunk [$sp, $fp) for a small frame ($fp - $sp <=
+// 2*k_expedite_stack_window), which covers the whole frame with no gap, or
+//
+// - two chunks [$sp, $sp + k_expedite_stack_window) and [$fp -
+// k_expedite_stack_window, $fp) for a large frame, covering the params near
+// $sp and the locals near $fp while leaving the (rarely-interesting) middle
----------------
qiyao wrote:
I pushed in a new commit to change the expedited windows slightly.
- If `fp` is valid, expedite two windows: `[fp + 16, fp + 16 + k_expedite_stack_arg_size)`, skip chunk `[fp, fp+16)` which is already expedited in backtrace chain. This windows covers function args, which was the oversight in this PR. The second window is `[max(sp, sp - (k_expedite_stack_window - k_expedite_stack_arg_size)), fp)`.
- If `fp` isn't valid, the window is `[sp, sp + k_expedite_stack_window)`.
`k_expedite_stack_window` is still 1k, not changed. The new constant `k_expedite_stack_arg_size` is 160, which is got from analyzing several program's dwarf info, and 160 is the optimal value.
https://github.com/llvm/llvm-project/pull/212706
More information about the lldb-commits
mailing list