Factor handle_bp_command into pieces:
[fw/openocd] / src / target / breakpoints.c
index c73d1f9aa4b7f0192475b2051a6436cd7695adf4..55524a7661a358f867fa4f4ba4c24d78faee78be 100644 (file)
 #include "config.h"
 #endif
 
-#include <stdlib.h>
-
-#include "binarybuffer.h"
 #include "target.h"
 #include "log.h"
-#include "types.h"
-
 #include "breakpoints.h"
 
-char *breakpoint_type_strings[] =
+
+static char *breakpoint_type_strings[] =
 {
        "hardware",
        "software"
 };
 
-char *watchpoint_rw_strings[] =
+static char *watchpoint_rw_strings[] =
 {
        "read",
        "write",
@@ -65,7 +61,7 @@ int breakpoint_add(target_t *target, u32 address, u32 length, enum breakpoint_ty
        (*breakpoint_p)->orig_instr = malloc(length);
        (*breakpoint_p)->next = NULL;
        
-       if ((retval = target->type->add_breakpoint(target, *breakpoint_p)) != ERROR_OK)
+       if ((retval = target_add_breakpoint(target, *breakpoint_p)) != ERROR_OK)
        {
                switch (retval)
                {
@@ -112,7 +108,7 @@ static void breakpoint_free(target_t *target, breakpoint_t *breakpoint_remove)
        if (breakpoint==NULL)
                return;
        
-       target->type->remove_breakpoint(target, breakpoint);
+       target_remove_breakpoint(target, breakpoint);
        
        (*breakpoint_p) = breakpoint->next;
        free(breakpoint->orig_instr);
@@ -188,7 +184,7 @@ int watchpoint_add(target_t *target, u32 address, u32 length, enum watchpoint_rw
        (*watchpoint_p)->set = 0;
        (*watchpoint_p)->next = NULL;
                
-       if ((retval = target->type->add_watchpoint(target, *watchpoint_p)) != ERROR_OK)
+       if ((retval = target_add_watchpoint(target, *watchpoint_p)) != ERROR_OK)
        {
                switch (retval)
                {
@@ -233,13 +229,11 @@ static void watchpoint_free(target_t *target, watchpoint_t *watchpoint_remove)
        
        if (watchpoint==NULL)
                return;
-       target->type->remove_watchpoint(target, watchpoint);
+       target_remove_watchpoint(target, watchpoint);
        (*watchpoint_p) = watchpoint->next;
        free(watchpoint);
 }
 
-
-
 void watchpoint_remove(target_t *target, u32 address)
 {
        watchpoint_t *watchpoint = target->watchpoints;
@@ -263,7 +257,6 @@ void watchpoint_remove(target_t *target, u32 address)
        }
 }
 
-
 void watchpoint_clear_target(target_t *target)
 {
        watchpoint_t *watchpoint;