Skip to content

Commit 161f30c

Browse files
authored
Merge pull request #79 from RinHizakura/gdbstub
Update mini-gdbstub with the API changes
2 parents 16ee11a + 764d516 commit 161f30c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

main.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,12 @@ static inline bool semu_is_interrupt(emu_state_t *emu)
775775
return __atomic_load_n(&emu->is_interrupted, __ATOMIC_RELAXED);
776776
}
777777

778-
static int semu_read_reg(void *args, int regno, size_t *data)
778+
static size_t semu_get_reg_bytes(UNUSED int regno)
779+
{
780+
return 4;
781+
}
782+
783+
static int semu_read_reg(void *args, int regno, void *data)
779784
{
780785
emu_state_t *emu = (emu_state_t *) args;
781786

@@ -785,9 +790,9 @@ static int semu_read_reg(void *args, int regno, size_t *data)
785790
assert((uint32_t) emu->curr_cpuid < emu->vm.n_hart);
786791

787792
if (regno == 32)
788-
*data = emu->vm.hart[emu->curr_cpuid]->pc;
793+
*(uint32_t *) data = emu->vm.hart[emu->curr_cpuid]->pc;
789794
else
790-
*data = emu->vm.hart[emu->curr_cpuid]->x_regs[regno];
795+
*(uint32_t *) data = emu->vm.hart[emu->curr_cpuid]->x_regs[regno];
791796

792797
return 0;
793798
}
@@ -845,6 +850,7 @@ static int semu_run_debug(emu_state_t *emu)
845850

846851
gdbstub_t gdbstub;
847852
struct target_ops gdbstub_ops = {
853+
.get_reg_bytes = semu_get_reg_bytes,
848854
.read_reg = semu_read_reg,
849855
.write_reg = NULL,
850856
.read_mem = semu_read_mem,
@@ -864,7 +870,6 @@ static int semu_run_debug(emu_state_t *emu)
864870
(arch_info_t){
865871
.smp = vm->n_hart,
866872
.reg_num = 33,
867-
.reg_byte = 4,
868873
.target_desc = TARGET_RV32,
869874
},
870875
"127.0.0.1:1234")) {

0 commit comments

Comments
 (0)