Skip to content

Commit d365067

Browse files
committed
Better stack address cleanup []
1 parent da707fb commit d365067

8 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎dev_tools/bin/edg-normalize-test-output‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def parse_args() -> argparse.Namespace:
2929
action = 'store_true',
3030
help = 'include rules to normalize IL'
3131
)
32+
parser.add_argument(
33+
'--stack-addr-cleanup',
34+
dest = 'stack_addr_cleanup',
35+
action = 'store_true',
36+
help = (
37+
'replace host-dependent stack / high addresses with STACK or 0xSTACK'
38+
)
39+
)
3240
return parser.parse_args()
3341

3442
def die(signum: Any, frame: Any) -> None:
@@ -73,6 +81,7 @@ def main() -> None:
7381

7482
normalizer = edgtest.filter.Normalizer(
7583
normalize_il = args.normalize_il,
84+
stack_addr_cleanup = args.stack_addr_cleanup,
7685
env = os.environ,
7786
build_constants = build_constants
7887
)

‎dev_tools/pylibs/edgtest/filter/__init__.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,17 @@ async def load_build_constants(compiler_bin: Path) -> BuildConstants:
9696
**_ESCAPED_REGEX_REPLACEMENTS
9797
}
9898

99+
# Stack / high canonical user addresses that vary across hosts and ASLR.
100+
# Match both %p (0x-prefixed) and %x (bare) forms. The 0x form must be listed
101+
# first so it wins over the bare form.
102+
_STACK_ADDR_REPLACEMENTS = (
103+
(r'0x(?:7fffffff[0-9a-f]+|ffff[0-9a-f]+)', '0xSTACK'),
104+
(r'(?<![0-9a-fx])(?:7fffffff[0-9a-f]+|ffff[0-9a-f]+)', 'STACK'),
105+
)
106+
99107
class Normalizer:
100-
def __init__(self, *, normalize_il: bool, env: Dict[str, str],
108+
def __init__(self, *, normalize_il: bool, stack_addr_cleanup: bool = False,
109+
env: Dict[str, str],
101110
build_constants: BuildConstants) -> None:
102111
self.replacements = list(GLOBAL_REGEX_REPLACEMENTS.items())
103112
self.replacements.extend([
@@ -119,6 +128,9 @@ def __init__(self, *, normalize_il: bool, env: Dict[str, str],
119128
'/edg/workspace'
120129
))
121130

131+
if stack_addr_cleanup:
132+
self.replacements.extend(_STACK_ADDR_REPLACEMENTS)
133+
122134
if normalize_il:
123135
# Detect the compiler version string.
124136
self.replacements.append(

‎tests/tests/imported/gnu/cpp/cpp0x/constexpr-tuple.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options: --c++11
3-
//filter:sed -E -e 's/0x(7fffffff[0-9a-f]+|ffff[0-9a-f]+)/0xSTACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
# 0 "./cpp0x/constexpr-tuple.C"
55
# 0 "<built-in>"
66
# 0 "<command-line>"

‎tests/tests/imported/gnu/cpp/ext/stmtexpr1.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options:
3-
//filter:sed -E -e 's/0x(7fffffff[0-9a-f]+|ffff[0-9a-f]+)/0xSTACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
// Copyright (C) 2003 Free Software Foundation, Inc.
55
// Contributed by Nathan Sidwell 30 Jul 2003 <nathan@codesourcery.com>
66

‎tests/tests/imported/gnu/cpp/init/elide3.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options:
3-
//filter:sed -E -e 's/0x(7fffffff[0-9a-f]+|ffff[0-9a-f]+)/0xSTACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
// PR c++/67557
55
// { dg-do run }
66

‎tests/tests/imported/gnu/cpp/opt/alias2.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options:
3-
//filter:sed -E -e 's/ffff[c-f][0-9a-f]{3}/STACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
// { dg-do run }
55
// { dg-options "-O2" }
66

‎tests/tests/imported/gnu/cpp/opt/tmp1.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options:
3-
//filter:sed -E -e 's/0x(7fffffff[0-9a-f]+|ffff[0-9a-f]+)/0xSTACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
// { dg-do run }
55

66

‎tests/tests/imported/gnu/cpp/tc1/dr20.sft.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//type: rp
22
//options:
3-
//filter:sed -E -e 's/ffff[c-f][0-9a-f]{3}/STACK/g'
3+
//filter:edg-normalize-test-output --stack-addr-cleanup
44
// { dg-do run }
55
// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
66
// DR20: Some clarifications needed for 12.8 para 15

0 commit comments

Comments
 (0)