Commit c58411661274631e2687deedd1597a34bfd38e2a
1 parent
73e51723
Add x86_64 gdb stub for qemu (Jason Wessel).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4390 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
133 additions
and
1 deletions
gdbstub.c
... | ... | @@ -233,9 +233,141 @@ static int put_packet(GDBState *s, char *buf) |
233 | 233 | } |
234 | 234 | return 0; |
235 | 235 | } |
236 | +#if defined(TARGET_X86_64) | |
236 | 237 | |
237 | -#if defined(TARGET_I386) | |
238 | +static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) | |
239 | +{ | |
240 | + uint8_t *p = mem_buf; | |
241 | + int i, fpus; | |
242 | + | |
243 | +#define PUTREG(x) do { \ | |
244 | + target_ulong reg = tswapl(x); \ | |
245 | + memcpy(p, ®, sizeof reg); \ | |
246 | + p += sizeof reg; \ | |
247 | + } while (0) | |
248 | +#define PUTREG32(x) do { \ | |
249 | + uint32_t reg = tswap32(x); \ | |
250 | + memcpy(p, ®, sizeof reg); \ | |
251 | + p += sizeof reg; \ | |
252 | + } while (0) | |
253 | +#define PUTREGF(x) do { \ | |
254 | + memcpy(p, &(x), 10); \ | |
255 | + p += sizeof (x); \ | |
256 | + } while (0) | |
257 | + | |
258 | + PUTREG(env->regs[R_EAX]); | |
259 | + PUTREG(env->regs[R_EBX]); | |
260 | + PUTREG(env->regs[R_ECX]); | |
261 | + PUTREG(env->regs[R_EDX]); | |
262 | + PUTREG(env->regs[R_ESI]); | |
263 | + PUTREG(env->regs[R_EDI]); | |
264 | + PUTREG(env->regs[R_EBP]); | |
265 | + PUTREG(env->regs[R_ESP]); | |
266 | + PUTREG(env->regs[8]); | |
267 | + PUTREG(env->regs[9]); | |
268 | + PUTREG(env->regs[10]); | |
269 | + PUTREG(env->regs[11]); | |
270 | + PUTREG(env->regs[12]); | |
271 | + PUTREG(env->regs[13]); | |
272 | + PUTREG(env->regs[14]); | |
273 | + PUTREG(env->regs[15]); | |
274 | + | |
275 | + PUTREG(env->eip); | |
276 | + PUTREG32(env->eflags); | |
277 | + PUTREG32(env->segs[R_CS].selector); | |
278 | + PUTREG32(env->segs[R_SS].selector); | |
279 | + PUTREG32(env->segs[R_DS].selector); | |
280 | + PUTREG32(env->segs[R_ES].selector); | |
281 | + PUTREG32(env->segs[R_FS].selector); | |
282 | + PUTREG32(env->segs[R_GS].selector); | |
283 | + /* XXX: convert floats */ | |
284 | + for(i = 0; i < 8; i++) { | |
285 | + PUTREGF(env->fpregs[i]); | |
286 | + } | |
287 | + PUTREG32(env->fpuc); | |
288 | + fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; | |
289 | + PUTREG32(fpus); | |
290 | + PUTREG32(0); /* XXX: convert tags */ | |
291 | + PUTREG32(0); /* fiseg */ | |
292 | + PUTREG32(0); /* fioff */ | |
293 | + PUTREG32(0); /* foseg */ | |
294 | + PUTREG32(0); /* fooff */ | |
295 | + PUTREG32(0); /* fop */ | |
296 | + | |
297 | +#undef PUTREG | |
298 | +#undef PUTREG32 | |
299 | +#undef PUTREGF | |
300 | + | |
301 | + return p - mem_buf; | |
302 | +} | |
303 | + | |
304 | +static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) | |
305 | +{ | |
306 | + uint8_t *p = mem_buf; | |
307 | + uint32_t junk; | |
308 | + int i, fpus; | |
309 | + | |
310 | +#define GETREG(x) do { \ | |
311 | + target_ulong reg; \ | |
312 | + memcpy(®, p, sizeof reg); \ | |
313 | + x = tswapl(reg); \ | |
314 | + p += sizeof reg; \ | |
315 | + } while (0) | |
316 | +#define GETREG32(x) do { \ | |
317 | + uint32_t reg; \ | |
318 | + memcpy(®, p, sizeof reg); \ | |
319 | + x = tswap32(reg); \ | |
320 | + p += sizeof reg; \ | |
321 | + } while (0) | |
322 | +#define GETREGF(x) do { \ | |
323 | + memcpy(&(x), p, 10); \ | |
324 | + p += 10; \ | |
325 | + } while (0) | |
326 | + | |
327 | + GETREG(env->regs[R_EAX]); | |
328 | + GETREG(env->regs[R_EBX]); | |
329 | + GETREG(env->regs[R_ECX]); | |
330 | + GETREG(env->regs[R_EDX]); | |
331 | + GETREG(env->regs[R_ESI]); | |
332 | + GETREG(env->regs[R_EDI]); | |
333 | + GETREG(env->regs[R_EBP]); | |
334 | + GETREG(env->regs[R_ESP]); | |
335 | + GETREG(env->regs[8]); | |
336 | + GETREG(env->regs[9]); | |
337 | + GETREG(env->regs[10]); | |
338 | + GETREG(env->regs[11]); | |
339 | + GETREG(env->regs[12]); | |
340 | + GETREG(env->regs[13]); | |
341 | + GETREG(env->regs[14]); | |
342 | + GETREG(env->regs[15]); | |
343 | + | |
344 | + GETREG(env->eip); | |
345 | + GETREG32(env->eflags); | |
346 | + GETREG32(env->segs[R_CS].selector); | |
347 | + GETREG32(env->segs[R_SS].selector); | |
348 | + GETREG32(env->segs[R_DS].selector); | |
349 | + GETREG32(env->segs[R_ES].selector); | |
350 | + GETREG32(env->segs[R_FS].selector); | |
351 | + GETREG32(env->segs[R_GS].selector); | |
352 | + /* XXX: convert floats */ | |
353 | + for(i = 0; i < 8; i++) { | |
354 | + GETREGF(env->fpregs[i]); | |
355 | + } | |
356 | + GETREG32(env->fpuc); | |
357 | + GETREG32(fpus); /* XXX: convert fpus */ | |
358 | + GETREG32(junk); /* XXX: convert tags */ | |
359 | + GETREG32(junk); /* fiseg */ | |
360 | + GETREG32(junk); /* fioff */ | |
361 | + GETREG32(junk); /* foseg */ | |
362 | + GETREG32(junk); /* fooff */ | |
363 | + GETREG32(junk); /* fop */ | |
364 | + | |
365 | +#undef GETREG | |
366 | +#undef GETREG32 | |
367 | +#undef GETREGF | |
368 | +} | |
238 | 369 | |
370 | +#elif defined(TARGET_I386) | |
239 | 371 | static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) |
240 | 372 | { |
241 | 373 | int i, fpus; | ... | ... |