Skip to content

Commit 5f658bf

Browse files
committed
Rename test utility & try to fix it for Windows
1 parent 51c5eba commit 5f658bf

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

compiler-rt/test/asan/TestCases/suppress_fake_stack.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99

1010
volatile uintptr_t saved;
1111

12-
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t caller_frame) {
12+
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame,
13+
uintptr_t var_addr) {
1314
uintptr_t this_frame =
1415
reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
15-
return this_frame <= saved && saved <= caller_frame;
16+
return this_frame <= var_addr && var_addr <= parent_frame;
1617
}
1718

18-
ATTRIBUTE_NOINLINE bool IsOnStack() {
19+
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame) {
1920
volatile char temp = ' ';
2021
saved = reinterpret_cast<uintptr_t>(&temp);
22+
return IsOnRealStack(parent_frame, saved);
23+
}
24+
25+
ATTRIBUTE_NOINLINE bool IsOnRealStack() {
2126
return IsOnRealStack(reinterpret_cast<uintptr_t>(__builtin_frame_address(0)));
2227
}
2328

2429
int main(int argc, char *argv[]) {
25-
assert(!IsOnStack());
30+
assert(!IsOnRealStack());
2631

2732
__asan_suppress_fake_stack();
28-
assert(IsOnStack());
33+
assert(IsOnRealStack());
2934

3035
__asan_unsuppress_fake_stack();
31-
assert(!IsOnStack());
36+
assert(!IsOnRealStack());
3237

3338
return 0;
3439
}

compiler-rt/test/asan/TestCases/suppress_fake_stack_force_disabled.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@
1010

1111
volatile uintptr_t saved;
1212

13-
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t caller_frame) {
13+
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame,
14+
uintptr_t var_addr) {
1415
uintptr_t this_frame =
1516
reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
16-
return this_frame <= saved && saved <= caller_frame;
17+
return this_frame <= var_addr && var_addr <= parent_frame;
1718
}
1819

19-
ATTRIBUTE_NOINLINE bool IsOnStack() {
20+
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t parent_frame) {
2021
volatile char temp = ' ';
2122
saved = reinterpret_cast<uintptr_t>(&temp);
23+
return IsOnRealStack(parent_frame, saved);
24+
}
25+
26+
ATTRIBUTE_NOINLINE bool IsOnRealStack() {
2227
return IsOnRealStack(reinterpret_cast<uintptr_t>(__builtin_frame_address(0)));
2328
}
2429

2530
int main(int argc, char *argv[]) {
26-
assert(IsOnStack());
31+
assert(IsOnRealStack());
2732

2833
__asan_suppress_fake_stack();
29-
assert(IsOnStack());
34+
assert(IsOnRealStack());
3035

3136
__asan_unsuppress_fake_stack();
32-
assert(IsOnStack());
37+
assert(IsOnRealStack());
3338

3439
return 0;
3540
}

0 commit comments

Comments
 (0)