xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1349cc55cSDimitry Andric //===-- ObjectFileMinidump.h ---------------------------------- -*- C++ -*-===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric //
9349cc55cSDimitry Andric /// \file
10349cc55cSDimitry Andric /// Placeholder plugin for the save core functionality.
11349cc55cSDimitry Andric ///
12349cc55cSDimitry Andric /// ObjectFileMinidump is created only to be able to save minidump core files
13349cc55cSDimitry Andric /// from existing processes with the ObjectFileMinidump::SaveCore function.
14349cc55cSDimitry Andric /// Minidump files are not ObjectFile objects, but they are core files and
15349cc55cSDimitry Andric /// currently LLDB's ObjectFile plug-ins handle emitting core files. If the
16349cc55cSDimitry Andric /// core file saving ever moves into a new plug-in type within LLDB, this code
17349cc55cSDimitry Andric /// should move as well, but for now this is the best place architecturally.
18349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
19349cc55cSDimitry Andric 
20349cc55cSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H
21349cc55cSDimitry Andric #define LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H
22349cc55cSDimitry Andric 
23349cc55cSDimitry Andric #include "lldb/Symbol/ObjectFile.h"
24349cc55cSDimitry Andric #include "lldb/Utility/ArchSpec.h"
25349cc55cSDimitry Andric 
26349cc55cSDimitry Andric class ObjectFileMinidump : public lldb_private::PluginInterface {
27349cc55cSDimitry Andric public:
28349cc55cSDimitry Andric   // Static Functions
29349cc55cSDimitry Andric   static void Initialize();
30349cc55cSDimitry Andric   static void Terminate();
31349cc55cSDimitry Andric 
32349cc55cSDimitry Andric   static llvm::StringRef GetPluginNameStatic() { return "minidump"; }
33349cc55cSDimitry Andric   static const char *GetPluginDescriptionStatic() {
34349cc55cSDimitry Andric     return "Minidump object file.";
35349cc55cSDimitry Andric   }
36349cc55cSDimitry Andric 
37349cc55cSDimitry Andric   // PluginInterface protocol
38349cc55cSDimitry Andric   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
39349cc55cSDimitry Andric 
40349cc55cSDimitry Andric   static lldb_private::ObjectFile *
4181ad6265SDimitry Andric   CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
42349cc55cSDimitry Andric                  lldb::offset_t data_offset, const lldb_private::FileSpec *file,
43349cc55cSDimitry Andric                  lldb::offset_t offset, lldb::offset_t length);
44349cc55cSDimitry Andric 
45349cc55cSDimitry Andric   static lldb_private::ObjectFile *CreateMemoryInstance(
4681ad6265SDimitry Andric       const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
47349cc55cSDimitry Andric       const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
48349cc55cSDimitry Andric 
49349cc55cSDimitry Andric   static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
50349cc55cSDimitry Andric                                         lldb::DataBufferSP &data_sp,
51349cc55cSDimitry Andric                                         lldb::offset_t data_offset,
52349cc55cSDimitry Andric                                         lldb::offset_t file_offset,
53349cc55cSDimitry Andric                                         lldb::offset_t length,
54349cc55cSDimitry Andric                                         lldb_private::ModuleSpecList &specs);
55349cc55cSDimitry Andric 
56349cc55cSDimitry Andric   // Saves dump in Minidump file format
57349cc55cSDimitry Andric   static bool SaveCore(const lldb::ProcessSP &process_sp,
58*0fca6ea1SDimitry Andric                        const lldb_private::SaveCoreOptions &options,
59349cc55cSDimitry Andric                        lldb_private::Status &error);
60349cc55cSDimitry Andric 
61349cc55cSDimitry Andric private:
62349cc55cSDimitry Andric   ObjectFileMinidump() = default;
63349cc55cSDimitry Andric };
64349cc55cSDimitry Andric 
65349cc55cSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H
66