LLVM  14.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"
19 #include "llvm/Support/Error.h"
21 #include <memory>
22 #include <string>
23 
24 namespace llvm {
25 
26 class MemoryBuffer;
27 
28 namespace orc {
29 
30 // --raw_ostream operators for ORC types--
31 
32 /// Render a SymbolStringPtr.
33 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
34 
35 /// Render a SymbolNameSet.
36 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
37 
38 /// Render a SymbolNameVector.
39 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameVector &Symbols);
40 
41 /// Render an array of SymbolStringPtrs.
42 raw_ostream &operator<<(raw_ostream &OS, ArrayRef<SymbolStringPtr> Symbols);
43 
44 /// Render JITSymbolFlags.
45 raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags);
46 
47 /// Render a SymbolFlagsMap entry.
48 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
49 
50 /// Render a SymbolMap entry.
51 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
52 
53 /// Render a SymbolFlagsMap.
54 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
55 
56 /// Render a SymbolMap.
57 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
58 
59 /// Render a SymbolDependenceMap entry.
60 raw_ostream &operator<<(raw_ostream &OS,
62 
63 /// Render a SymbolDependendeMap.
64 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
65 
66 /// Render a MaterializationUnit.
67 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
68 
69 //// Render a JITDylibLookupFlags instance.
70 raw_ostream &operator<<(raw_ostream &OS,
71  const JITDylibLookupFlags &JDLookupFlags);
72 
73 /// Rendar a SymbolLookupFlags instance.
74 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LookupFlags);
75 
76 /// Render a JITDylibLookupFlags instance.
77 raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
78 
79 /// Render a SymbolLookupSet entry.
80 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet::value_type &KV);
81 
82 /// Render a SymbolLookupSet.
83 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet &LookupSet);
84 
85 /// Render a JITDylibSearchOrder.
86 raw_ostream &operator<<(raw_ostream &OS,
87  const JITDylibSearchOrder &SearchOrder);
88 
89 /// Render a SymbolAliasMap.
90 raw_ostream &operator<<(raw_ostream &OS, const SymbolAliasMap &Aliases);
91 
92 /// Render a SymbolState.
93 raw_ostream &operator<<(raw_ostream &OS, const SymbolState &S);
94 
95 /// Render a LookupKind.
96 raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
97 
98 /// A function object that can be used as an ObjectTransformLayer transform
99 /// to dump object files to disk at a specified path.
100 class DumpObjects {
101 public:
102  /// Construct a DumpObjects transform that will dump objects to disk.
103  ///
104  /// @param DumpDir specifies the path to write dumped objects to. DumpDir may
105  /// be empty, in which case files will be dumped to the working directory. If
106  /// DumpDir is non-empty then any trailing separators will be discarded.
107  ///
108  /// @param IdentifierOverride specifies a file name stem to use when dumping
109  /// objects. If empty, each MemoryBuffer's identifier will be used (with a .o
110  /// suffix added if not already present). If an identifier override is
111  /// supplied it will be used instead (since all buffers will use the same
112  /// identifier, the resulting files will be named <ident>.o, <ident>.2.o,
113  /// <ident>.3.o, and so on). IdentifierOverride should not contain an
114  /// extension, as a .o suffix will be added by DumpObjects.
115  DumpObjects(std::string DumpDir = "", std::string IdentifierOverride = "");
116 
117  /// Dumps the given buffer to disk.
119  operator()(std::unique_ptr<MemoryBuffer> Obj);
120 
121 private:
122  StringRef getBufferIdentifier(MemoryBuffer &B);
123  std::string DumpDir;
124  std::string IdentifierOverride;
125 };
126 
127 } // End namespace orc
128 } // End namespace llvm
129 
130 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
llvm::orc::operator<<
raw_ostream & operator<<(raw_ostream &OS, const SymbolStringPtr &Sym)
Render a SymbolStringPtr.
Definition: DebugUtils.cpp:141
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::orc::DumpObjects::DumpObjects
DumpObjects(std::string DumpDir="", std::string IdentifierOverride="")
Construct a DumpObjects transform that will dump objects to disk.
Definition: DebugUtils.cpp:300
Error.h
llvm::orc::DumpObjects::operator()
Expected< std::unique_ptr< MemoryBuffer > > operator()(std::unique_ptr< MemoryBuffer > Obj)
Dumps the given buffer to disk.
Definition: DebugUtils.cpp:311
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::orc::LookupKind
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:148
llvm::MachO::SymbolFlags
SymbolFlags
Symbol flags.
Definition: Symbol.h:25
llvm::MemoryBuffer
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:50
llvm::orc::SymbolState
SymbolState
Represents the state that a symbol has reached during materialization.
Definition: Core.h:799
SymbolStringPool.h
llvm::orc::SymbolLookupFlags
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
Definition: Core.h:136
llvm::orc::SymbolMap
DenseMap< SymbolStringPtr, JITEvaluatedSymbol > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
Definition: Core.h:112
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::orc::SymbolAliasMap
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition: Core.h:391
llvm::orc::SymbolLookupSet::value_type
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
Definition: Core.h:176
llvm::DenseMapBase< DenseMap< SymbolStringPtr, JITSymbolFlags, DenseMapInfo< SymbolStringPtr >, llvm::detail::DenseMapPair< SymbolStringPtr, JITSymbolFlags > >, SymbolStringPtr, JITSymbolFlags, DenseMapInfo< SymbolStringPtr >, llvm::detail::DenseMapPair< SymbolStringPtr, JITSymbolFlags > >::value_type
llvm::detail::DenseMapPair< SymbolStringPtr, JITSymbolFlags > value_type
Definition: DenseMap.h:68
ArrayRef.h
llvm::orc::JITDylibSearchOrder
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:153
llvm::orc::DumpObjects
A function object that can be used as an ObjectTransformLayer transform to dump object files to disk ...
Definition: DebugUtils.h:100
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::orc::SymbolDependenceMap
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
Definition: Core.h:118
llvm::orc::SymbolFlagsMap
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:115
Core.h
llvm::orc::SymbolNameSet
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
Definition: Core.h:105
llvm::orc::JITDylibLookupFlags
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:126
raw_ostream.h
llvm::orc::SymbolNameVector
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
Definition: Core.h:108