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