Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:52

0001 //===----- DebugUtils.h - Utilities for debugging ORC JITs ------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Utilities for debugging ORC-based JITs.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
0014 #define LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
0015 
0016 #include "llvm/ADT/ArrayRef.h"
0017 #include "llvm/ExecutionEngine/Orc/Core.h"
0018 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
0019 #include "llvm/Support/Error.h"
0020 #include "llvm/Support/raw_ostream.h"
0021 #include <memory>
0022 #include <string>
0023 
0024 namespace llvm {
0025 
0026 class MemoryBuffer;
0027 
0028 namespace orc {
0029 
0030 // --raw_ostream operators for ORC types--
0031 
0032 /// Render a SymbolNameSet.
0033 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
0034 
0035 /// Render a SymbolNameVector.
0036 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameVector &Symbols);
0037 
0038 /// Render an array of SymbolStringPtrs.
0039 raw_ostream &operator<<(raw_ostream &OS, ArrayRef<SymbolStringPtr> Symbols);
0040 
0041 /// Render JITSymbolFlags.
0042 raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags);
0043 
0044 /// Render a SymbolFlagsMap entry.
0045 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap::value_type &KV);
0046 
0047 /// Render a SymbolMap entry.
0048 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap::value_type &KV);
0049 
0050 /// Render a SymbolFlagsMap.
0051 raw_ostream &operator<<(raw_ostream &OS, const SymbolFlagsMap &SymbolFlags);
0052 
0053 /// Render a SymbolMap.
0054 raw_ostream &operator<<(raw_ostream &OS, const SymbolMap &Symbols);
0055 
0056 /// Render a SymbolDependenceMap entry.
0057 raw_ostream &operator<<(raw_ostream &OS,
0058                         const SymbolDependenceMap::value_type &KV);
0059 
0060 /// Render a SymbolDependendeMap.
0061 raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps);
0062 
0063 /// Render a MaterializationUnit.
0064 raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU);
0065 
0066 //// Render a JITDylibLookupFlags instance.
0067 raw_ostream &operator<<(raw_ostream &OS,
0068                         const JITDylibLookupFlags &JDLookupFlags);
0069 
0070 /// Render a SymbolLookupFlags instance.
0071 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LookupFlags);
0072 
0073 /// Render a SymbolLookupSet entry.
0074 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet::value_type &KV);
0075 
0076 /// Render a SymbolLookupSet.
0077 raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupSet &LookupSet);
0078 
0079 /// Render a JITDylibSearchOrder.
0080 raw_ostream &operator<<(raw_ostream &OS,
0081                         const JITDylibSearchOrder &SearchOrder);
0082 
0083 /// Render a SymbolAliasMap.
0084 raw_ostream &operator<<(raw_ostream &OS, const SymbolAliasMap &Aliases);
0085 
0086 /// Render a SymbolState.
0087 raw_ostream &operator<<(raw_ostream &OS, const SymbolState &S);
0088 
0089 /// Render a LookupKind.
0090 raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);
0091 
0092 /// Dump a SymbolStringPool. Useful for debugging dangling-pointer crashes.
0093 raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPool &SSP);
0094 
0095 /// A function object that can be used as an ObjectTransformLayer transform
0096 /// to dump object files to disk at a specified path.
0097 class DumpObjects {
0098 public:
0099   /// Construct a DumpObjects transform that will dump objects to disk.
0100   ///
0101   /// @param DumpDir specifies the path to write dumped objects to. DumpDir may
0102   /// be empty, in which case files will be dumped to the working directory. If
0103   /// DumpDir is non-empty then any trailing separators will be discarded.
0104   ///
0105   /// @param IdentifierOverride specifies a file name stem to use when dumping
0106   /// objects. If empty, each MemoryBuffer's identifier will be used (with a .o
0107   /// suffix added if not already present). If an identifier override is
0108   /// supplied it will be used instead (since all buffers will use the same
0109   /// identifier, the resulting files will be named <ident>.o, <ident>.2.o,
0110   /// <ident>.3.o, and so on). IdentifierOverride should not contain an
0111   /// extension, as a .o suffix will be added by DumpObjects.
0112   DumpObjects(std::string DumpDir = "", std::string IdentifierOverride = "");
0113 
0114   /// Dumps the given buffer to disk.
0115   Expected<std::unique_ptr<MemoryBuffer>>
0116   operator()(std::unique_ptr<MemoryBuffer> Obj);
0117 
0118 private:
0119   StringRef getBufferIdentifier(MemoryBuffer &B);
0120   std::string DumpDir;
0121   std::string IdentifierOverride;
0122 };
0123 
0124 } // End namespace orc
0125 } // End namespace llvm
0126 
0127 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H