Skip to content

Commit a11fd2b

Browse files
committed
cortexar: Added override of soft to hard breakpoints
- 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.
1 parent 611a789 commit a11fd2b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/target/cortexar.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,15 @@ static int cortexar_breakwatch_set(target_s *const target, breakwatch_s *const b
16001600
{
16011601
cortexar_priv_s *const priv = (cortexar_priv_s *)target->priv;
16021602

1603-
switch (breakwatch->type) {
1603+
/*
1604+
* Redirect soft to hard breakpoints (until soft breakpoints are working?)
1605+
* GDB automatically selects soft breakpoints when an address is in RAM. This
1606+
* code is needed to allow breakpoints to work when the break type can't be
1607+
* configured in a GDB frontend (eg: in cortex-debug for VSCode).
1608+
*/
1609+
target_breakwatch_e bw_type = breakwatch->type == TARGET_BREAK_SOFT ? TARGET_BREAK_HARD : breakwatch->type;
1610+
1611+
switch (bw_type) {
16041612
case TARGET_BREAK_HARD: {
16051613
/* First try and find a unused breakpoint slot */
16061614
size_t breakpoint = 0;
@@ -1652,7 +1660,15 @@ static int cortexar_breakwatch_clear(target_s *const target, breakwatch_s *const
16521660
{
16531661
cortexar_priv_s *const priv = (cortexar_priv_s *)target->priv;
16541662

1655-
switch (breakwatch->type) {
1663+
/*
1664+
* Redirect soft to hard breakpoints (until soft breakpoints are working?)
1665+
* GDB automatically selects soft breakpoints when an address is in RAM. This
1666+
* code is needed to allow breakpoints to work when the break type can't be
1667+
* configured in a GDB frontend (eg: in cortex-debug for VSCode).
1668+
*/
1669+
target_breakwatch_e bw_type = breakwatch->type == TARGET_BREAK_SOFT ? TARGET_BREAK_HARD : breakwatch->type;
1670+
1671+
switch (bw_type) {
16561672
case TARGET_BREAK_HARD: {
16571673
/* Clear the breakpoint slot this used */
16581674
const size_t breakpoint = breakwatch->reserved[0];

0 commit comments

Comments
 (0)