Path: blob/main/contrib/llvm-project/lldb/source/Symbol/SymbolVendor.cpp
39587 views
//===-- SymbolVendor.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/Symbol/SymbolVendor.h"910#include "lldb/Core/Module.h"11#include "lldb/Core/PluginManager.h"12#include "lldb/Symbol/CompileUnit.h"13#include "lldb/Symbol/ObjectFile.h"14#include "lldb/Symbol/SymbolFile.h"15#include "lldb/Utility/Stream.h"1617using namespace lldb;18using namespace lldb_private;1920// FindPlugin21//22// Platforms can register a callback to use when creating symbol vendors to23// allow for complex debug information file setups, and to also allow for24// finding separate debug information files.25SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,26lldb_private::Stream *feedback_strm) {27std::unique_ptr<SymbolVendor> instance_up;28SymbolVendorCreateInstance create_callback;2930for (size_t idx = 0;31(create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(32idx)) != nullptr;33++idx) {34instance_up.reset(create_callback(module_sp, feedback_strm));3536if (instance_up) {37return instance_up.release();38}39}40// The default implementation just tries to create debug information using41// the file representation for the module.42ObjectFileSP sym_objfile_sp;43FileSpec sym_spec = module_sp->GetSymbolFileFileSpec();44if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) {45DataBufferSP data_sp;46offset_t data_offset = 0;47sym_objfile_sp = ObjectFile::FindPlugin(48module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec),49data_sp, data_offset);50}51if (!sym_objfile_sp)52sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();53instance_up = std::make_unique<SymbolVendor>(module_sp);54instance_up->AddSymbolFileRepresentation(sym_objfile_sp);55return instance_up.release();56}5758// SymbolVendor constructor59SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)60: ModuleChild(module_sp), m_sym_file_up() {}6162// Add a representation given an object file.63void SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) {64ModuleSP module_sp(GetModule());65if (module_sp) {66std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());67if (objfile_sp)68m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp));69}70}717273