|
18 | 18 | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
19 | 19 | */
|
20 | 20 | #include "qemu/osdep.h"
|
| 21 | +#include "accel/tcg/vcpu-state.h" |
21 | 22 | #include "cpu.h"
|
| 23 | +#include "exec/gdbstub.h" |
22 | 24 | #include "gdbstub/helpers.h"
|
| 25 | +#ifdef CONFIG_LINUX_USER |
| 26 | +#include "linux-user/qemu.h" |
| 27 | +#endif |
23 | 28 |
|
24 | 29 | #ifdef TARGET_X86_64
|
25 | 30 | static const int gpr_map[16] = {
|
@@ -406,3 +411,49 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
406 | 411 | /* Unrecognised register. */
|
407 | 412 | return 0;
|
408 | 413 | }
|
| 414 | + |
| 415 | +#ifdef CONFIG_LINUX_USER |
| 416 | + |
| 417 | +#define IDX_ORIG_AX 0 |
| 418 | + |
| 419 | +static int x86_cpu_gdb_read_linux_register(CPUState *cs, GByteArray *mem_buf, |
| 420 | + int n) |
| 421 | +{ |
| 422 | + X86CPU *cpu = X86_CPU(cs); |
| 423 | + CPUX86State *env = &cpu->env; |
| 424 | + |
| 425 | + switch (n) { |
| 426 | + case IDX_ORIG_AX: |
| 427 | + return gdb_get_reg(env, mem_buf, get_task_state(cs)->orig_ax); |
| 428 | + } |
| 429 | + return 0; |
| 430 | +} |
| 431 | + |
| 432 | +static int x86_cpu_gdb_write_linux_register(CPUState *cs, uint8_t *mem_buf, |
| 433 | + int n) |
| 434 | +{ |
| 435 | + X86CPU *cpu = X86_CPU(cs); |
| 436 | + CPUX86State *env = &cpu->env; |
| 437 | + |
| 438 | + switch (n) { |
| 439 | + case IDX_ORIG_AX: |
| 440 | + return gdb_write_reg(env, mem_buf, &get_task_state(cs)->orig_ax); |
| 441 | + } |
| 442 | + return 0; |
| 443 | +} |
| 444 | + |
| 445 | +#endif |
| 446 | + |
| 447 | +void x86_cpu_gdb_init(CPUState *cs) |
| 448 | +{ |
| 449 | +#ifdef CONFIG_LINUX_USER |
| 450 | + gdb_register_coprocessor(cs, x86_cpu_gdb_read_linux_register, |
| 451 | + x86_cpu_gdb_write_linux_register, |
| 452 | +#ifdef TARGET_X86_64 |
| 453 | + gdb_find_static_feature("i386-64bit-linux.xml"), |
| 454 | +#else |
| 455 | + gdb_find_static_feature("i386-32bit-linux.xml"), |
| 456 | +#endif |
| 457 | + 0); |
| 458 | +#endif |
| 459 | +} |
0 commit comments