Path: blob/main/contrib/llvm-project/lldb/source/Target/InstrumentationRuntime.cpp
39587 views
//===-- InstrumentationRuntime.cpp ----------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===---------------------------------------------------------------------===//78#include "lldb/Target/InstrumentationRuntime.h"9#include "lldb/Core/Module.h"10#include "lldb/Core/ModuleList.h"11#include "lldb/Core/PluginManager.h"12#include "lldb/Target/Process.h"13#include "lldb/Utility/RegularExpression.h"14#include "lldb/lldb-private.h"1516using namespace lldb;17using namespace lldb_private;1819void InstrumentationRuntime::ModulesDidLoad(20lldb_private::ModuleList &module_list, lldb_private::Process *process,21InstrumentationRuntimeCollection &runtimes) {22InstrumentationRuntimeCreateInstance create_callback = nullptr;23InstrumentationRuntimeGetType get_type_callback;24for (uint32_t idx = 0;; ++idx) {25create_callback =26PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(idx);27if (create_callback == nullptr)28break;29get_type_callback =30PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(idx);31InstrumentationRuntimeType type = get_type_callback();3233InstrumentationRuntimeCollection::iterator pos;34pos = runtimes.find(type);35if (pos == runtimes.end()) {36runtimes[type] = create_callback(process->shared_from_this());37}38}39}4041void InstrumentationRuntime::ModulesDidLoad(42lldb_private::ModuleList &module_list) {43if (IsActive())44return;4546if (GetRuntimeModuleSP()) {47Activate();48return;49}5051module_list.ForEach([this](const lldb::ModuleSP module_sp) -> bool {52const FileSpec &file_spec = module_sp->GetFileSpec();53if (!file_spec)54return true; // Keep iterating.5556const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary();57if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) ||58module_sp->IsExecutable()) {59if (CheckIfRuntimeIsValid(module_sp)) {60SetRuntimeModuleSP(module_sp);61Activate();62if (!IsActive())63SetRuntimeModuleSP({}); // Don't cache module if activation failed.64return false; // Stop iterating, we're done.65}66}6768return true;69});70}7172lldb::ThreadCollectionSP73InstrumentationRuntime::GetBacktracesFromExtendedStopInfo(74StructuredData::ObjectSP info) {75return ThreadCollectionSP(new ThreadCollection());76}777879