The code you're looking for is riscv_get_gdb_reg_list() in
src/target/riscv.c. If you are thinking of making RISC-V-specific changes,
then https://github.com/riscv/riscv-openocd is the place you want. It has
many changes that haven't made it to the OpenOCD mainline yet.

Tim

On Wed, Feb 6, 2019 at 6:07 AM Xen Mann <[email protected]> wrote:

> We have figured out, that target_type->get_gdb_reg_list() is mandatory for
> supporting the gdb connection, see proof (if I'm not wrong) in the end of
> the mail.
> Because my core is a riscV (zeroRiscy) I had a look at the
> target/riscv/riscv-01x.c. There is no such function pointer in their
> structure defined.
>
> Does riscV support a GDB-connction. If yes, how?
>
>
> # different target_type structures
>
> struct target_type riscv013_target = {
>         .name = "riscv",
>
>         .init_target = init_target,
>         .deinit_target = deinit_target,
>         .examine = examine,
>
>         .poll = &riscv_openocd_poll,
>         .halt = &riscv_openocd_halt,
>         .resume = &riscv_openocd_resume,
>         .step = &riscv_openocd_step,
>
>         .assert_reset = assert_reset,
>         .deassert_reset = deassert_reset,
>
>         .read_memory = read_memory,
>         .write_memory = write_memory,
>
>         .arch_state = arch_state,
> };
>
> struct target_type riscv011_target = {
>         .name = "riscv",
>
>         .init_target = init_target,
>         .deinit_target = deinit_target,
>         .examine = examine,
>
>         /* poll current target status */
>         .poll = riscv011_poll,
>
>         .halt = halt,
>         .resume = riscv011_resume,
>         .step = step,
>
>         .assert_reset = assert_reset,
>         .deassert_reset = deassert_reset,
>
>         .read_memory = read_memory,
>         .write_memory = write_memory,
>
>         .arch_state = arch_state,
> };
>
> struct target_type arm9tdmi_target = {
>         .name = "arm9tdmi",
>
>         .poll = arm7_9_poll,
>         .arch_state = arm_arch_state,
>
>         .target_request_data = arm7_9_target_request_data,
>
>         .halt = arm7_9_halt,
>         .resume = arm7_9_resume,
>         .step = arm7_9_step,
>
>         .assert_reset = arm7_9_assert_reset,
>         .deassert_reset = arm7_9_deassert_reset,
>         .soft_reset_halt = arm7_9_soft_reset_halt,
>
>         .get_gdb_reg_list = arm_get_gdb_reg_list,
>
>         .read_memory = arm7_9_read_memory,
>         .write_memory = arm7_9_write_memory_opt,
>
>         .checksum_memory = arm_checksum_memory,
>         .blank_check_memory = arm_blank_check_memory,
>
>         .run_algorithm = armv4_5_run_algorithm,
>
>         .add_breakpoint = arm7_9_add_breakpoint,
>         .remove_breakpoint = arm7_9_remove_breakpoint,
>         .add_watchpoint = arm7_9_add_watchpoint,
>         .remove_watchpoint = arm7_9_remove_watchpoint,
>
>         .commands = arm9tdmi_command_handlers,
>         .target_create = arm9tdmi_target_create,
>         .init_target = arm9tdmi_init_target,
>         .examine = arm7_9_examine,
>         .check_reset = arm7_9_check_reset,
> };
>
>
>
> # Proof why get_gdb_reg_list() is mandatory
> ## check-function
> //target.c
> bool target_supports_gdb_connection(struct target *target)
> {
>         /*
>          * based on current code, we can simply exclude all the targets
> that
>          * don't provide get_gdb_reg_list; this could change with new
> targets.
>          */
>         return !!target->type->get_gdb_reg_list;
> }
>
> ## called by during startup
> // gdbserver.c
> static int gdb_target_add_one(struct target *target)
> {
>         /*  one gdb instance per smp list */
>         if ((target->smp) && (target->gdb_service))
>                 return ERROR_OK;
>
>         /* skip targets that cannot handle a gdb connections (e.g. mem_ap)
> */
>         if (!target_supports_gdb_connection(target)) {
>                 LOG_DEBUG("skip gdb server for target %s",
> target_name(target));
>                 return ERROR_OK;
>         }
>    ...
> }
>
>
> ## Stack trace of start up procedure
> gdb_target_add_one() at gdb_server.c
> gdb_target_add_all() at gdb_server.c
> handle_init_command() at openocd.c
> run_command() at command.c
> ...
>
>
> _______________________________________________
> OpenOCD-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openocd-devel
>
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to