Files
clang-p2996/lldb/source/Plugins/InstrumentationRuntime/Utility/Utility.cpp
Michael Buch 1bb755fdcd [lldb][Instrumentation] GetPreferredAsanModule should be no-op on non-Darwin platforms (#132911)
The regex we use to find the compiler-rt library is already
Darwin-specific, so no need to run this on non-Darwin platforms.
2025-03-25 15:50:20 +00:00

36 lines
1002 B
C++

//===-- Utility.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Utility.h"
#include "lldb/Core/Module.h"
#include "lldb/Target/Target.h"
namespace lldb_private {
lldb::ModuleSP GetPreferredAsanModule(const Target &target) {
// Currently only supported on Darwin.
if (!target.GetArchitecture().GetTriple().isOSDarwin())
return nullptr;
lldb::ModuleSP module;
llvm::Regex pattern(R"(libclang_rt\.asan_.*_dynamic\.dylib)");
target.GetImages().ForEach([&](const lldb::ModuleSP &m) {
if (pattern.match(m->GetFileSpec().GetFilename().GetStringRef())) {
module = m;
return false;
}
return true;
});
return module;
}
} // namespace lldb_private