virtual uint32_t
GetSDKVersion (uint32_t *versions, uint32_t num_versions);
-
-protected:
-
+
static bool
ParseHeader (lldb_private::DataExtractor &data,
lldb::offset_t *data_offset_ptr,
llvm::MachO::mach_header &header);
+protected:
static bool
GetUUID (const llvm::MachO::mach_header &header,
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/DynamicLoader.h"
+
+#include "llvm/Support/ELF.h"
+
#include "ProcessPOSIXLog.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
ProcessElfCore::CreateInstance (Target &target, Listener &listener, const FileSpec *crash_file)
{
lldb::ProcessSP process_sp;
- if (crash_file)
- process_sp.reset(new ProcessElfCore (target, listener, *crash_file));
+ if (crash_file)
+ {
+ // Read enough data for a ELF32 header or ELF64 header
+ const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
+
+ lldb::DataBufferSP data_sp (crash_file->ReadFileContents(0, header_size));
+ if (data_sp->GetByteSize() == header_size)
+ {
+ elf::ELFHeader elf_header;
+ DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);
+ lldb::offset_t data_offset = 0;
+ if (elf_header.Parse(data, &data_offset))
+ {
+ if (elf_header.e_type == llvm::ELF::ET_CORE)
+ process_sp.reset(new ProcessElfCore (target, listener, *crash_file));
+ }
+ }
+ }
return process_sp;
}
// Needed for the plug-in names for the dynamic loaders.
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
using namespace lldb;
using namespace lldb_private;
{
lldb::ProcessSP process_sp;
if (crash_file)
- process_sp.reset(new ProcessMachCore (target, listener, *crash_file));
+ {
+ const size_t header_size = sizeof(llvm::MachO::mach_header);
+ lldb::DataBufferSP data_sp (crash_file->ReadFileContents(0, header_size));
+ if (data_sp->GetByteSize() == header_size)
+ {
+ DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);
+
+ lldb::offset_t data_offset = 0;
+ llvm::MachO::mach_header mach_header;
+ if (ObjectFileMachO::ParseHeader(data, &data_offset, mach_header))
+ {
+ if (mach_header.filetype == llvm::MachO::MH_CORE)
+ process_sp.reset(new ProcessMachCore (target, listener, *crash_file));
+ }
+ }
+
+ }
return process_sp;
}