LLVM 22.0.0git
DebugUtils.h
Go to the documentation of this file.
1//===----- DebugUtils.h - Utilities for debugging ORC JITs ------*- 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// Utilities for debugging ORC-based JITs.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
14#define LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
15
16#include "llvm/ADT/ArrayRef.h"
20#include "llvm/Support/Error.h"
22#include <memory>
23#include <string>
24
25namespace llvm {
26
27class MemoryBuffer;
28
29namespace orc {
30
31// --raw_ostream operators for ORC types--
32
33/// Render a SymbolNameSet.
34LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
35
36/// Render a SymbolNameVector.
37LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
38 const SymbolNameVector &Symbols);
39
40/// Render an array of SymbolStringPtrs.
41LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
43
44/// Render JITSymbolFlags.
45LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags);
46
47/// Render a SymbolFlagsMap entry.
48LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
50
51/// Render a SymbolMap entry.
52LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
53 const SymbolMap::value_type &KV);
54
55/// Render a SymbolFlagsMap.
56LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
57 const SymbolFlagsMap &SymbolFlags);
58
59/// Render a SymbolMap.
60LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
61
62/// Render a SymbolDependenceMap entry.
63LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
65
66/// Render a SymbolDependendeMap.
67LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
68 const SymbolDependenceMap &Deps);
69
70/// Render a MaterializationUnit.
71LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
72 const MaterializationUnit &MU);
73
74//// Render a JITDylibLookupFlags instance.
75LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
76 const JITDylibLookupFlags &JDLookupFlags);
77
78/// Render a SymbolLookupFlags instance.
79LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
80 const SymbolLookupFlags &LookupFlags);
81
82/// Render a SymbolLookupSet entry.
83LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
85
86/// Render a SymbolLookupSet.
87LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
88 const SymbolLookupSet &LookupSet);
89
90/// Render a JITDylibSearchOrder.
91LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
92 const JITDylibSearchOrder &SearchOrder);
93
94/// Render a SymbolAliasMap.
95LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
96 const SymbolAliasMap &Aliases);
97
98/// Render a SymbolState.
99LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SymbolState &S);
100
101/// Render a LookupKind.
102LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
103
104/// Dump a SymbolStringPool. Useful for debugging dangling-pointer crashes.
105LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPool &SSP);
106
107/// A function object that can be used as an ObjectTransformLayer transform
108/// to dump object files to disk at a specified path.
110public:
111 /// Construct a DumpObjects transform that will dump objects to disk.
112 ///
113 /// @param DumpDir specifies the path to write dumped objects to. DumpDir may
114 /// be empty, in which case files will be dumped to the working directory. If
115 /// DumpDir is non-empty then any trailing separators will be discarded.
116 ///
117 /// @param IdentifierOverride specifies a file name stem to use when dumping
118 /// objects. If empty, each MemoryBuffer's identifier will be used (with a .o
119 /// suffix added if not already present). If an identifier override is
120 /// supplied it will be used instead (since all buffers will use the same
121 /// identifier, the resulting files will be named <ident>.o, <ident>.2.o,
122 /// <ident>.3.o, and so on). IdentifierOverride should not contain an
123 /// extension, as a .o suffix will be added by DumpObjects.
124 LLVM_ABI DumpObjects(std::string DumpDir = "",
125 std::string IdentifierOverride = "");
126
127 /// Dumps the given buffer to disk.
129 operator()(std::unique_ptr<MemoryBuffer> Obj);
130
131private:
132 StringRef getBufferIdentifier(MemoryBuffer &B);
133 std::string DumpDir;
134 std::string IdentifierOverride;
135};
136
137} // End namespace orc
138} // End namespace llvm
139
140#endif // LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
BucketT value_type
Definition DenseMap.h:72
Tagged union holding either a T or a Error.
Definition Error.h:485
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
LLVM_ABI Expected< std::unique_ptr< MemoryBuffer > > operator()(std::unique_ptr< MemoryBuffer > Obj)
Dumps the given buffer to disk.
LLVM_ABI DumpObjects(std::string DumpDir="", std::string IdentifierOverride="")
Construct a DumpObjects transform that will dump objects to disk.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition Core.h:195
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
Definition Core.h:197
String pool for symbol names used by the JIT.
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
Definition Core.h:173
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const SymbolNameSet &Symbols)
Render a SymbolNameSet.
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
Definition Core.h:157
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition Core.h:147
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LookupKind
Describes the kind of lookup being performed.
Definition Core.h:169
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
SymbolState
Represents the state that a symbol has reached during materialization.
Definition Core.h:772
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:413
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef(const T &OneElt) -> ArrayRef< T >