Index: include/lldb/Formats/MinidumpParser.h =================================================================== --- include/lldb/Formats/MinidumpParser.h +++ include/lldb/Formats/MinidumpParser.h @@ -6,25 +6,19 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_MinidumpParser_h_ -#define liblldb_MinidumpParser_h_ - -#include "MinidumpTypes.h" +#ifndef LLDB_BINARYFORMAT_MINIDUMPPARSER_H +#define LLDB_BINARYFORMAT_MINIDUMPPARSER_H +#include "lldb/Formats/MinidumpTypes.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/MemoryRegionInfo.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" - #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" - -// C includes - -// C++ includes #include #include @@ -116,4 +110,5 @@ } // end namespace minidump } // end namespace lldb_private -#endif // liblldb_MinidumpParser_h_ + +#endif // LLDB_BINARYFORMAT_MINIDUMPPARSER_H Index: include/lldb/Formats/MinidumpTypes.h =================================================================== --- include/lldb/Formats/MinidumpTypes.h +++ include/lldb/Formats/MinidumpTypes.h @@ -6,12 +6,10 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_MinidumpTypes_h_ -#define liblldb_MinidumpTypes_h_ - +#ifndef LLDB_BINARYFORMAT_MINIDUMPTYPES_H +#define LLDB_BINARYFORMAT_MINIDUMPTYPES_H #include "lldb/Utility/Status.h" - #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" #include "llvm/ADT/Optional.h" @@ -20,9 +18,6 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Endian.h" -// C includes -// C++ includes - // Reference: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms679293(v=vs.85).aspx // https://chromium.googlesource.com/breakpad/breakpad/ @@ -512,6 +507,253 @@ static_assert(sizeof(MinidumpExceptionStream) == 168, "sizeof MinidumpExceptionStream is not correct!"); +// This describes the layout of a TEB (Thread Environment Block) for a 64-bit +// process. It's adapted from the 32-bit TEB in winternl.h. Currently, we care +// only about the position of the tls_slots. +struct TEB64 { + llvm::support::ulittle64_t reserved1[12]; + llvm::support::ulittle64_t process_environment_block; + llvm::support::ulittle64_t reserved2[399]; + uint8_t reserved3[1952]; + llvm::support::ulittle64_t tls_slots[64]; + uint8_t reserved4[8]; + llvm::support::ulittle64_t reserved5[26]; + llvm::support::ulittle64_t reserved_for_ole; // Windows 2000 only + llvm::support::ulittle64_t reserved6[4]; + llvm::support::ulittle64_t tls_expansion_slots; +}; + +// Reference: see breakpad/crashpad source or WinNT.h +struct MinidumpFloatingSaveAreaX86 { + llvm::support::ulittle32_t control_word; + llvm::support::ulittle32_t status_word; + llvm::support::ulittle32_t tag_word; + llvm::support::ulittle32_t error_offset; + llvm::support::ulittle32_t error_selector; + llvm::support::ulittle32_t data_offset; + llvm::support::ulittle32_t data_selector; + + enum { + RegisterAreaSize = 80, + }; + // register_area contains eight 80-bit (x87 "long double") quantities for + // floating-point registers %st0 (%mm0) through %st7 (%mm7). + uint8_t register_area[RegisterAreaSize]; + llvm::support::ulittle32_t cr0_npx_state; +}; + +struct MinidumpContext_x86_32 { + // The context_flags field determines which parts + // of the structure are populated (have valid values) + llvm::support::ulittle32_t context_flags; + + // The next 6 registers are included with + // MinidumpContext_x86_32_Flags::DebugRegisters + llvm::support::ulittle32_t dr0; + llvm::support::ulittle32_t dr1; + llvm::support::ulittle32_t dr2; + llvm::support::ulittle32_t dr3; + llvm::support::ulittle32_t dr6; + llvm::support::ulittle32_t dr7; + + // The next field is included with + // MinidumpContext_x86_32_Flags::FloatingPoint + MinidumpFloatingSaveAreaX86 float_save; + + // The next 4 registers are included with + // MinidumpContext_x86_32_Flags::Segments + llvm::support::ulittle32_t gs; + llvm::support::ulittle32_t fs; + llvm::support::ulittle32_t es; + llvm::support::ulittle32_t ds; + + // The next 6 registers are included with + // MinidumpContext_x86_32_Flags::Integer + llvm::support::ulittle32_t edi; + llvm::support::ulittle32_t esi; + llvm::support::ulittle32_t ebx; + llvm::support::ulittle32_t edx; + llvm::support::ulittle32_t ecx; + llvm::support::ulittle32_t eax; + + // The next 6 registers are included with + // MinidumpContext_x86_32_Flags::Control + llvm::support::ulittle32_t ebp; + llvm::support::ulittle32_t eip; + llvm::support::ulittle32_t cs; // WinNT.h says "must be sanitized" + llvm::support::ulittle32_t eflags; // WinNT.h says "must be sanitized" + llvm::support::ulittle32_t esp; + llvm::support::ulittle32_t ss; + + // The next field is included with + // MinidumpContext_x86_32_Flags::ExtendedRegisters + // It contains vector (MMX/SSE) registers. It it laid out in the + // format used by the fxsave and fsrstor instructions, so it includes + // a copy of the x87 floating-point registers as well. See FXSAVE in + // "Intel Architecture Software Developer's Manual, Volume 2." + enum { + ExtendedRegistersSize = 512, + }; + uint8_t extended_registers[ExtendedRegistersSize]; +}; + +// For context_flags. These values indicate the type of +// context stored in the structure. The high 24 bits identify the CPU, the +// low 8 bits identify the type of context saved. +enum class MinidumpContext_x86_32_Flags : uint32_t { + x86_32_Flag = 0x00010000, // CONTEXT_i386, CONTEXT_i486 + Control = x86_32_Flag | 0x00000001, + Integer = x86_32_Flag | 0x00000002, + Segments = x86_32_Flag | 0x00000004, + FloatingPoint = x86_32_Flag | 0x00000008, + DebugRegisters = x86_32_Flag | 0x00000010, + ExtendedRegisters = x86_32_Flag | 0x00000020, + XState = x86_32_Flag | 0x00000040, + + Full = Control | Integer | Segments, + All = Full | FloatingPoint | DebugRegisters | ExtendedRegisters, + + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) +}; + +struct Uint128 { + llvm::support::ulittle64_t high; + llvm::support::ulittle64_t low; +}; + +// Reference: see breakpad/crashpad source or WinNT.h +struct MinidumpXMMSaveArea32AMD64 { + llvm::support::ulittle16_t control_word; + llvm::support::ulittle16_t status_word; + uint8_t tag_word; + uint8_t reserved1; + llvm::support::ulittle16_t error_opcode; + llvm::support::ulittle32_t error_offset; + llvm::support::ulittle16_t error_selector; + llvm::support::ulittle16_t reserved2; + llvm::support::ulittle32_t data_offset; + llvm::support::ulittle16_t data_selector; + llvm::support::ulittle16_t reserved3; + llvm::support::ulittle32_t mx_csr; + llvm::support::ulittle32_t mx_csr_mask; + Uint128 float_registers[8]; + Uint128 xmm_registers[16]; + uint8_t reserved4[96]; +}; + +struct MinidumpContext_x86_64 { + // Register parameter home addresses. + llvm::support::ulittle64_t p1_home; + llvm::support::ulittle64_t p2_home; + llvm::support::ulittle64_t p3_home; + llvm::support::ulittle64_t p4_home; + llvm::support::ulittle64_t p5_home; + llvm::support::ulittle64_t p6_home; + + // The context_flags field determines which parts + // of the structure are populated (have valid values) + llvm::support::ulittle32_t context_flags; + llvm::support::ulittle32_t mx_csr; + + // The next register is included with + // MinidumpContext_x86_64_Flags::Control + llvm::support::ulittle16_t cs; + + // The next 4 registers are included with + // MinidumpContext_x86_64_Flags::Segments + llvm::support::ulittle16_t ds; + llvm::support::ulittle16_t es; + llvm::support::ulittle16_t fs; + llvm::support::ulittle16_t gs; + + // The next 2 registers are included with + // MinidumpContext_x86_64_Flags::Control + llvm::support::ulittle16_t ss; + llvm::support::ulittle32_t eflags; + + // The next 6 registers are included with + // MinidumpContext_x86_64_Flags::DebugRegisters + llvm::support::ulittle64_t dr0; + llvm::support::ulittle64_t dr1; + llvm::support::ulittle64_t dr2; + llvm::support::ulittle64_t dr3; + llvm::support::ulittle64_t dr6; + llvm::support::ulittle64_t dr7; + + // The next 4 registers are included with + // MinidumpContext_x86_64_Flags::Integer + llvm::support::ulittle64_t rax; + llvm::support::ulittle64_t rcx; + llvm::support::ulittle64_t rdx; + llvm::support::ulittle64_t rbx; + + // The next register is included with + // MinidumpContext_x86_64_Flags::Control + llvm::support::ulittle64_t rsp; + + // The next 11 registers are included with + // MinidumpContext_x86_64_Flags::Integer + llvm::support::ulittle64_t rbp; + llvm::support::ulittle64_t rsi; + llvm::support::ulittle64_t rdi; + llvm::support::ulittle64_t r8; + llvm::support::ulittle64_t r9; + llvm::support::ulittle64_t r10; + llvm::support::ulittle64_t r11; + llvm::support::ulittle64_t r12; + llvm::support::ulittle64_t r13; + llvm::support::ulittle64_t r14; + llvm::support::ulittle64_t r15; + + // The next register is included with + // MinidumpContext_x86_64_Flags::Control + llvm::support::ulittle64_t rip; + + // The next set of registers are included with + // MinidumpContext_x86_64_Flags:FloatingPoint + union FPR { + MinidumpXMMSaveArea32AMD64 flt_save; + struct { + Uint128 header[2]; + Uint128 legacy[8]; + Uint128 xmm[16]; + } sse_registers; + }; + + enum { + VRCount = 26, + }; + + Uint128 vector_register[VRCount]; + llvm::support::ulittle64_t vector_control; + + // The next 5 registers are included with + // MinidumpContext_x86_64_Flags::DebugRegisters + llvm::support::ulittle64_t debug_control; + llvm::support::ulittle64_t last_branch_to_rip; + llvm::support::ulittle64_t last_branch_from_rip; + llvm::support::ulittle64_t last_exception_to_rip; + llvm::support::ulittle64_t last_exception_from_rip; +}; + +// For context_flags. These values indicate the type of +// context stored in the structure. The high 24 bits identify the CPU, the +// low 8 bits identify the type of context saved. +enum class MinidumpContext_x86_64_Flags : uint32_t { + x86_64_Flag = 0x00100000, + Control = x86_64_Flag | 0x00000001, + Integer = x86_64_Flag | 0x00000002, + Segments = x86_64_Flag | 0x00000004, + FloatingPoint = x86_64_Flag | 0x00000008, + DebugRegisters = x86_64_Flag | 0x00000010, + XState = x86_64_Flag | 0x00000040, + + Full = Control | Integer | FloatingPoint, + All = Full | Segments | DebugRegisters, + + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) +}; + } // namespace minidump } // namespace lldb_private -#endif // liblldb_MinidumpTypes_h_ +#endif // LLDB_BINARYFORMAT_MINIDUMPTYPES_H Index: source/Formats/CMakeLists.txt =================================================================== --- source/Formats/CMakeLists.txt +++ source/Formats/CMakeLists.txt @@ -1,5 +1,7 @@ add_lldb_library(lldbFormats LinuxProcMaps.cpp + MinidumpParser.cpp + MinidumpTypes.cpp LINK_LIBS lldbUtility Index: source/Formats/MinidumpParser.cpp =================================================================== --- source/Formats/MinidumpParser.cpp +++ source/Formats/MinidumpParser.cpp @@ -6,11 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "MinidumpParser.h" -#include "NtStructures.h" -#include "RegisterContextMinidump_x86_32.h" - -#include "lldb/Utility/LLDBAssert.h" +#include "lldb/Formats/MinidumpParser.h" #include "lldb/Formats/LinuxProcMaps.h" // C includes Index: source/Formats/MinidumpTypes.cpp =================================================================== --- source/Formats/MinidumpTypes.cpp +++ source/Formats/MinidumpTypes.cpp @@ -6,10 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "MinidumpTypes.h" - -// C includes -// C++ includes +#include "lldb/Formats/MinidumpTypes.h" using namespace lldb_private; using namespace minidump; Index: source/Plugins/Process/minidump/CMakeLists.txt =================================================================== --- source/Plugins/Process/minidump/CMakeLists.txt +++ source/Plugins/Process/minidump/CMakeLists.txt @@ -1,6 +1,4 @@ add_lldb_library(lldbPluginProcessMinidump PLUGIN - MinidumpTypes.cpp - MinidumpParser.cpp RegisterContextMinidump_ARM.cpp RegisterContextMinidump_ARM64.cpp RegisterContextMinidump_x86_32.cpp Index: source/Plugins/Process/minidump/NtStructures.h =================================================================== --- source/Plugins/Process/minidump/NtStructures.h +++ /dev/null @@ -1,36 +0,0 @@ -//===-- NtStructures.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_Plugins_Process_Minidump_NtStructures_h_ -#define liblldb_Plugins_Process_Minidump_NtStructures_h_ - -#include "llvm/Support/Endian.h" - -namespace lldb_private { - -namespace minidump { - -// This describes the layout of a TEB (Thread Environment Block) for a 64-bit -// process. It's adapted from the 32-bit TEB in winternl.h. Currently, we care -// only about the position of the tls_slots. -struct TEB64 { - llvm::support::ulittle64_t reserved1[12]; - llvm::support::ulittle64_t process_environment_block; - llvm::support::ulittle64_t reserved2[399]; - uint8_t reserved3[1952]; - llvm::support::ulittle64_t tls_slots[64]; - uint8_t reserved4[8]; - llvm::support::ulittle64_t reserved5[26]; - llvm::support::ulittle64_t reserved_for_ole; // Windows 2000 only - llvm::support::ulittle64_t reserved6[4]; - llvm::support::ulittle64_t tls_expansion_slots; -}; - -#endif // liblldb_Plugins_Process_Minidump_NtStructures_h_ -} // namespace minidump -} // namespace lldb_private Index: source/Plugins/Process/minidump/ProcessMinidump.h =================================================================== --- source/Plugins/Process/minidump/ProcessMinidump.h +++ source/Plugins/Process/minidump/ProcessMinidump.h @@ -9,9 +9,8 @@ #ifndef liblldb_ProcessMinidump_h_ #define liblldb_ProcessMinidump_h_ -#include "MinidumpParser.h" -#include "MinidumpTypes.h" - +#include "lldb/Formats/MinidumpParser.h" +#include "lldb/Formats/MinidumpTypes.h" #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" Index: source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h +++ source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h @@ -9,8 +9,6 @@ #ifndef liblldb_RegisterContextMinidump_ARM_h_ #define liblldb_RegisterContextMinidump_ARM_h_ -#include "MinidumpTypes.h" - #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "lldb/Target/RegisterContext.h" Index: source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h +++ source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h @@ -9,8 +9,6 @@ #ifndef liblldb_RegisterContextMinidump_ARM64_h_ #define liblldb_RegisterContextMinidump_ARM64_h_ -#include "MinidumpTypes.h" - #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "lldb/Target/RegisterContext.h" Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h +++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h @@ -9,8 +9,6 @@ #ifndef liblldb_RegisterContextMinidump_x86_32_h_ #define liblldb_RegisterContextMinidump_x86_32_h_ -#include "MinidumpTypes.h" - #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "Plugins/Process/Utility/lldb-x86-register-enums.h" @@ -35,101 +33,6 @@ ConvertMinidumpContext_x86_32(llvm::ArrayRef source_data, RegisterInfoInterface *target_reg_interface); -// Reference: see breakpad/crashpad source or WinNT.h -struct MinidumpFloatingSaveAreaX86 { - llvm::support::ulittle32_t control_word; - llvm::support::ulittle32_t status_word; - llvm::support::ulittle32_t tag_word; - llvm::support::ulittle32_t error_offset; - llvm::support::ulittle32_t error_selector; - llvm::support::ulittle32_t data_offset; - llvm::support::ulittle32_t data_selector; - - enum { - RegisterAreaSize = 80, - }; - // register_area contains eight 80-bit (x87 "long double") quantities for - // floating-point registers %st0 (%mm0) through %st7 (%mm7). - uint8_t register_area[RegisterAreaSize]; - llvm::support::ulittle32_t cr0_npx_state; -}; - -struct MinidumpContext_x86_32 { - // The context_flags field determines which parts - // of the structure are populated (have valid values) - llvm::support::ulittle32_t context_flags; - - // The next 6 registers are included with - // MinidumpContext_x86_32_Flags::DebugRegisters - llvm::support::ulittle32_t dr0; - llvm::support::ulittle32_t dr1; - llvm::support::ulittle32_t dr2; - llvm::support::ulittle32_t dr3; - llvm::support::ulittle32_t dr6; - llvm::support::ulittle32_t dr7; - - // The next field is included with - // MinidumpContext_x86_32_Flags::FloatingPoint - MinidumpFloatingSaveAreaX86 float_save; - - // The next 4 registers are included with - // MinidumpContext_x86_32_Flags::Segments - llvm::support::ulittle32_t gs; - llvm::support::ulittle32_t fs; - llvm::support::ulittle32_t es; - llvm::support::ulittle32_t ds; - - // The next 6 registers are included with - // MinidumpContext_x86_32_Flags::Integer - llvm::support::ulittle32_t edi; - llvm::support::ulittle32_t esi; - llvm::support::ulittle32_t ebx; - llvm::support::ulittle32_t edx; - llvm::support::ulittle32_t ecx; - llvm::support::ulittle32_t eax; - - // The next 6 registers are included with - // MinidumpContext_x86_32_Flags::Control - llvm::support::ulittle32_t ebp; - llvm::support::ulittle32_t eip; - llvm::support::ulittle32_t cs; // WinNT.h says "must be sanitized" - llvm::support::ulittle32_t eflags; // WinNT.h says "must be sanitized" - llvm::support::ulittle32_t esp; - llvm::support::ulittle32_t ss; - - // The next field is included with - // MinidumpContext_x86_32_Flags::ExtendedRegisters - // It contains vector (MMX/SSE) registers. It it laid out in the - // format used by the fxsave and fsrstor instructions, so it includes - // a copy of the x87 floating-point registers as well. See FXSAVE in - // "Intel Architecture Software Developer's Manual, Volume 2." - enum { - ExtendedRegistersSize = 512, - }; - uint8_t extended_registers[ExtendedRegistersSize]; -}; - -LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); - -// For context_flags. These values indicate the type of -// context stored in the structure. The high 24 bits identify the CPU, the -// low 8 bits identify the type of context saved. -enum class MinidumpContext_x86_32_Flags : uint32_t { - x86_32_Flag = 0x00010000, // CONTEXT_i386, CONTEXT_i486 - Control = x86_32_Flag | 0x00000001, - Integer = x86_32_Flag | 0x00000002, - Segments = x86_32_Flag | 0x00000004, - FloatingPoint = x86_32_Flag | 0x00000008, - DebugRegisters = x86_32_Flag | 0x00000010, - ExtendedRegisters = x86_32_Flag | 0x00000020, - XState = x86_32_Flag | 0x00000040, - - Full = Control | Integer | Segments, - All = Full | FloatingPoint | DebugRegisters | ExtendedRegisters, - - LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) -}; - } // end namespace minidump } // end namespace lldb_private #endif // liblldb_RegisterContextMinidump_x86_32_h_ Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp +++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp @@ -9,6 +9,7 @@ #include "RegisterContextMinidump_x86_32.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Formats/MinidumpTypes.h" // C includes // C++ includes Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h +++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h @@ -9,8 +9,6 @@ #ifndef liblldb_RegisterContextMinidump_h_ #define liblldb_RegisterContextMinidump_h_ -#include "MinidumpTypes.h" - #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "Plugins/Process/Utility/lldb-x86-register-enums.h" @@ -35,146 +33,6 @@ ConvertMinidumpContext_x86_64(llvm::ArrayRef source_data, RegisterInfoInterface *target_reg_interface); -struct Uint128 { - llvm::support::ulittle64_t high; - llvm::support::ulittle64_t low; -}; - -// Reference: see breakpad/crashpad source or WinNT.h -struct MinidumpXMMSaveArea32AMD64 { - llvm::support::ulittle16_t control_word; - llvm::support::ulittle16_t status_word; - uint8_t tag_word; - uint8_t reserved1; - llvm::support::ulittle16_t error_opcode; - llvm::support::ulittle32_t error_offset; - llvm::support::ulittle16_t error_selector; - llvm::support::ulittle16_t reserved2; - llvm::support::ulittle32_t data_offset; - llvm::support::ulittle16_t data_selector; - llvm::support::ulittle16_t reserved3; - llvm::support::ulittle32_t mx_csr; - llvm::support::ulittle32_t mx_csr_mask; - Uint128 float_registers[8]; - Uint128 xmm_registers[16]; - uint8_t reserved4[96]; -}; - -struct MinidumpContext_x86_64 { - // Register parameter home addresses. - llvm::support::ulittle64_t p1_home; - llvm::support::ulittle64_t p2_home; - llvm::support::ulittle64_t p3_home; - llvm::support::ulittle64_t p4_home; - llvm::support::ulittle64_t p5_home; - llvm::support::ulittle64_t p6_home; - - // The context_flags field determines which parts - // of the structure are populated (have valid values) - llvm::support::ulittle32_t context_flags; - llvm::support::ulittle32_t mx_csr; - - // The next register is included with - // MinidumpContext_x86_64_Flags::Control - llvm::support::ulittle16_t cs; - - // The next 4 registers are included with - // MinidumpContext_x86_64_Flags::Segments - llvm::support::ulittle16_t ds; - llvm::support::ulittle16_t es; - llvm::support::ulittle16_t fs; - llvm::support::ulittle16_t gs; - - // The next 2 registers are included with - // MinidumpContext_x86_64_Flags::Control - llvm::support::ulittle16_t ss; - llvm::support::ulittle32_t eflags; - - // The next 6 registers are included with - // MinidumpContext_x86_64_Flags::DebugRegisters - llvm::support::ulittle64_t dr0; - llvm::support::ulittle64_t dr1; - llvm::support::ulittle64_t dr2; - llvm::support::ulittle64_t dr3; - llvm::support::ulittle64_t dr6; - llvm::support::ulittle64_t dr7; - - // The next 4 registers are included with - // MinidumpContext_x86_64_Flags::Integer - llvm::support::ulittle64_t rax; - llvm::support::ulittle64_t rcx; - llvm::support::ulittle64_t rdx; - llvm::support::ulittle64_t rbx; - - // The next register is included with - // MinidumpContext_x86_64_Flags::Control - llvm::support::ulittle64_t rsp; - - // The next 11 registers are included with - // MinidumpContext_x86_64_Flags::Integer - llvm::support::ulittle64_t rbp; - llvm::support::ulittle64_t rsi; - llvm::support::ulittle64_t rdi; - llvm::support::ulittle64_t r8; - llvm::support::ulittle64_t r9; - llvm::support::ulittle64_t r10; - llvm::support::ulittle64_t r11; - llvm::support::ulittle64_t r12; - llvm::support::ulittle64_t r13; - llvm::support::ulittle64_t r14; - llvm::support::ulittle64_t r15; - - // The next register is included with - // MinidumpContext_x86_64_Flags::Control - llvm::support::ulittle64_t rip; - - // The next set of registers are included with - // MinidumpContext_x86_64_Flags:FloatingPoint - union FPR { - MinidumpXMMSaveArea32AMD64 flt_save; - struct { - Uint128 header[2]; - Uint128 legacy[8]; - Uint128 xmm[16]; - } sse_registers; - }; - - enum { - VRCount = 26, - }; - - Uint128 vector_register[VRCount]; - llvm::support::ulittle64_t vector_control; - - // The next 5 registers are included with - // MinidumpContext_x86_64_Flags::DebugRegisters - llvm::support::ulittle64_t debug_control; - llvm::support::ulittle64_t last_branch_to_rip; - llvm::support::ulittle64_t last_branch_from_rip; - llvm::support::ulittle64_t last_exception_to_rip; - llvm::support::ulittle64_t last_exception_from_rip; -}; - -// For context_flags. These values indicate the type of -// context stored in the structure. The high 24 bits identify the CPU, the -// low 8 bits identify the type of context saved. -LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); - -enum class MinidumpContext_x86_64_Flags : uint32_t { - x86_64_Flag = 0x00100000, - Control = x86_64_Flag | 0x00000001, - Integer = x86_64_Flag | 0x00000002, - Segments = x86_64_Flag | 0x00000004, - FloatingPoint = x86_64_Flag | 0x00000008, - DebugRegisters = x86_64_Flag | 0x00000010, - XState = x86_64_Flag | 0x00000040, - - Full = Control | Integer | FloatingPoint, - All = Full | Segments | DebugRegisters, - - LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) -}; - } // end namespace minidump } // end namespace lldb_private #endif // liblldb_RegisterContextMinidump_h_ Index: source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp =================================================================== --- source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp +++ source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp @@ -9,6 +9,7 @@ #include "RegisterContextMinidump_x86_64.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Formats/MinidumpTypes.h" // C includes // C++ includes Index: source/Plugins/Process/minidump/ThreadMinidump.h =================================================================== --- source/Plugins/Process/minidump/ThreadMinidump.h +++ source/Plugins/Process/minidump/ThreadMinidump.h @@ -9,8 +9,7 @@ #ifndef liblldb_ThreadMinidump_h_ #define liblldb_ThreadMinidump_h_ -#include "MinidumpTypes.h" - +#include "lldb/Formats/MinidumpTypes.h" #include "lldb/Target/Thread.h" Index: unittests/Formats/CMakeLists.txt =================================================================== --- unittests/Formats/CMakeLists.txt +++ unittests/Formats/CMakeLists.txt @@ -1,8 +1,35 @@ add_lldb_unittest(LLDBFormatsTests LinuxProcMapsTest.cpp + MinidumpParserTest.cpp LINK_LIBS lldbFormats + lldbHost + lldbUtilityHelpers + LLVMTestingSupport LINK_COMPONENTS Support ) + +set(test_inputs + bad_duplicate_streams.dmp + bad_overlapping_streams.dmp + fizzbuzz_no_heap.dmp + fizzbuzz_wow64.dmp + linux-i386.dmp + linux-x86_64.dmp + linux-x86_64_not_crashed.dmp + memory-list-not-padded.dmp + memory-list-padded.dmp + module-list-not-padded.dmp + module-list-padded.dmp + modules-dup-min-addr.dmp + modules-order.dmp + regions-linux-map.dmp + regions-memlist.dmp + regions-memlist64.dmp + thread-list-not-padded.dmp + thread-list-padded.dmp + ) + +add_unittest_inputs(LLDBFormatsTests "${test_inputs}") Index: unittests/Formats/MinidumpParserTest.cpp =================================================================== --- unittests/Formats/MinidumpParserTest.cpp +++ unittests/Formats/MinidumpParserTest.cpp @@ -1,4 +1,4 @@ -//===-- MinidumpTypesTest.cpp -----------------------------------*- C++ -*-===// +//===-- MinidumpParserTest.cpp ----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,10 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "Plugins/Process/minidump/MinidumpParser.h" -#include "Plugins/Process/minidump/MinidumpTypes.h" -#include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h" -#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h" +#include "lldb/Formats/MinidumpParser.h" +#include "lldb/Formats/MinidumpTypes.h" #include "TestingSupport/TestUtilities.h" #include "lldb/Host/FileSystem.h" #include "lldb/Utility/MemoryRegionInfo.h" Index: unittests/Process/minidump/CMakeLists.txt =================================================================== --- unittests/Process/minidump/CMakeLists.txt +++ unittests/Process/minidump/CMakeLists.txt @@ -1,38 +1,8 @@ add_lldb_unittest(LLDBMinidumpTests - MinidumpParserTest.cpp RegisterContextMinidumpTest.cpp LINK_LIBS - lldbCore - lldbHost - lldbTarget - lldbPluginProcessUtility lldbPluginProcessMinidump - lldbUtilityHelpers - LLVMTestingSupport LINK_COMPONENTS Support ) - -set(test_inputs - bad_duplicate_streams.dmp - bad_overlapping_streams.dmp - fizzbuzz_no_heap.dmp - fizzbuzz_wow64.dmp - linux-i386.dmp - linux-x86_64.dmp - linux-x86_64_not_crashed.dmp - memory-list-not-padded.dmp - memory-list-padded.dmp - module-list-not-padded.dmp - module-list-padded.dmp - modules-dup-min-addr.dmp - modules-order.dmp - regions-linux-map.dmp - regions-memlist.dmp - regions-memlist64.dmp - thread-list-not-padded.dmp - thread-list-padded.dmp - ) - -add_unittest_inputs(LLDBMinidumpTests "${test_inputs}") Index: unittests/Process/minidump/Inputs/linux-x86_64.cpp =================================================================== --- /dev/null +++ unittests/Process/minidump/Inputs/linux-x86_64.cpp @@ -1,28 +0,0 @@ -// Example source from breakpad's linux tutorial -// https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/linux_starter_guide.md - -#include -#include -#include - -#include "client/linux/handler/exception_handler.h" - -static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor, - void *context, bool succeeded) { - printf("Dump path: %s\n", descriptor.path()); - return succeeded; -} - -void crash() { - volatile int *a = (int *)(NULL); - *a = 1; -} - -int main(int argc, char *argv[]) { - google_breakpad::MinidumpDescriptor descriptor("/tmp"); - google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, - true, -1); - printf("pid: %d\n", getpid()); - crash(); - return 0; -} Index: unittests/Process/minidump/RegisterContextMinidumpTest.cpp =================================================================== --- unittests/Process/minidump/RegisterContextMinidumpTest.cpp +++ unittests/Process/minidump/RegisterContextMinidumpTest.cpp @@ -10,6 +10,7 @@ #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" #include "Plugins/Process/minidump/RegisterContextMinidump_x86_32.h" #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h" +#include "lldb/Formats/MinidumpTypes.h" #include "lldb/Utility/DataBuffer.h" #include "gtest/gtest.h"