Skip to content

Commit d061ddb

Browse files
committed
[BoundsSafety][LLDB] Implement instrumentation plugin for -fbounds-safety soft traps
This patch implements an instrumentation plugin for the `-fbounds-safety` soft trap mode first implemented in #11645 (rdar://158088757). The current implementation of -fbounds-safety traps works by emitting calls to runtime functions intended to log the occurrence of a soft trap. While the user could just set a breakpoint of these functions the instrumentation plugin sets it automatically and provides several additional features: When debug info is available: * It adjusts the stop reason to be the reason for trapping. This is extracted from the artificial frame in the debug info (similar to -fbounds-safety hard traps). * It adjusts the selected frame to be the frame where the soft trap occurred. When debug info is not available: * For the `call-with-str` soft trap mode the soft trap reason is read from the first argument register. * For the `call-minimal` soft trap mode the stop reason is adjusted to note its a bounds check failure but does not give further information because none is available. * In this situation the selected frame is not adjusted because in this mode the user will be looking at assembly and adjusting the frame makes things confusing. This patch includes shell and api tests. The shell tests seemed like the best way to test behavior when debug info is missing because those tests make it easy to disable building with debug info completely. rdar://163230807
1 parent 7b9b164 commit d061ddb

20 files changed

+998
-9
lines changed

lldb/include/lldb/lldb-enumerations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ enum InstrumentationRuntimeType {
538538
eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
539539
eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
540540
eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
541+
eInstrumentationRuntimeTypeBoundsSafety = 0x0006,
541542
eNumInstrumentationRuntimeTypes
542543
};
543544

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
add_lldb_library(lldbPluginInstrumentationRuntimeBoundsSafety PLUGIN
2+
InstrumentationRuntimeBoundsSafety.cpp
3+
4+
LINK_LIBS
5+
lldbBreakpoint
6+
lldbCore
7+
lldbSymbol
8+
lldbTarget
9+
lldbPluginInstrumentationRuntimeUtility
10+
11+
CLANG_LIBS
12+
clangCodeGen
13+
)

0 commit comments

Comments
 (0)