[llvm-branch-commits] [llvm] [Dexter] Add additional variable metrics, sanitize lldb-dap function names (PR #204366)

Stephen Tozer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 24 07:50:52 PDT 2026


https://github.com/SLTozer updated https://github.com/llvm/llvm-project/pull/204366

>From a58cba57c71acc19c00476f52bb1451545f1cc21 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 17 Jun 2026 13:46:31 +0100
Subject: [PATCH 1/5] backport: add optimized out metric

---
 .../debuginfo-tests/dexter/dex/evaluation/Metrics.py      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
index 28df661bb1b24..d42a56c6bf351 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
@@ -107,6 +107,7 @@ def get_variable_metrics(
     all_expected_values = get_expected_value_set(expected_values)
     seen_expected_values = set()
     num_correct_steps = 0
+    num_optimized_out_steps = 0
     num_missing_var_steps = 0
     num_unexpected_value_steps = 0
     partial_step_correctness = 0.0
@@ -118,7 +119,10 @@ def get_variable_metrics(
         if match.match_result == MatchResult.TRUE:
             num_correct_steps += 1
         elif match.actual_result is None:
-            num_missing_var_steps += 1
+            if match.actual and match.actual.is_optimized_away:
+                num_optimized_out_steps += 1
+            else:
+                num_missing_var_steps += 1
         else:
             num_unexpected_value_steps += 1
     assert all(
@@ -143,6 +147,8 @@ def get_variable_metrics(
         ),
         # The sum of the 0.0-1.0 "correctness value" of matches across each step.
         "partial_step_correctness": ScalarMetric(partial_step_correctness),
+        # The number of steps where the watched variable/expression was marked "optimized out" in the debugger.
+        "optimized_out_steps": ScalarMetric(num_optimized_out_steps, improves_asc=False),
         # The number of steps where the watched variable/expression was not available in the debugger.
         "missing_var_steps": ScalarMetric(num_missing_var_steps, improves_asc=False),
         # The number of steps where the watched variable/expression had a value not in the set of expected values.

>From 47da5f109f70c80ea50545507ea540287e63f382 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 17 Jun 2026 15:48:56 +0100
Subject: [PATCH 2/5] Fix: Account for weird function name endings in lldb-dap

---
 .../debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py         | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
index 6ab06d066dfe6..6383036a8e1f1 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
@@ -436,6 +436,11 @@ def frames_below_main(self):
             "_start",
         ]
 
+    def _sanitize_function_name(self, name: str):  # pylint: disable=no-self-use
+        if name.endswith(" [opt]"):
+            name = name[:-len(" [opt]")]
+        return name
+
     def _post_step_hook(self):
         """Hook to be executed after completing a step request."""
         if self._debugger_state.stopped_reason == "step":

>From e4a7d546edf0e68a54b39528addebcc18be4b363 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 17 Jun 2026 15:49:30 +0100
Subject: [PATCH 3/5] Add irretrievable metric

---
 .../debuginfo-tests/dexter/dex/evaluation/Metrics.py         | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
index d42a56c6bf351..2b933354a4e1a 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
@@ -108,6 +108,7 @@ def get_variable_metrics(
     seen_expected_values = set()
     num_correct_steps = 0
     num_optimized_out_steps = 0
+    num_irretrievable_steps = 0
     num_missing_var_steps = 0
     num_unexpected_value_steps = 0
     partial_step_correctness = 0.0
@@ -121,6 +122,8 @@ def get_variable_metrics(
         elif match.actual_result is None:
             if match.actual and match.actual.is_optimized_away:
                 num_optimized_out_steps += 1
+            elif match.actual and match.actual.is_irretrievable:
+                num_irretrievable_steps += 1
             else:
                 num_missing_var_steps += 1
         else:
@@ -149,6 +152,8 @@ def get_variable_metrics(
         "partial_step_correctness": ScalarMetric(partial_step_correctness),
         # The number of steps where the watched variable/expression was marked "optimized out" in the debugger.
         "optimized_out_steps": ScalarMetric(num_optimized_out_steps, improves_asc=False),
+        # The number of steps where the watched variable/expression had an inaccessible address in the debugger.
+        "irretrievable_steps": ScalarMetric(num_irretrievable_steps, improves_asc=False),
         # The number of steps where the watched variable/expression was not available in the debugger.
         "missing_var_steps": ScalarMetric(num_missing_var_steps, improves_asc=False),
         # The number of steps where the watched variable/expression had a value not in the set of expected values.

>From 36c2bb0782eb91e540fa9f121fd2d92bbc2a5b34 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 17 Jun 2026 16:27:00 +0100
Subject: [PATCH 4/5] format

---
 .../debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py      | 2 +-
 .../debuginfo-tests/dexter/dex/evaluation/Metrics.py      | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
index 6383036a8e1f1..7f4af13ad8481 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
@@ -438,7 +438,7 @@ def frames_below_main(self):
 
     def _sanitize_function_name(self, name: str):  # pylint: disable=no-self-use
         if name.endswith(" [opt]"):
-            name = name[:-len(" [opt]")]
+            name = name[: -len(" [opt]")]
         return name
 
     def _post_step_hook(self):
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
index 2b933354a4e1a..44bd7ef63cd8b 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/evaluation/Metrics.py
@@ -151,9 +151,13 @@ def get_variable_metrics(
         # The sum of the 0.0-1.0 "correctness value" of matches across each step.
         "partial_step_correctness": ScalarMetric(partial_step_correctness),
         # The number of steps where the watched variable/expression was marked "optimized out" in the debugger.
-        "optimized_out_steps": ScalarMetric(num_optimized_out_steps, improves_asc=False),
+        "optimized_out_steps": ScalarMetric(
+            num_optimized_out_steps, improves_asc=False
+        ),
         # The number of steps where the watched variable/expression had an inaccessible address in the debugger.
-        "irretrievable_steps": ScalarMetric(num_irretrievable_steps, improves_asc=False),
+        "irretrievable_steps": ScalarMetric(
+            num_irretrievable_steps, improves_asc=False
+        ),
         # The number of steps where the watched variable/expression was not available in the debugger.
         "missing_var_steps": ScalarMetric(num_missing_var_steps, improves_asc=False),
         # The number of steps where the watched variable/expression had a value not in the set of expected values.

>From b89ba6e22c7b9b67df59355e1359868f624e0808 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 24 Jun 2026 14:56:12 +0100
Subject: [PATCH 5/5] Remove all tags that LLDB may add

---
 .../debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py       | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
index 7f4af13ad8481..7f42a86dde600 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
@@ -437,8 +437,11 @@ def frames_below_main(self):
         ]
 
     def _sanitize_function_name(self, name: str):  # pylint: disable=no-self-use
-        if name.endswith(" [opt]"):
-            name = name[: -len(" [opt]")]
+        # Remove the tags that LLDB may insert at the end of a function name; these appear in a fixed order, and we
+        # strip them in the reverse of that order below.
+        for tag in ["artificial", "inlined", "opt"]:
+            if name.endswith(f" [{tag}]"):
+                name = name[: -len(f" [{tag}]")]
         return name
 
     def _post_step_hook(self):



More information about the llvm-branch-commits mailing list