Skip to content

Commit

Permalink
target/riscv: use breakpoint_hw_set/watchpoint_set to properly initia…
Browse files Browse the repository at this point in the history
…lize bp/wp descriptor

Signed-off-by: Parshintsev Anatoly <[email protected]>
  • Loading branch information
aap-sc committed Apr 23, 2024
1 parent 3991492 commit 88f7650
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,19 +1415,21 @@ static int riscv_add_breakpoint(struct target *target, struct breakpoint *breakp
TARGET_PRIxADDR, breakpoint->length, breakpoint->address);
return ERROR_FAIL;
}
breakpoint->is_set = true;

} else if (breakpoint->type == BKPT_HARD) {
struct trigger trigger;
trigger_from_breakpoint(&trigger, breakpoint);
int const result = add_trigger(target, &trigger);
if (result != ERROR_OK)
return result;

int trigger_idx = find_first_trigger_by_id(target, breakpoint->unique_id);
breakpoint_hw_set(breakpoint, trigger_idx);
} else {
LOG_TARGET_INFO(target, "OpenOCD only supports hardware and software breakpoints.");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}

breakpoint->is_set = true;
return ERROR_OK;
}

Expand Down Expand Up @@ -1521,7 +1523,9 @@ int riscv_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
int result = add_trigger(target, &trigger);
if (result != ERROR_OK)
return result;
watchpoint->is_set = true;

int trigger_idx = find_first_trigger_by_id(target, watchpoint->unique_id);
watchpoint_set(watchpoint, trigger_idx);

return ERROR_OK;
}
Expand Down

0 comments on commit 88f7650

Please sign in to comment.