Skip to content

Commit dddf06d

Browse files
committed
Try to use constexpr std::array for getBoundsSafetySoftTrapRuntimeFuncs
1 parent 997594a commit dddf06d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lldb/source/Plugins/InstrumentationRuntime/BoundsSafety/InstrumentationRuntimeBoundsSafety.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ constexpr llvm::StringLiteral
4141
constexpr llvm::StringLiteral
4242
BoundsSafetySoftTrapStr("__bounds_safety_soft_trap_s");
4343

44-
const std::vector<std::string> &getBoundsSafetySoftTrapRuntimeFuncs() {
45-
static std::vector<std::string> Funcs = {BoundsSafetySoftTrapMinimal.str(),
46-
BoundsSafetySoftTrapStr.str()};
47-
48-
return Funcs;
44+
constexpr std::array<llvm::StringLiteral, 2>
45+
getBoundsSafetySoftTrapRuntimeFuncs() {
46+
return {BoundsSafetySoftTrapMinimal, BoundsSafetySoftTrapStr};
4947
}
5048

5149
#define SOFT_TRAP_CATEGORY_PREFIX "Soft "
@@ -374,14 +372,15 @@ bool InstrumentationRuntimeBoundsSafety::CheckIfRuntimeIsValid(
374372

375373
if (module_sp->FindFirstSymbolWithNameAndType(test_sym,
376374
lldb::eSymbolTypeAny)) {
377-
LLDB_LOG(log_category, "found \"{0}\" in {1}", SoftTrapFunc.c_str(),
378-
module_sp->GetObjectName().AsCString("<unknown>"));
375+
LLDB_LOG(log_category, "found \"{0}\" in {1}",
376+
test_sym.AsCString("<unknown symbol>"),
377+
module_sp->GetObjectName().AsCString("<unknown module>"));
379378
return true;
380379
}
381380
}
382381
LLDB_LOG(log_category,
383382
"did not find BoundsSafety soft trap functions in module {0}",
384-
module_sp->GetObjectName().AsCString("<unknown>"));
383+
module_sp->GetObjectName().AsCString("<unknown module>"));
385384
return false;
386385
}
387386

@@ -429,10 +428,14 @@ void InstrumentationRuntimeBoundsSafety::Activate() {
429428
if (!process_sp)
430429
return LogBeforeReturn<void>("could not get process during Activate()");
431430

431+
std::vector<std::string> breakpoints;
432+
for (auto &breakpoint_func : getBoundsSafetySoftTrapRuntimeFuncs())
433+
breakpoints.emplace_back(breakpoint_func);
434+
432435
BreakpointSP breakpoint = process_sp->GetTarget().CreateBreakpoint(
433436
/*containingModules=*/nullptr,
434-
/*containingSourceFiles=*/nullptr, getBoundsSafetySoftTrapRuntimeFuncs(),
435-
eFunctionNameTypeFull, eLanguageTypeUnknown,
437+
/*containingSourceFiles=*/nullptr, breakpoints, eFunctionNameTypeFull,
438+
eLanguageTypeUnknown,
436439
/*m_offset=*/0,
437440
/*skip_prologue*/ eLazyBoolNo,
438441
/*internal=*/true,

0 commit comments

Comments
 (0)