LLDB mainline
ExternalSymbolResolver.h
Go to the documentation of this file.
1//===-- ExternalSymbolResolver.h --------------------------------*- C++ -*-===//
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#ifndef LLDB_EXPRESSION_EXTERNALSYMBOLRESOLVER_H
10#define LLDB_EXPRESSION_EXTERNALSYMBOLRESOLVER_H
11
12#include <vector>
13
17#include "lldb/lldb-types.h"
18
19namespace lldb_private {
20
21/// \class ExternalSymbolResolver ExternalSymbolResolver.h
22/// "lldb/Expression/ExternalSymbolResolver.h" Finds the load addresses of
23/// symbols that an expression refers to but does not define.
24///
25/// An expression's IR refers by name to functions and variables that live
26/// outside the expression's own module. Finding the address for such a name is
27/// not a simple lookup: the name may be an LLDB function call label, it may
28/// need alternate manglings tried, and it may be satisfied by the target's
29/// images, by a language runtime, or by a symbol that a previous expression
30/// defined (see Target::GetPersistentSymbol).
32public:
33 /// Constructor
34 ///
35 /// \param[in] sym_ctx
36 /// The symbol context to search from. Its module, if any, is searched
37 /// before all others.
38 ///
39 /// \param[in] strip_underscore
40 /// True for platforms where global symbols have a _ prefix, in which case
41 /// the name with that prefix removed is also tried.
42 ExternalSymbolResolver(const SymbolContext &sym_ctx, bool strip_underscore);
43
44 /// Search the modules of \p contexts before any others, except for the
45 /// module of the symbol context this resolver was constructed with.
47 for (auto const &ctx : contexts)
48 if (ctx.module_sp)
49 m_preferred_modules.Append(ctx.module_sp);
50 }
51
52 /// Find the load address of \p name.
53 ///
54 /// \param[out] missing_weak
55 /// Set to true if \p name was only found as a weak undefined symbol, in
56 /// which case the returned address is 0.
57 ///
58 /// \return
59 /// The load address, or LLDB_INVALID_ADDRESS if \p name was not found.
60 lldb::addr_t FindSymbol(ConstString name, bool &missing_weak);
61
62private:
63 void CollectCandidateCNames(std::vector<ConstString> &C_names,
64 ConstString name);
65
66 void CollectCandidateCPlusPlusNames(std::vector<ConstString> &CPP_names,
67 const std::vector<ConstString> &C_names,
68 const SymbolContext &sc);
69
70 lldb::addr_t FindInSymbols(const std::vector<ConstString> &names,
72 bool &symbol_was_missing_weak);
73
74 lldb::addr_t FindInRuntimes(const std::vector<ConstString> &names,
76
77 lldb::addr_t FindInUserDefinedSymbols(const std::vector<ConstString> &names,
79
80 SymbolContext m_sym_ctx; ///< Used for symbol lookups
81
82 bool m_strip_underscore; ///< True for platforms where global symbols have a
83 /// _ prefix
84
85 /// Any Module in this list will be used for symbol/function lookup before
86 /// any other module (except for the module corresponding to the current
87 /// frame).
89};
90
91} // namespace lldb_private
92
93#endif // LLDB_EXPRESSION_EXTERNALSYMBOLRESOLVER_H
A uniqued constant string class.
Definition ConstString.h:40
ExternalSymbolResolver(const SymbolContext &sym_ctx, bool strip_underscore)
Constructor.
SymbolContext m_sym_ctx
Used for symbol lookups.
lldb::addr_t FindSymbol(ConstString name, bool &missing_weak)
Find the load address of name.
lldb::addr_t FindInSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc, bool &symbol_was_missing_weak)
lldb::addr_t FindInUserDefinedSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
lldb::addr_t FindInRuntimes(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
void AppendPreferredSymbolContexts(SymbolContextList const &contexts)
Search the modules of contexts before any others, except for the module of the symbol context this re...
ModuleList m_preferred_modules
Any Module in this list will be used for symbol/function lookup before any other module (except for t...
void CollectCandidateCPlusPlusNames(std::vector< ConstString > &CPP_names, const std::vector< ConstString > &C_names, const SymbolContext &sc)
bool m_strip_underscore
True for platforms where global symbols have a _ prefix.
void CollectCandidateCNames(std::vector< ConstString > &C_names, ConstString name)
A collection class for Module objects.
Definition ModuleList.h:127
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80