1 //===-- InstrumentationRuntime.cpp ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===---------------------------------------------------------------------===//
10 #include "lldb/Target/InstrumentationRuntime.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleList.h"
13 #include "lldb/Core/PluginManager.h"
14 #include "lldb/Target/Process.h"
15 #include "lldb/Utility/RegularExpression.h"
16 #include "lldb/lldb-private.h"
19 using namespace lldb_private;
21 void InstrumentationRuntime::ModulesDidLoad(
22 lldb_private::ModuleList &module_list, lldb_private::Process *process,
23 InstrumentationRuntimeCollection &runtimes) {
24 InstrumentationRuntimeCreateInstance create_callback = nullptr;
25 InstrumentationRuntimeGetType get_type_callback;
26 for (uint32_t idx = 0;; ++idx) {
28 PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(idx);
29 if (create_callback == nullptr)
32 PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(idx);
33 InstrumentationRuntimeType type = get_type_callback();
35 InstrumentationRuntimeCollection::iterator pos;
36 pos = runtimes.find(type);
37 if (pos == runtimes.end()) {
38 runtimes[type] = create_callback(process->shared_from_this());
43 void InstrumentationRuntime::ModulesDidLoad(
44 lldb_private::ModuleList &module_list) {
48 if (GetRuntimeModuleSP()) {
53 module_list.ForEach([this](const lldb::ModuleSP module_sp) -> bool {
54 const FileSpec &file_spec = module_sp->GetFileSpec();
56 return true; // Keep iterating.
58 const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary();
59 if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) ||
60 module_sp->IsExecutable()) {
61 if (CheckIfRuntimeIsValid(module_sp)) {
62 SetRuntimeModuleSP(module_sp);
64 return false; // Stop iterating, we're done.
72 lldb::ThreadCollectionSP
73 InstrumentationRuntime::GetBacktracesFromExtendedStopInfo(
74 StructuredData::ObjectSP info) {
75 return ThreadCollectionSP(new ThreadCollection());