File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
compiler-rt/test/asan/TestCases Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 99
1010volatile 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
2429int 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}
Original file line number Diff line number Diff line change 1010
1111volatile 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
2530int 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}
You can’t perform that action at this time.
0 commit comments