1 //===-- RegisterContextMinidump_x86_32.h ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_RegisterContextMinidump_x86_32_h_
11 #define liblldb_RegisterContextMinidump_x86_32_h_
14 #include "MinidumpTypes.h"
16 // Other libraries and framework includes
17 #include "Plugins/Process/Utility/RegisterInfoInterface.h"
18 #include "Plugins/Process/Utility/lldb-x86-register-enums.h"
20 #include "lldb/Target/RegisterContext.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/BitmaskEnum.h"
24 #include "llvm/Support/Endian.h"
29 namespace lldb_private {
33 // This function receives an ArrayRef pointing to the bytes of the Minidump
34 // register context and returns a DataBuffer that's ordered by the offsets
35 // specified in the RegisterInfoInterface argument
36 // This way we can reuse the already existing register contexts
38 ConvertMinidumpContext_x86_32(llvm::ArrayRef<uint8_t> source_data,
39 RegisterInfoInterface *target_reg_interface);
41 // Reference: see breakpad/crashpad source or WinNT.h
42 struct MinidumpFloatingSaveAreaX86 {
43 llvm::support::ulittle32_t control_word;
44 llvm::support::ulittle32_t status_word;
45 llvm::support::ulittle32_t tag_word;
46 llvm::support::ulittle32_t error_offset;
47 llvm::support::ulittle32_t error_selector;
48 llvm::support::ulittle32_t data_offset;
49 llvm::support::ulittle32_t data_selector;
52 RegisterAreaSize = 80,
54 // register_area contains eight 80-bit (x87 "long double") quantities for
55 // floating-point registers %st0 (%mm0) through %st7 (%mm7).
56 uint8_t register_area[RegisterAreaSize];
57 llvm::support::ulittle32_t cr0_npx_state;
60 struct MinidumpContext_x86_32 {
61 // The context_flags field determines which parts
62 // of the structure are populated (have valid values)
63 llvm::support::ulittle32_t context_flags;
65 // The next 6 registers are included with
66 // MinidumpContext_x86_32_Flags::DebugRegisters
67 llvm::support::ulittle32_t dr0;
68 llvm::support::ulittle32_t dr1;
69 llvm::support::ulittle32_t dr2;
70 llvm::support::ulittle32_t dr3;
71 llvm::support::ulittle32_t dr6;
72 llvm::support::ulittle32_t dr7;
74 // The next field is included with
75 // MinidumpContext_x86_32_Flags::FloatingPoint
76 MinidumpFloatingSaveAreaX86 float_save;
78 // The next 4 registers are included with
79 // MinidumpContext_x86_32_Flags::Segments
80 llvm::support::ulittle32_t gs;
81 llvm::support::ulittle32_t fs;
82 llvm::support::ulittle32_t es;
83 llvm::support::ulittle32_t ds;
85 // The next 6 registers are included with
86 // MinidumpContext_x86_32_Flags::Integer
87 llvm::support::ulittle32_t edi;
88 llvm::support::ulittle32_t esi;
89 llvm::support::ulittle32_t ebx;
90 llvm::support::ulittle32_t edx;
91 llvm::support::ulittle32_t ecx;
92 llvm::support::ulittle32_t eax;
94 // The next 6 registers are included with
95 // MinidumpContext_x86_32_Flags::Control
96 llvm::support::ulittle32_t ebp;
97 llvm::support::ulittle32_t eip;
98 llvm::support::ulittle32_t cs; // WinNT.h says "must be sanitized"
99 llvm::support::ulittle32_t eflags; // WinNT.h says "must be sanitized"
100 llvm::support::ulittle32_t esp;
101 llvm::support::ulittle32_t ss;
103 // The next field is included with
104 // MinidumpContext_x86_32_Flags::ExtendedRegisters
105 // It contains vector (MMX/SSE) registers. It it laid out in the
106 // format used by the fxsave and fsrstor instructions, so it includes
107 // a copy of the x87 floating-point registers as well. See FXSAVE in
108 // "Intel Architecture Software Developer's Manual, Volume 2."
110 ExtendedRegistersSize = 512,
112 uint8_t extended_registers[ExtendedRegistersSize];
115 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
117 // For context_flags. These values indicate the type of
118 // context stored in the structure. The high 24 bits identify the CPU, the
119 // low 8 bits identify the type of context saved.
120 enum class MinidumpContext_x86_32_Flags : uint32_t {
121 x86_32_Flag = 0x00010000, // CONTEXT_i386, CONTEXT_i486
122 Control = x86_32_Flag | 0x00000001,
123 Integer = x86_32_Flag | 0x00000002,
124 Segments = x86_32_Flag | 0x00000004,
125 FloatingPoint = x86_32_Flag | 0x00000008,
126 DebugRegisters = x86_32_Flag | 0x00000010,
127 ExtendedRegisters = x86_32_Flag | 0x00000020,
128 XState = x86_32_Flag | 0x00000040,
130 Full = Control | Integer | Segments,
131 All = Full | FloatingPoint | DebugRegisters | ExtendedRegisters,
133 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All)
136 } // end namespace minidump
137 } // end namespace lldb_private
138 #endif // liblldb_RegisterContextMinidump_x86_32_h_