1 //===----- DebugUtils.h - Utilities for debugging ORC JITs ------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Utilities for debugging ORC-based JITs.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
14 #define LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H
16 #include "llvm/Support/Error.h"
26 /// A function object that can be used as an ObjectTransformLayer transform
27 /// to dump object files to disk at a specified path.
30 /// Construct a DumpObjects transform that will dump objects to disk.
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.
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 = "");
45 /// Dumps the given buffer to disk.
46 Expected<std::unique_ptr<MemoryBuffer>>
47 operator()(std::unique_ptr<MemoryBuffer> Obj);
50 StringRef getBufferIdentifier(MemoryBuffer &B);
52 std::string IdentifierOverride;
55 } // End namespace orc
56 } // End namespace llvm
58 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGUTILS_H