Compare commits

...

2 Commits

Author SHA1 Message Date
Gleb Gagarin 030abf5be0 set hartid in riscv013_is_halted function 2017-09-20 17:16:52 -07:00
Gleb Gagarin 371fddfc41 Fixes for multicore debug in Eclipse 2017-09-16 10:07:31 -07:00
3 changed files with 15 additions and 6 deletions

View File

@ -1810,6 +1810,8 @@ static void riscv013_on_halt(struct target *target)
static bool riscv013_is_halted(struct target *target) static bool riscv013_is_halted(struct target *target)
{ {
riscv_set_current_hartid(target, riscv_current_hartid(target));
uint32_t dmstatus = dmi_read(target, DMI_DMSTATUS); uint32_t dmstatus = dmi_read(target, DMI_DMSTATUS);
if (get_field(dmstatus, DMI_DMSTATUS_ANYUNAVAIL)) if (get_field(dmstatus, DMI_DMSTATUS_ANYUNAVAIL))
LOG_ERROR("hart %d is unavailiable", riscv_current_hartid(target)); LOG_ERROR("hart %d is unavailiable", riscv_current_hartid(target));

View File

@ -391,22 +391,25 @@ static int add_trigger(struct target *target, struct trigger *trigger)
riscv_reg_t tselect[RISCV_MAX_HARTS]; riscv_reg_t tselect[RISCV_MAX_HARTS];
int active_hartid = 0;
for (int hartid = 0; hartid < riscv_count_harts(target); ++hartid) { for (int hartid = 0; hartid < riscv_count_harts(target); ++hartid) {
if (!riscv_hart_enabled(target, hartid)) if (!riscv_hart_enabled(target, hartid))
continue; continue;
active_hartid = hartid;
tselect[hartid] = riscv_get_register_on_hart(target, hartid, tselect[hartid] = riscv_get_register_on_hart(target, hartid,
GDB_REGNO_TSELECT); GDB_REGNO_TSELECT);
} }
unsigned int i; unsigned int i;
for (i = 0; i < r->trigger_count[0]; i++) { for (i = 0; i < r->trigger_count[active_hartid]; i++) {
if (r->trigger_unique_id[i] != -1) { if (r->trigger_unique_id[i] != -1) {
continue; continue;
} }
riscv_set_register_on_hart(target, 0, GDB_REGNO_TSELECT, i); riscv_set_register_on_hart(target, active_hartid, GDB_REGNO_TSELECT, i);
uint64_t tdata1 = riscv_get_register_on_hart(target, 0, GDB_REGNO_TDATA1); uint64_t tdata1 = riscv_get_register_on_hart(target, active_hartid, GDB_REGNO_TDATA1);
int type = get_field(tdata1, MCONTROL_TYPE(riscv_xlen(target))); int type = get_field(tdata1, MCONTROL_TYPE(riscv_xlen(target)));
int result = ERROR_OK; int result = ERROR_OK;
@ -450,7 +453,7 @@ static int add_trigger(struct target *target, struct trigger *trigger)
tselect[hartid]); tselect[hartid]);
} }
if (i >= r->trigger_count[0]) { if (i >= r->trigger_count[active_hartid]) {
LOG_ERROR("Couldn't find an available hardware trigger."); LOG_ERROR("Couldn't find an available hardware trigger.");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
} }
@ -460,6 +463,8 @@ static int add_trigger(struct target *target, struct trigger *trigger)
int riscv_add_breakpoint(struct target *target, struct breakpoint *breakpoint) int riscv_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
{ {
assert(riscv_is_halted(target));
if (breakpoint->type == BKPT_SOFT) { if (breakpoint->type == BKPT_SOFT) {
if (target_read_memory(target, breakpoint->address, breakpoint->length, 1, if (target_read_memory(target, breakpoint->address, breakpoint->length, 1,
breakpoint->orig_instr) != ERROR_OK) { breakpoint->orig_instr) != ERROR_OK) {
@ -503,12 +508,12 @@ static int remove_trigger(struct target *target, struct trigger *trigger)
RISCV_INFO(r); RISCV_INFO(r);
unsigned int i; unsigned int i;
for (i = 0; i < r->trigger_count[0]; i++) { for (i = 0; i < r->trigger_count[target->coreid]; i++) {
if (r->trigger_unique_id[i] == trigger->unique_id) { if (r->trigger_unique_id[i] == trigger->unique_id) {
break; break;
} }
} }
if (i >= r->trigger_count[0]) { if (i >= r->trigger_count[target->coreid]) {
LOG_ERROR("Couldn't find the hardware resources used by hardware " LOG_ERROR("Couldn't find the hardware resources used by hardware "
"trigger."); "trigger.");
return ERROR_FAIL; return ERROR_FAIL;

View File

@ -608,6 +608,8 @@ int target_resume(struct target *target, int current, target_addr_t address,
{ {
int retval; int retval;
target->halt_issued = false;
/* We can't poll until after examine */ /* We can't poll until after examine */
if (!target_was_examined(target)) { if (!target_was_examined(target)) {
LOG_ERROR("Target not examined yet"); LOG_ERROR("Target not examined yet");