summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/heuristic/Heuristic.py44
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp4
2 files changed, 43 insertions, 5 deletions
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/heuristic/Heuristic.py b/cross-project-tests/debuginfo-tests/dexter/dex/heuristic/Heuristic.py
index 0305c836f5d7..1582e7b3b706 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/heuristic/Heuristic.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/heuristic/Heuristic.py
@@ -98,6 +98,32 @@ def add_heuristic_tool_arguments(parser):
metavar='<int>')
+class PenaltyLineRanges:
+ def __init__(self, first_step, penalty):
+ self.ranges = [(first_step, first_step)]
+ self.penalty = penalty
+
+ def add_step(self, next_step, penalty):
+ last_range = self.ranges[-1]
+ last_step = last_range[1]
+ if (next_step == last_step + 1):
+ self.ranges[-1] = (last_range[0], next_step)
+ else:
+ self.ranges.append((next_step, next_step))
+ self.penalty += penalty
+
+ def __str__(self):
+ range_to_str = lambda r: str(r[0]) if r[0] == r[1] else f'{r[0]}-{r[1]}'
+ if self.ranges[0][0] == self.ranges[-1][1]:
+ text = f'step {self.ranges[0][0]}'
+ else:
+ step_list = ', '.join([range_to_str(r) for r in self.ranges])
+ text = f'steps [{step_list}]'
+ if self.penalty:
+ text += ' <r>[-{}]</>'.format(self.penalty)
+ return text
+
+
class Heuristic(object):
def __init__(self, context, steps):
self.context = context
@@ -456,11 +482,23 @@ class Heuristic(object):
for category in sorted(pen_cmd.pen_dict):
lines.append(' <r>{}</>:\n'.format(category))
+ step_value_results = {}
+ for result, penalty in pen_cmd.pen_dict[category]:
+ if not isinstance(result, StepValueInfo):
+ continue
+ if result.expected_value not in step_value_results:
+ step_value_results[result.expected_value] = PenaltyLineRanges(result.step_index, penalty)
+ else:
+ step_value_results[result.expected_value].add_step(result.step_index, penalty)
+
+ for value, penalty_line_range in step_value_results.items():
+ text = f'({value}): {penalty_line_range}'
+ total_penalty += penalty_line_range.penalty
+ lines.append(' {}\n'.format(text))
+
for result, penalty in pen_cmd.pen_dict[category]:
if isinstance(result, StepValueInfo):
- text = 'step {}'.format(result.step_index)
- if result.expected_value:
- text += ' ({})'.format(result.expected_value)
+ continue
else:
text = str(result)
if penalty:
diff --git a/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
index ffb4defac662..5d4e39e38fda 100644
--- a/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
+++ b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
@@ -30,8 +30,8 @@
// CHECK-NEXT: address 'x_2' (0x[[X2_VAL]])
// CHECK-NEXT: address 'y' (0x[[Y_VAL]])
// CHECK: misordered result:
-// CHECK-NEXT: step 4 (0x[[Y_VAL]])
-// CHECK-NEXT: step 5 (0x[[X2_VAL]])
+// CHECK-NEXT: (0x[[Y_VAL]]): step 4
+// CHECK-NEXT: (0x[[X2_VAL]]): step 5
int main() {
int *x = new int(5);