57 uint32_t eax, ecx, edx, ebx, esi, edi, esp, ebp, eip, cs, ss, ds, es, fs,
84 SSEVector const &operator[](
size_t index)
const {
85 return _sse[index << 1];
87 SSEVector &operator[](
size_t index) {
return _sse[index << 1]; }
99 uint64_t xfeatures_mask;
117 inline void clear() {
118 std::memset(&gp, 0,
sizeof(gp));
119 std::memset(&x87, 0,
sizeof(x87));
120 std::memset(&xsave_header, 0,
sizeof(xsave_header));
121 std::memset(&avx, 0,
sizeof(avx));
122 std::memset(&dr, 0,
sizeof(dr));
123 std::memset(&xcr0, 0,
sizeof(xcr0));
125 std::memset(&linux_gp, 0,
sizeof(linux_gp));
133 inline uint32_t pc()
const {
return gp.eip; }
134 inline void setPC(uint32_t pc) { gp.eip = pc; }
136 inline uint32_t xpc()
const {
return gp.eip; }
138 inline uint32_t sp()
const {
return gp.esp; }
139 inline void setSP(uint32_t sp) { gp.esp = sp; }
141 inline uint32_t retval()
const {
return gp.eax; }
144#define _REGVALUE(REG) \
145 GPRegisterValue { sizeof(gp.REG), gp.REG }
154 inline void getGPState(GPRegisterValueVector ®s)
const {
156 regs.push_back(_REGVALUE(eax));
157 regs.push_back(_REGVALUE(ebx));
158 regs.push_back(_REGVALUE(ecx));
159 regs.push_back(_REGVALUE(edx));
160 regs.push_back(_REGVALUE(esi));
161 regs.push_back(_REGVALUE(edi));
162 regs.push_back(_REGVALUE(ebp));
163 regs.push_back(_REGVALUE(esp));
164 regs.push_back(_REGVALUE(eip));
165 regs.push_back(_REGVALUE(eflags));
166 regs.push_back(_REGVALUE(cs));
167 regs.push_back(_REGVALUE(ss));
168 regs.push_back(_REGVALUE(ds));
169 regs.push_back(_REGVALUE(es));
170 regs.push_back(_REGVALUE(fs));
171 regs.push_back(_REGVALUE(gs));
174 inline void setGPState(std::vector<uint64_t>
const ®s) {
175 gp.eax =
static_cast<uint32_t
>(regs[0]);
176 gp.ebx =
static_cast<uint32_t
>(regs[1]);
177 gp.ecx =
static_cast<uint32_t
>(regs[2]);
178 gp.edx =
static_cast<uint32_t
>(regs[3]);
179 gp.esi =
static_cast<uint32_t
>(regs[4]);
180 gp.edi =
static_cast<uint32_t
>(regs[5]);
181 gp.ebp =
static_cast<uint32_t
>(regs[6]);
182 gp.esp =
static_cast<uint32_t
>(regs[7]);
183 gp.eip =
static_cast<uint32_t
>(regs[8]);
184 gp.eflags =
static_cast<uint32_t
>(regs[9]);
185 gp.cs =
static_cast<uint32_t
>(regs[10]);
186 gp.ss =
static_cast<uint32_t
>(regs[11]);
187 gp.ds =
static_cast<uint32_t
>(regs[12]);
188 gp.es =
static_cast<uint32_t
>(regs[13]);
189 gp.fs =
static_cast<uint32_t
>(regs[14]);
190 gp.gs =
static_cast<uint32_t
>(regs[15]);
194 inline void getStopGPState(GPRegisterStopMap ®s,
bool forLLDB)
const {
196#define _SETREG(REG) regs[reg_lldb_##REG] = _REGVALUE(REG)
216#define _SETREG(REG) regs[reg_gdb_##REG] = _REGVALUE(REG)
240 inline bool getLLDBRegisterPtr(
int regno,
void **ptr,
size_t *length)
const {
241#define _GETREG2(T, REG, FLD) \
242 case reg_lldb_##REG: \
243 *ptr = &const_cast<CPUState *>(this)->T.FLD, *length = sizeof(T.FLD); \
245#define _GETREG8L(T, REG, FREG) \
246 case reg_lldb_##REG: \
247 *ptr = reinterpret_cast<uint8_t *>(&const_cast<CPUState *>(this)->T.FREG), \
248 *length = sizeof(uint8_t); \
250#define _GETREG8H(T, REG, FREG) \
251 case reg_lldb_##REG: \
253 reinterpret_cast<uint8_t *>(&const_cast<CPUState *>(this)->T.FREG) + \
255 *length = sizeof(uint8_t); \
257#define _GETREG16(T, REG, FREG) \
258 case reg_lldb_##REG: \
260 reinterpret_cast<uint16_t *>(&const_cast<CPUState *>(this)->T.FREG), \
261 *length = sizeof(uint16_t); \
263#define _GETREG(T, REG) _GETREG2(T, REG, REG)
283 _GETREG16(gp, ax, eax);
284 _GETREG16(gp, bx, ebx);
285 _GETREG16(gp, cx, ecx);
286 _GETREG16(gp, dx, edx);
287 _GETREG16(gp, si, esi);
288 _GETREG16(gp, di, edi);
289 _GETREG16(gp, sp, esp);
290 _GETREG16(gp, bp, ebp);
292 _GETREG8L(gp, al, eax);
293 _GETREG8L(gp, bl, ebx);
294 _GETREG8L(gp, cl, ecx);
295 _GETREG8L(gp, dl, edx);
297 _GETREG8H(gp, ah, eax);
298 _GETREG8H(gp, bh, ebx);
299 _GETREG8H(gp, ch, ecx);
300 _GETREG8H(gp, dh, edx);
302 _GETREG2(x87, st0, regs[0].data);
303 _GETREG2(x87, st1, regs[1].data);
304 _GETREG2(x87, st2, regs[2].data);
305 _GETREG2(x87, st3, regs[3].data);
306 _GETREG2(x87, st4, regs[4].data);
307 _GETREG2(x87, st5, regs[5].data);
308 _GETREG2(x87, st6, regs[6].data);
309 _GETREG2(x87, st7, regs[7].data);
310 _GETREG2(x87, fstat, fstw);
311 _GETREG2(x87, fctrl, fctw);
320 _GETREG(avx, mxcsrmask);
321 _GETREG2(avx, ymm0, regs[0]);
322 _GETREG2(avx, ymm1, regs[1]);
323 _GETREG2(avx, ymm2, regs[2]);
324 _GETREG2(avx, ymm3, regs[3]);
325 _GETREG2(avx, ymm4, regs[4]);
326 _GETREG2(avx, ymm5, regs[5]);
327 _GETREG2(avx, ymm6, regs[6]);
328 _GETREG2(avx, ymm7, regs[7]);
342 inline bool getGDBRegisterPtr(
int regno,
void **ptr,
size_t *length)
const {
343#define _GETREG2(T, REG, FLD) \
344 case reg_gdb_##REG: \
345 *ptr = &const_cast<CPUState *>(this)->T.FLD, *length = sizeof(T.FLD); \
347#define _GETREG(T, REG) _GETREG2(T, REG, REG)
367 _GETREG2(x87, st0, regs[0].data);
368 _GETREG2(x87, st1, regs[1].data);
369 _GETREG2(x87, st2, regs[2].data);
370 _GETREG2(x87, st3, regs[3].data);
371 _GETREG2(x87, st4, regs[4].data);
372 _GETREG2(x87, st5, regs[5].data);
373 _GETREG2(x87, st6, regs[6].data);
374 _GETREG2(x87, st7, regs[7].data);
375 _GETREG2(x87, fstat, fstw);
376 _GETREG2(x87, fctrl, fctw);
385 _GETREG2(sse, ymm0, regs[0]);
386 _GETREG2(sse, ymm1, regs[1]);
387 _GETREG2(sse, ymm2, regs[2]);
388 _GETREG2(sse, ymm3, regs[3]);
389 _GETREG2(sse, ymm4, regs[4]);
390 _GETREG2(sse, ymm5, regs[5]);
391 _GETREG2(sse, ymm6, regs[6]);
392 _GETREG2(sse, ymm7, regs[7]);
397 _GETREG(linux_gp, orig_eax);