LLDB mainline
SymbolFileJSON.cpp
Go to the documentation of this file.
1//===-- SymbolFileJSON.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 "SymbolFileJSON.h"
10
12#include "lldb/Core/Module.h"
17#include "lldb/Symbol/Symbol.h"
19#include "lldb/Symbol/Symtab.h"
22#include "lldb/Utility/Log.h"
24#include "lldb/Utility/Timer.h"
25#include "llvm/Support/MemoryBuffer.h"
26
27#include <memory>
28#include <optional>
29
30using namespace llvm;
31using namespace lldb;
32using namespace lldb_private;
33
35
37
39 : SymbolFileCommon(std::move(objfile_sp)) {}
40
44}
45
48}
49
51 return "Reads debug symbols from a JSON symbol table.";
52}
53
55 return new SymbolFileJSON(std::move(objfile_sp));
56}
57
59 if (!m_objfile_sp || !llvm::isa<ObjectFileJSON>(*m_objfile_sp))
60 return 0;
61
63}
64
66 SymbolContextItem resolve_scope,
67 SymbolContext &sc) {
68 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
69 if (m_objfile_sp->GetSymtab() == nullptr)
70 return 0;
71
72 uint32_t resolved_flags = 0;
73 if (resolve_scope & eSymbolContextSymbol) {
74 sc.symbol = m_objfile_sp->GetSymtab()->FindSymbolContainingFileAddress(
75 so_addr.GetFileAddress());
76 if (sc.symbol)
77 resolved_flags |= eSymbolContextSymbol;
78 }
79 return resolved_flags;
80}
81
83
84void SymbolFileJSON::GetTypes(SymbolContextScope *sc_scope, TypeClass type_mask,
85 lldb_private::TypeList &type_list) {}
86
88 if (!m_objfile_sp)
89 return;
90
91 Symtab *json_symtab = m_objfile_sp->GetSymtab();
92 if (!json_symtab)
93 return;
94
95 if (&symtab == json_symtab)
96 return;
97
98 // Merge the two symbol tables.
99 const size_t num_new_symbols = json_symtab->GetNumSymbols();
100 for (size_t i = 0; i < num_new_symbols; ++i) {
101 Symbol *s = json_symtab->SymbolAtIndex(i);
102 symtab.AddSymbol(*s);
103 }
104 symtab.Finalize();
105}
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:32
A section + offset based address class.
Definition: Address.h:62
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:293
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
Symbol * symbol
The Symbol for a given query.
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:504
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolFile.h:609
static char ID
LLVM RTTI support.
SymbolFileJSON(lldb::ObjectFileSP objfile_sp)
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
void AddSymbols(Symtab &symtab) override
static llvm::StringRef GetPluginNameStatic()
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
uint32_t CalculateAbilities() override
static llvm::StringRef GetPluginDescriptionStatic()
static lldb_private::SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:50
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Definition: SymbolFile.cpp:36
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:228
uint32_t AddSymbol(const Symbol &symbol)
Definition: Symtab.cpp:64
size_t GetNumSymbols() const
Definition: Symtab.cpp:77
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
Definition: lldb-forward.h:373
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Definition: lldb-forward.h:333
Definition: Debugger.h:54