1//===-- Utility.cpp -------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "Utility.h"
10
11#include "lldb/Core/Module.h"
12#include "lldb/Target/Target.h"
13
14namespace lldb_private {
15
16lldb::ModuleSP GetPreferredAsanModule(const Target &target) {
17 // Currently only supported on Darwin.
18 if (!target.GetArchitecture().GetTriple().isOSDarwin())
19 return nullptr;
20
21 lldb::ModuleSP module;
22 llvm::Regex pattern(R"(libclang_rt\.asan_.*_dynamic\.dylib)");
23 target.GetImages().ForEach(callback: [&](const lldb::ModuleSP &m) {
24 if (pattern.match(String: m->GetFileSpec().GetFilename().GetStringRef())) {
25 module = m;
26 return false;
27 }
28
29 return true;
30 });
31
32 return module;
33}
34
35} // namespace lldb_private
36

source code of lldb/source/Plugins/InstrumentationRuntime/Utility/Utility.cpp