Skip to content

Commit e5888bd

Browse files
sobuchtom-van
authored andcommitted
target/breakpoints: drop duplicate breakpoint/watchpoint "clear_target" functions
We need to cleanup watchpoints on all targets in SMP group when GDB connects. Otherwise, the targets will not be consistent. Once thats fixed, both *_clear_target functions clearly duplicate the corresponding *_remove_all functions. Change-Id: I8e85dbc66fd3e596990d631ed2aed22959a8ca60 Signed-off-by: Samuel Obuch <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9086 Reviewed-by: Evgeniy Naydanov <[email protected]> Tested-by: jenkins Reviewed-by: Tomas Vanek <[email protected]>
1 parent 8967382 commit e5888bd

File tree

3 files changed

+6
-44
lines changed

3 files changed

+6
-44
lines changed

src/server/gdb_server.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ static int gdb_new_connection(struct connection *connection)
10411041
* GDB session could leave dangling breakpoints if e.g. communication
10421042
* timed out.
10431043
*/
1044-
breakpoint_clear_target(target);
1045-
watchpoint_clear_target(target);
1044+
breakpoint_remove_all(target);
1045+
watchpoint_remove_all(target);
10461046

10471047
/* Since version 3.95 (gdb-19990504), with the exclusion of 6.5~6.8, GDB
10481048
* sends an ACK at connection with the following comment in its source code:
@@ -3219,8 +3219,8 @@ static void gdb_restart_inferior(struct connection *connection, const char *pack
32193219
struct gdb_connection *gdb_con = connection->priv;
32203220
struct target *target = get_target_from_connection(connection);
32213221

3222-
breakpoint_clear_target(target);
3223-
watchpoint_clear_target(target);
3222+
breakpoint_remove_all(target);
3223+
watchpoint_remove_all(target);
32243224
command_run_linef(connection->cmd_ctx, "ocd_gdb_restart %s",
32253225
target_name(target));
32263226
/* set connection as attached after reset */

src/target/breakpoints.c

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ static int watchpoint_free(struct target *target, struct watchpoint *watchpoint_
412412

413413
static int watchpoint_remove_all_internal(struct target *target)
414414
{
415+
LOG_TARGET_DEBUG(target, "Delete all watchpoints");
416+
415417
struct watchpoint *watchpoint = target->watchpoints;
416418
int retval = ERROR_OK;
417419

@@ -465,27 +467,6 @@ int watchpoint_remove_all(struct target *target)
465467
return breakpoint_watchpoint_remove_all(target, WATCHPOINT);
466468
}
467469

468-
int breakpoint_clear_target(struct target *target)
469-
{
470-
int retval = ERROR_OK;
471-
472-
if (target->smp) {
473-
struct target_list *head;
474-
475-
foreach_smp_target(head, target->smp_targets) {
476-
struct target *curr = head->target;
477-
int status = breakpoint_remove_all_internal(curr);
478-
479-
if (status != ERROR_OK)
480-
retval = status;
481-
}
482-
} else {
483-
retval = breakpoint_remove_all_internal(target);
484-
}
485-
486-
return retval;
487-
}
488-
489470
struct breakpoint *breakpoint_find(struct target *target, target_addr_t address)
490471
{
491472
struct breakpoint *breakpoint = target->breakpoints;
@@ -641,23 +622,6 @@ int watchpoint_remove(struct target *target, target_addr_t address)
641622
return retval;
642623
}
643624

644-
int watchpoint_clear_target(struct target *target)
645-
{
646-
LOG_TARGET_DEBUG(target, "Delete all watchpoints");
647-
648-
struct watchpoint *watchpoint = target->watchpoints;
649-
int retval = ERROR_OK;
650-
651-
while (watchpoint) {
652-
struct watchpoint *tmp = watchpoint;
653-
watchpoint = watchpoint->next;
654-
int status = watchpoint_free(target, tmp);
655-
if (status != ERROR_OK)
656-
retval = status;
657-
}
658-
return retval;
659-
}
660-
661625
int watchpoint_hit(struct target *target, enum watchpoint_rw *rw,
662626
target_addr_t *address)
663627
{

src/target/breakpoints.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ struct watchpoint {
5050
int unique_id;
5151
};
5252

53-
int breakpoint_clear_target(struct target *target);
5453
int breakpoint_add(struct target *target,
5554
target_addr_t address, unsigned int length, enum breakpoint_type type);
5655
int context_breakpoint_add(struct target *target,
@@ -69,7 +68,6 @@ static inline void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int
6968
breakpoint->number = hw_number;
7069
}
7170

72-
int watchpoint_clear_target(struct target *target);
7371
int watchpoint_add(struct target *target,
7472
target_addr_t address, unsigned int length,
7573
enum watchpoint_rw rw, uint64_t value, uint64_t mask);

0 commit comments

Comments
 (0)