LLVM  10.0.0
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/Support/Error.h"
17 #include <memory>
18 #include <string>
19 
20 namespace llvm {
21 
22 class MemoryBuffer;
23 
24 namespace orc {
25 
26 /// A function object that can be used as an ObjectTransformLayer transform
27 /// to dump object files to disk at a specified path.
28 class DumpObjects {
29 public:
30  /// Construct a DumpObjects transform that will dump objects to disk.
31  ///
32  /// @param DumpDir specifies the path to write dumped objects to. DumpDir may
33  /// be empty, in which case files will be dumped to the working directory. If
34  /// DumpDir is non-empty then any trailing separators will be discarded.
35  ///
36  /// @param IdentifierOverride specifies a file name stem to use when dumping
37  /// objects. If empty, each MemoryBuffer's identifier will be used (with a .o
38  /// suffix added if not already present). If an identifier override is
39  /// supplied it will be used instead (since all buffers will use the same
40  /// identifier, the resulting files will be named <ident>.o, <ident>.2.o,
41  /// <ident>.3.o, and so on). IdentifierOverride should not contain an
42  /// extension, as a .o suffix will be added by DumpObjects.
43  DumpObjects(std::string DumpDir = "", std::string IdentifierOverride = "");
44 
45  /// Dumps the given buffer to disk.
47  operator()(std::unique_ptr<MemoryBuffer> Obj);
48 
49 private:
50  StringRef getBufferIdentifier(MemoryBuffer &B);
51  std::string DumpDir;
52  std::string IdentifierOverride;
53 };
54 
55 } // End namespace orc
56 } // End namespace llvm
57 
58 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Expected< std::unique_ptr< MemoryBuffer > > operator()(std::unique_ptr< MemoryBuffer > Obj)
Dumps the given buffer to disk.
Definition: DebugUtils.cpp:31
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A function object that can be used as an ObjectTransformLayer transform to dump object files to disk ...
Definition: DebugUtils.h:28
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:41
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
DumpObjects(std::string DumpDir="", std::string IdentifierOverride="")
Construct a DumpObjects transform that will dump objects to disk.
Definition: DebugUtils.cpp:20