File tree Expand file tree Collapse file tree 4 files changed +32
-19
lines changed
lldb/test/Shell/BoundsSafety Expand file tree Collapse file tree 4 files changed +32
-19
lines changed Original file line number Diff line number Diff line change 1+ #include <bounds_safety_soft_traps.h>
2+ #include <ptrcheck.h>
3+ #include <stdio.h>
4+
5+ #if __CLANG_BOUNDS_SAFETY_SOFT_TRAP_API_VERSION > 0
6+ #error API version changed
7+ #endif
8+
9+ #if __has_ptrcheck
10+ #error Do not compile the runtime with -fbounds-safety enabled due to potential for infinite recursion
11+ #endif
12+
13+
14+
15+ void __bounds_safety_soft_trap_s (const char * reason ) {
16+ printf ("BoundsSafety check FAILED: message:\"%s\"\n" , reason ? reason : "" );
17+ }
18+
19+ void __bounds_safety_soft_trap (void ) {
20+ printf ("BoundsSafety check FAILED\n" );
21+ }
Original file line number Diff line number Diff line change 11#include <stdio.h>
2- #include <bounds_safety_soft_traps.h>
3-
4- #if __CLANG_BOUNDS_SAFETY_SOFT_TRAP_API_VERSION > 0
5- #error API version changed
6- #endif
7-
8- void __bounds_safety_soft_trap_s (const char * reason ) {
9- printf ("BoundsSafety check FAILED: message:\"%s\"\n" , reason ? reason : "" );
10- }
11-
12- void __bounds_safety_soft_trap (void ) {
13- printf ("BoundsSafety check FAILED\n" );
14- }
152
163int bad_read (int index ) {
174 int array [] = {0 , 1 , 2 };
Original file line number Diff line number Diff line change 11# UNSUPPORTED: system-windows
2- # RUN: %clang_host -fbounds-safety -fbounds-safety-soft-traps=call-minimal -g -O0 %S/Inputs/boundsSafetySoftTraps.c -o %t.out
2+ # RUN: %clang_host -c -fbounds-safety -fbounds-safety-soft-traps=call-minimal -g -O0 %S/Inputs/boundsSafetySoftTraps.c -o %t.o
3+ # RUN: %clang_host -c -O0 %S/Inputs/boundsSafetyMockSoftTrapRuntime.c -o %t.softtrap_runtime.o
4+ # RUN: %clang_host %t.o %t.softtrap_runtime.o -o %t.out
35# RUN: %lldb -b -s %s %t.out | FileCheck %s
46b __bounds_safety_soft_trap
57run
1012
1113# Check that reason for bounds check failing can be seen in the stacktrace
1214bt
13- # CHECK: * frame #{{.*}}`__bounds_safety_soft_trap{{[ ]+ }}
15+ # CHECK: * frame #{{.*}}`__bounds_safety_soft_trap{{$ }}
1416# CHECK-NEXT: frame #{{.*}}`__clang_trap_msg$Bounds check failed$indexing above upper bound in 'array[index]'
15- # CHECK-NEXT: frame #2{{.*}}`bad_read(index=10) at boundsSafetySoftTraps.c:18
17+ # CHECK-NEXT: frame #2{{.*}}`bad_read(index=10) at boundsSafetySoftTraps.c:5
1618
1719# Resume execution
1820c
Original file line number Diff line number Diff line change 11# UNSUPPORTED: system-windows
2- # RUN: %clang_host -fbounds-safety -fbounds-safety-soft-traps=call-with-str -g -O0 %S/Inputs/boundsSafetySoftTraps.c -o %t.out
2+ # RUN: %clang_host -c -fbounds-safety -fbounds-safety-soft-traps=call-with-str -g -O0 %S/Inputs/boundsSafetySoftTraps.c -o %t.o
3+ # Note: Building the runtime without debug info is intentional because this is the common case
4+ # RUN: %clang_host -c -O0 %S/Inputs/boundsSafetyMockSoftTrapRuntime.c -o %t.softtrap_runtime.o
5+ # RUN: %clang_host %t.o %t.softtrap_runtime.o -o %t.out
36# RUN: %lldb -b -s %s %t.out | FileCheck %s
47b __bounds_safety_soft_trap_s
58run
1013
1114# Check that reason for bounds check failing can be seen in the stacktrace
1215bt
13- # CHECK: * frame #{{.*}}`__bounds_safety_soft_trap_s(reason="indexing above upper bound in 'array[index]'")
16+ # CHECK: * frame #{{.*}}`__bounds_safety_soft_trap_s
1417# CHECK-NEXT: frame #{{.*}}`__clang_trap_msg$Bounds check failed$indexing above upper bound in 'array[index]'
15- # CHECK-NEXT: frame #2 {{.*}}`bad_read(index=10) at boundsSafetySoftTraps.c:18
18+ # CHECK-NEXT: frame #{{.*}}`bad_read(index=10) at boundsSafetySoftTraps.c:5
1619
1720# Resume execution
1821c
You can’t perform that action at this time.
0 commit comments