1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
//===-- RegisterContextMinidump_x86_64.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 LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
#include "MinidumpTypes.h"
#include "Plugins/Process/Utility/RegisterInfoInterface.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
#include "lldb/Target/RegisterContext.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/Support/Endian.h"
// C includes
// C++ includes
namespace lldb_private {
namespace minidump {
// This function receives an ArrayRef pointing to the bytes of the Minidump
// register context and returns a DataBuffer that's ordered by the offsets
// specified in the RegisterInfoInterface argument
// This way we can reuse the already existing register contexts
lldb::DataBufferSP
ConvertMinidumpContext_x86_64(llvm::ArrayRef<uint8_t> 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 // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
|