Skip to content

Commit

Permalink
cortexar: Added override of soft to hard breakpoints
Browse files Browse the repository at this point in the history
- Found that some GDB frontends (eg: cortex-debug) don't allow specifying the type of breakpoint to use. Since we don't have working soft breakpoints for cortexar, it makes sense to override and use hard breakpoints in both cases.
  • Loading branch information
litui committed Sep 1, 2024
1 parent 60a5880 commit b961e13
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/target/cortexar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,15 @@ static int cortexar_breakwatch_set(target_s *const target, breakwatch_s *const b
{
cortexar_priv_s *const priv = (cortexar_priv_s *)target->priv;

switch (breakwatch->type) {
/*
* Redirect soft to hard breakpoints (until soft breakpoints are working?)
* GDB automatically selects soft breakpoints when an address is in RAM. This
* code is needed to allow breakpoints to work when the break type can't be
* configured in a GDB frontend (eg: in cortex-debug for VSCode).
*/
target_breakwatch_e bw_type = breakwatch->type == TARGET_BREAK_SOFT ? TARGET_BREAK_HARD : breakwatch->type;

switch (bw_type) {
case TARGET_BREAK_HARD: {
/* First try and find a unused breakpoint slot */
size_t breakpoint = 0;
Expand Down Expand Up @@ -1652,7 +1660,15 @@ static int cortexar_breakwatch_clear(target_s *const target, breakwatch_s *const
{
cortexar_priv_s *const priv = (cortexar_priv_s *)target->priv;

switch (breakwatch->type) {
/*
* Redirect soft to hard breakpoints (until soft breakpoints are working?)
* GDB automatically selects soft breakpoints when an address is in RAM. This
* code is needed to allow breakpoints to work when the break type can't be
* configured in a GDB frontend (eg: in cortex-debug for VSCode).
*/
target_breakwatch_e bw_type = breakwatch->type == TARGET_BREAK_SOFT ? TARGET_BREAK_HARD : breakwatch->type;

switch (bw_type) {
case TARGET_BREAK_HARD: {
/* Clear the breakpoint slot this used */
const size_t breakpoint = breakwatch->reserved[0];
Expand Down

0 comments on commit b961e13

Please sign in to comment.