[llvm-branch-commits] [llvm] [Dexter] Allow fetching "scopes" from the debugger (PR #202802)
Stephen Tozer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 16 07:05:32 PDT 2026
================
@@ -0,0 +1,48 @@
+// RUN: %dexter_regression_test_cxx_build %s -o %t
+// RUN: %dexter_regression_test_run --use-script --skip-evaluate --binary %t \
+// RUN: -- %s | FileCheck %s
+
+char There[] = "Here";
+
+int main() {
+ int One = 2;
+ char Red[] = "Blue";
+ return 0; // !dex_label ret
+}
+
+/// Test that we can use functions in !where nodes, and that Dexter steps
+/// through the entirety of those functions. We expect both calls to `assign` to
+/// be stepped through, but only the non-recursive call of `replace` should be
+/// stepped through, as the !where matches to the rootmost applicable frame.
+
+// CHECK: Step 0
+// CHECK: main
+// CHECK: Variable Scopes:
+// CHECK-NEXT: Globals: [::There]
+// CHECK-NEXT: Locals: [One, Red]
+// CHECK-NEXT: Variables:
+// CHECK-NEXT: "::There": (char[5]) "Here"
+// CHECK-NEXT: "[0]": (char) 'H'
+// CHECK-NEXT: "[1]": (char) 'e'
+// CHECK-NEXT: "[2]": (char) 'r'
+// CHECK-NEXT: "[3]": (char) 'e'
+// CHECK-NEXT: "[4]": (char) '\0'
+// CHECK-NEXT: "One": (int) 2
+// CHECK-NEXT: "Red": (char[5]) "Blue"
+// CHECK-NEXT: "[0]": (char) 'B'
+// CHECK-NEXT: "[1]": (char) 'l'
+// CHECK-NEXT: "[2]": (char) 'u'
+// CHECK-NEXT: "[3]": (char) 'e'
+// CHECK-NEXT: "[4]": (char) '\0'
+
+// CHECK-NOT: Step 1
+
+/*
+---
+!where {lines: !label ret}:
+ ? !value/all Locals
+ ? !value/all Globals
----------------
SLTozer wrote:
The scope names are not determined by Dexter, but come from the result of a `scopes` DAP request. Long-term it would potentially make sense to define some "generic" scopes that Dexter can refer to, but this gets awkward when different debuggers present different kinds of scopes (e.g. if one debugger has `Arguments` and `Locals` scopes and another debugger only has `Locals`, we don't have a way of generically requesting the "Arguments" scope).
Regarding locality to function vs lexical block, that is again debugger-specific, and not easily (read: worth doing currently) solved from the Dexter side.
https://github.com/llvm/llvm-project/pull/202802
More information about the llvm-branch-commits
mailing list