Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mini-gdbstub with the API changes #589

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ void rv_debug(riscv_t *rv)
if (!gdbstub_init(&rv->gdbstub, &gdbstub_ops,
(arch_info_t){
.reg_num = 33,
.reg_byte = 4,
.target_desc = TARGET_RV32,
},
GDBSTUB_COMM)) {
Expand Down
18 changes: 12 additions & 6 deletions src/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,36 @@
#include "riscv.h"
#include "riscv_private.h"

static int rv_read_reg(void *args, int regno, size_t *data)
static size_t rv_get_reg_bytes(UNUSED int regno)
{
return 4;
}

static int rv_read_reg(void *args, int regno, void *data)
{
riscv_t *rv = (riscv_t *) args;

if (unlikely(regno > 32))
return EFAULT;

if (regno == 32)
*data = rv_get_pc(rv);
*(riscv_word_t *) data = rv_get_pc(rv);
else
*data = rv_get_reg(rv, regno);
*(riscv_word_t *) data = rv_get_reg(rv, regno);

return 0;
}

static int rv_write_reg(void *args, int regno, size_t data)
static int rv_write_reg(void *args, int regno, void *data)
{
if (unlikely(regno > 32))
return EFAULT;

riscv_t *rv = (riscv_t *) args;
if (regno == 32)
rv_set_pc(rv, data);
rv_set_pc(rv, *(riscv_word_t *) data);
else
rv_set_reg(rv, regno, data);
rv_set_reg(rv, regno, *(riscv_word_t *) data);

return 0;
}
Expand Down Expand Up @@ -132,6 +137,7 @@ static void rv_on_interrupt(void *args)
}

const struct target_ops gdbstub_ops = {
.get_reg_bytes = rv_get_reg_bytes,
.read_reg = rv_read_reg,
.write_reg = rv_write_reg,
.read_mem = rv_read_mem,
Expand Down
2 changes: 1 addition & 1 deletion src/mini-gdbstub
Loading