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

target: Support 64-bit address for break/wath point #2017

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ void gdb_poll_target(void)
}

/* poll target */
target_addr_t watch;
target_addr64_t watch;
target_halt_reason_e reason = target_halt_poll(cur_target, &watch);
if (!reason)
return;
Expand All @@ -947,7 +947,8 @@ void gdb_poll_target(void)
gdb_putpacket_str_f("T%02Xthread:1;", GDB_SIGINT);
break;
case TARGET_HALT_WATCHPOINT:
gdb_putpacket_str_f("T%02Xwatch:%08" PRIX32 ";", GDB_SIGTRAP, watch);
gdb_putpacket_str_f(
"T%02Xwatch:%0" PRIX32 "%08" PRIX32 ";", GDB_SIGTRAP, (uint32_t)(watch >> 32U), (uint32_t)watch);
break;
case TARGET_HALT_FAULT:
gdb_putpacket_str_f("T%02Xthread:1;", GDB_SIGSEGV);
Expand Down
2 changes: 1 addition & 1 deletion src/include/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef enum target_halt_reason {

void target_reset(target_s *target);
void target_halt_request(target_s *target);
target_halt_reason_e target_halt_poll(target_s *target, target_addr_t *watch);
target_halt_reason_e target_halt_poll(target_s *target, target_addr64_t *watch);
void target_halt_resume(target_s *target, bool step);
void target_set_cmdline(target_s *target, const char *cmdline, size_t cmdline_len);
void target_set_heapinfo(target_s *target, target_addr_t heap_base, target_addr_t heap_limit, target_addr_t stack_base,
Expand Down
2 changes: 1 addition & 1 deletion src/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void poll_rtt(target_s *const cur_target)
rtt_halt = target_mem_access_needs_halt(cur_target);

bool resume_target = false;
target_addr_t watch;
target_addr64_t watch;
if (rtt_halt && target_halt_poll(cur_target, &watch) == TARGET_HALT_RUNNING) {
/* briefly halt target during target memory access */
target_halt_request(cur_target);
Expand Down
4 changes: 2 additions & 2 deletions src/target/cortexar.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static size_t cortexar_reg_read(target_s *target, uint32_t reg, void *data, size
static size_t cortexar_reg_write(target_s *target, uint32_t reg, const void *data, size_t max);

static void cortexar_reset(target_s *target);
static target_halt_reason_e cortexar_halt_poll(target_s *target, target_addr_t *watch);
static target_halt_reason_e cortexar_halt_poll(target_s *target, target_addr64_t *watch);
static void cortexar_halt_request(target_s *target);
static void cortexar_halt_resume(target_s *target, bool step);
static bool cortexar_halt_and_wait(target_s *target);
Expand Down Expand Up @@ -1405,7 +1405,7 @@ static void cortexar_halt_request(target_s *const target)
}
}

static target_halt_reason_e cortexar_halt_poll(target_s *const target, target_addr_t *const watch)
static target_halt_reason_e cortexar_halt_poll(target_s *const target, target_addr64_t *const watch)
{
volatile uint32_t dscr = 0;
TRY (EXCEPTION_ALL) {
Expand Down
4 changes: 2 additions & 2 deletions src/target/cortexm.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static size_t cortexm_reg_read(target_s *target, uint32_t reg, void *data, size_
static size_t cortexm_reg_write(target_s *target, uint32_t reg, const void *data, size_t max);

static void cortexm_reset(target_s *target);
static target_halt_reason_e cortexm_halt_poll(target_s *target, target_addr_t *watch);
static target_halt_reason_e cortexm_halt_poll(target_s *target, target_addr64_t *watch);
static void cortexm_halt_request(target_s *target);
static int cortexm_fault_unwind(target_s *target);

Expand Down Expand Up @@ -828,7 +828,7 @@ static void cortexm_halt_request(target_s *target)
}
}

static target_halt_reason_e cortexm_halt_poll(target_s *target, target_addr_t *watch)
static target_halt_reason_e cortexm_halt_poll(target_s *target, target_addr64_t *watch)
{
cortexm_priv_s *priv = target->priv;

Expand Down
4 changes: 2 additions & 2 deletions src/target/riscv_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static const char *riscv_target_description(target_s *target);
static bool riscv_check_error(target_s *target);
static void riscv_halt_request(target_s *target);
static void riscv_halt_resume(target_s *target, bool step);
static target_halt_reason_e riscv_halt_poll(target_s *target, target_addr_t *watch);
static target_halt_reason_e riscv_halt_poll(target_s *target, target_addr64_t *watch);
static void riscv_reset(target_s *target);

void riscv_dmi_init(riscv_dmi_s *const dmi)
Expand Down Expand Up @@ -1033,7 +1033,7 @@ static void riscv_halt_resume(target_s *target, const bool step)
(void)riscv_dm_write(hart->dbg_module, RV_DM_CONTROL, hart->hartsel);
}

static target_halt_reason_e riscv_halt_poll(target_s *const target, target_addr_t *const watch)
static target_halt_reason_e riscv_halt_poll(target_s *const target, target_addr64_t *const watch)
{
(void)watch;
riscv_hart_s *const hart = riscv_hart_struct(target);
Expand Down
2 changes: 1 addition & 1 deletion src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static const char *target_halt_reason_str(const target_halt_reason_e reason)
}
#endif

target_halt_reason_e target_halt_poll(target_s *target, target_addr_t *watch)
target_halt_reason_e target_halt_poll(target_s *target, target_addr64_t *watch)
{
if (target->halt_poll) {
const target_halt_reason_e reason = target->halt_poll(target, watch);
Expand Down
9 changes: 4 additions & 5 deletions src/target/target_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,11 @@ struct target_command {
typedef struct breakwatch breakwatch_s;

struct breakwatch {
/* XXX: This needs adjusting for 64-bit operations */
breakwatch_s *next;
target_breakwatch_e type;
target_addr32_t addr;
target_addr64_t addr;
Comment on lines -108 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reordering needs to be gated on sizeof(void *) - for the firmware, pointers are 32-bit so this mis-aligns the 64-bit int of addr, while this correctly aligns it on 64-bit platforms. Conditionally reordering the addr and type members is probably the right way forwards.

size_t size;
uint32_t reserved[4]; /* For use by the implementing driver */
target_breakwatch_e type;
uint32_t reserved[2]; /* For use by the implementing driver */
};

#define MAX_CMDLINE 81
Expand Down Expand Up @@ -137,7 +136,7 @@ struct target {
void (*reset)(target_s *target);
void (*extended_reset)(target_s *target);
void (*halt_request)(target_s *target);
target_halt_reason_e (*halt_poll)(target_s *target, target_addr_t *watch);
target_halt_reason_e (*halt_poll)(target_s *target, target_addr64_t *watch);
void (*halt_resume)(target_s *target, bool step);

/* Break-/watchpoint functions */
Expand Down
Loading