1 //===-- ObjectFileMinidump.h ---------------------------------- -*- 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 /// \file 10 /// Placeholder plugin for the save core functionality. 11 /// 12 /// ObjectFileMinidump is created only to be able to save minidump core files 13 /// from existing processes with the ObjectFileMinidump::SaveCore function. 14 /// Minidump files are not ObjectFile objects, but they are core files and 15 /// currently LLDB's ObjectFile plug-ins handle emitting core files. If the 16 /// core file saving ever moves into a new plug-in type within LLDB, this code 17 /// should move as well, but for now this is the best place architecturally. 18 //===----------------------------------------------------------------------===// 19 20 #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H 21 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H 22 23 #include "lldb/Symbol/ObjectFile.h" 24 #include "lldb/Utility/ArchSpec.h" 25 26 class ObjectFileMinidump : public lldb_private::PluginInterface { 27 public: 28 // Static Functions 29 static void Initialize(); 30 static void Terminate(); 31 32 static lldb_private::ConstString GetPluginNameStatic(); 33 static const char *GetPluginDescriptionStatic() { 34 return "Minidump object file."; 35 } 36 37 // PluginInterface protocol 38 lldb_private::ConstString GetPluginName() override { 39 return GetPluginNameStatic(); 40 } 41 42 static lldb_private::ObjectFile * 43 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, 44 lldb::offset_t data_offset, const lldb_private::FileSpec *file, 45 lldb::offset_t offset, lldb::offset_t length); 46 47 static lldb_private::ObjectFile *CreateMemoryInstance( 48 const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, 49 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr); 50 51 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, 52 lldb::DataBufferSP &data_sp, 53 lldb::offset_t data_offset, 54 lldb::offset_t file_offset, 55 lldb::offset_t length, 56 lldb_private::ModuleSpecList &specs); 57 58 // Saves dump in Minidump file format 59 static bool SaveCore(const lldb::ProcessSP &process_sp, 60 const lldb_private::FileSpec &outfile, 61 lldb::SaveCoreStyle &core_style, 62 lldb_private::Status &error); 63 64 private: 65 ObjectFileMinidump() = default; 66 }; 67 68 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H 69