@@ -35,12 +35,14 @@ using namespace lldb_private;
3535
3636LLDB_PLUGIN_DEFINE (InstrumentationRuntimeBoundsSafety)
3737
38- #define BOUNDS_SAFETY_SOFT_TRAP_MINIMAL " __bounds_safety_soft_trap"
39- #define BOUNDS_SAFETY_SOFT_TRAP_S " __bounds_safety_soft_trap_s"
38+ constexpr llvm::StringLiteral
39+ BoundsSafetySoftTrapMinimal(" __bounds_safety_soft_trap" );
40+ constexpr llvm::StringLiteral
41+ BoundsSafetySoftTrapStr (" __bounds_safety_soft_trap_s" );
4042
4143const std::vector<std::string> &getBoundsSafetySoftTrapRuntimeFuncs () {
42- static std::vector<std::string> Funcs = {BOUNDS_SAFETY_SOFT_TRAP_MINIMAL ,
43- BOUNDS_SAFETY_SOFT_TRAP_S };
44+ static std::vector<std::string> Funcs = {BoundsSafetySoftTrapMinimal. str () ,
45+ BoundsSafetySoftTrapStr. str () };
4446
4547 return Funcs;
4648}
@@ -210,7 +212,7 @@ InstrumentationBoundsSafetyStopInfo::
210212 }
211213 llvm::StringRef trap_reason_func_name = softtrap_sf->GetFunctionName ();
212214
213- if (trap_reason_func_name == BOUNDS_SAFETY_SOFT_TRAP_MINIMAL ) {
215+ if (trap_reason_func_name == BoundsSafetySoftTrapMinimal ) {
214216 // This function has no arguments so there's no additional information
215217 // that would allow us to identify the trap reason.
216218 //
@@ -227,21 +229,22 @@ InstrumentationBoundsSafetyStopInfo::
227229 // This makes it look we stopped after finishing the call to
228230 // `__bounds_safety_soft_trap` but actually we are in the middle of the
229231 // call. To avoid this confusion just use the current frame.
230- Debugger::ReportWarning (
231- " specific BoundsSafety trap reason is not available because debug "
232- " info is missing on the caller of '" BOUNDS_SAFETY_SOFT_TRAP_MINIMAL
233- " '" ,
234- debugger_id);
232+ std::string warning;
233+ llvm::raw_string_ostream ss (warning);
234+ ss << " specific BoundsSafety trap reason is not available because debug "
235+ " info is missing on the caller of '"
236+ << BoundsSafetySoftTrapMinimal << " '" ;
237+ Debugger::ReportWarning (warning.c_str (), debugger_id);
235238 warning_emitted_for_failure = true ;
236239 return {};
237240 }
238241
239- // BOUNDS_SAFETY_SOFT_TRAP_S has one argument which is a pointer to a string
242+ // __bounds_safety_soft_trap_s has one argument which is a pointer to a string
240243 // describing the trap or a nullptr.
241- if (trap_reason_func_name != BOUNDS_SAFETY_SOFT_TRAP_S ) {
244+ if (trap_reason_func_name != BoundsSafetySoftTrapStr ) {
242245 LLDB_LOGF (log_category,
243246 " unexpected function name. Expected \" %s\" but got \" %s\" " ,
244- BOUNDS_SAFETY_SOFT_TRAP_S , trap_reason_func_name.data ());
247+ BoundsSafetySoftTrapStr. data () , trap_reason_func_name.data ());
245248 assert (0 && " hit breakpoint for unexpected function name" );
246249 return {};
247250 }
@@ -266,15 +269,18 @@ InstrumentationBoundsSafetyStopInfo::
266269 case ArchSpec::eCore_x86_32_i386:
267270 case ArchSpec::eCore_x86_32_i486:
268271 case ArchSpec::eCore_x86_32_i486sx:
269- case ArchSpec::eCore_x86_32_i686:
272+ case ArchSpec::eCore_x86_32_i686: {
270273 // Technically some x86 calling conventions do use a register for
271274 // passing the first argument but let's ignore that for now.
272- Debugger::ReportWarning (
273- " specific BoundsSafety trap reason cannot be inferred on x86 when "
274- " the caller of '" BOUNDS_SAFETY_SOFT_TRAP_S " ' is missing debug info" ,
275- debugger_id);
275+ std::string warning;
276+ llvm::raw_string_ostream ss (warning);
277+ ss << " specific BoundsSafety trap reason cannot be inferred on x86 when "
278+ " the caller of '"
279+ << BoundsSafetySoftTrapStr << " ' is missing debug info" ;
280+ Debugger::ReportWarning (warning.c_str (), debugger_id);
276281 warning_emitted_for_failure = true ;
277282 return {};
283+ }
278284 default : {
279285 }
280286 };
@@ -330,7 +336,7 @@ InstrumentationBoundsSafetyStopInfo::
330336 SS << " : " << out_string;
331337 }
332338 // Use the current frame as the suggested frame for the same reason as for
333- // `BOUNDS_SAFETY_SOFT_TRAP_MINIMAL `.
339+ // `__bounds_safety_soft_trap `.
334340 return {stop_reason, 0 };
335341}
336342
0 commit comments