This is an automated email from Gerrit.

Andreas Fritiofson ([email protected]) just uploaded a new patch set 
to Gerrit, which you can find at http://openocd.zylin.com/3664

-- gerrit

commit 5f267a9f71b77a3c85f5d84826be2f46ef6de3c3
Author: Andreas Fritiofson <[email protected]>
Date:   Thu Aug 11 13:40:55 2016 +0200

    arm_dpm: Avoid modifying target_type during setup
    
    arm_dpm_setup() is called from the arm11, cortex_a and cortex_r4
    targets' examine functions. It conditionally and unconditionally
    overrides the breakpoint and watchpoint add/remove functions.
    
    To avoid modifying the target_type struct at runtime, adjust the
    affected targets' target_types static initialization to get the
    same effect and remove the dynamic change from arm_dpm_setup().
    
    The breakpoint code in arm_dpm.c is actually dead code since no
    target ends up calling them (yet?) but they might be used in the
    future so export the functions instead of removing them.
    
    Change-Id: I0a54079630539a88e73f9f87f5dce58a24f135a3
    Signed-off-by: Andreas Fritiofson <[email protected]>

diff --git a/src/target/arm11.c b/src/target/arm11.c
index cbe4d45..50c8132 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -1373,6 +1373,9 @@ struct target_type arm11_target = {
        .add_breakpoint = arm11_add_breakpoint,
        .remove_breakpoint = arm11_remove_breakpoint,
 
+       .add_watchpoint = arm_dpm_add_watchpoint,
+       .remove_watchpoint = arm_dpm_remove_watchpoint,
+
        .run_algorithm = armv4_5_run_algorithm,
 
        .commands = arm11_command_handlers,
diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c
index 8ad6575..200b052 100644
--- a/src/target/arm_dpm.c
+++ b/src/target/arm_dpm.c
@@ -343,8 +343,6 @@ done:
        return retval;
 }
 
-static int dpm_add_breakpoint(struct target *target, struct breakpoint *bp);
-
 /**
  * Writes all modified core registers for all processor modes.  In normal
  * operation this is called on exit from halting debug state.
@@ -371,7 +369,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool 
bpwp)
         * we should be able to assume we handle them; but until then,
         * cope with the hand-crafted breakpoint code.
         */
-       if (arm->target->type->add_breakpoint == dpm_add_breakpoint) {
+       if (arm->target->type->add_breakpoint == arm_dpm_add_breakpoint) {
                for (unsigned i = 0; i < dpm->nbp; i++) {
                        struct dpm_bp *dbp = dpm->dbp + i;
                        struct breakpoint *bp = dbp->bp;
@@ -772,7 +770,7 @@ static int dpm_bpwp_setup(struct arm_dpm *dpm, struct 
dpm_bpwp *xp,
        return ERROR_OK;
 }
 
-static int dpm_add_breakpoint(struct target *target, struct breakpoint *bp)
+int arm_dpm_add_breakpoint(struct target *target, struct breakpoint *bp)
 {
        struct arm *arm = target_to_arm(target);
        struct arm_dpm *dpm = arm->dpm;
@@ -800,7 +798,7 @@ static int dpm_add_breakpoint(struct target *target, struct 
breakpoint *bp)
        return retval;
 }
 
-static int dpm_remove_breakpoint(struct target *target, struct breakpoint *bp)
+int arm_dpm_remove_breakpoint(struct target *target, struct breakpoint *bp)
 {
        struct arm *arm = target_to_arm(target);
        struct arm_dpm *dpm = arm->dpm;
@@ -856,7 +854,7 @@ static int dpm_watchpoint_setup(struct arm_dpm *dpm, 
unsigned index_t,
        return retval;
 }
 
-static int dpm_add_watchpoint(struct target *target, struct watchpoint *wp)
+int arm_dpm_add_watchpoint(struct target *target, struct watchpoint *wp)
 {
        struct arm *arm = target_to_arm(target);
        struct arm_dpm *dpm = arm->dpm;
@@ -874,7 +872,7 @@ static int dpm_add_watchpoint(struct target *target, struct 
watchpoint *wp)
        return retval;
 }
 
-static int dpm_remove_watchpoint(struct target *target, struct watchpoint *wp)
+int arm_dpm_remove_watchpoint(struct target *target, struct watchpoint *wp)
 {
        struct arm *arm = target_to_arm(target);
        struct arm_dpm *dpm = arm->dpm;
@@ -982,16 +980,6 @@ int arm_dpm_setup(struct arm_dpm *dpm)
        arm->mrc = dpm_mrc;
        arm->mcr = dpm_mcr;
 
-       /* breakpoint setup -- optional until it works everywhere */
-       if (!target->type->add_breakpoint) {
-               target->type->add_breakpoint = dpm_add_breakpoint;
-               target->type->remove_breakpoint = dpm_remove_breakpoint;
-       }
-
-       /* watchpoint setup */
-       target->type->add_watchpoint = dpm_add_watchpoint;
-       target->type->remove_watchpoint = dpm_remove_watchpoint;
-
        /* FIXME add vector catch support */
 
        dpm->nbp = 1 + ((dpm->didr >> 24) & 0xf);
diff --git a/src/target/arm_dpm.h b/src/target/arm_dpm.h
index fa87baf..246225d 100644
--- a/src/target/arm_dpm.h
+++ b/src/target/arm_dpm.h
@@ -133,6 +133,10 @@ int arm_dpm_initialize(struct arm_dpm *dpm);
 int arm_dpm_read_current_registers(struct arm_dpm *);
 int dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode);
 
+int arm_dpm_add_breakpoint(struct target *target, struct breakpoint *bp);
+int arm_dpm_remove_breakpoint(struct target *target, struct breakpoint *bp);
+int arm_dpm_add_watchpoint(struct target *target, struct watchpoint *wp);
+int arm_dpm_remove_watchpoint(struct target *target, struct watchpoint *wp);
 
 int arm_dpm_write_dirty_registers(struct arm_dpm *, bool bpwp);
 
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index d1590f6..7ad9dc4 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -3495,8 +3495,8 @@ struct target_type cortexa_target = {
        .add_context_breakpoint = cortex_a_add_context_breakpoint,
        .add_hybrid_breakpoint = cortex_a_add_hybrid_breakpoint,
        .remove_breakpoint = cortex_a_remove_breakpoint,
-       .add_watchpoint = NULL,
-       .remove_watchpoint = NULL,
+       .add_watchpoint = arm_dpm_add_watchpoint,
+       .remove_watchpoint = arm_dpm_remove_watchpoint,
 
        .commands = cortex_a_command_handlers,
        .target_create = cortex_a_target_create,
@@ -3580,8 +3580,8 @@ struct target_type cortexr4_target = {
        .add_context_breakpoint = cortex_a_add_context_breakpoint,
        .add_hybrid_breakpoint = cortex_a_add_hybrid_breakpoint,
        .remove_breakpoint = cortex_a_remove_breakpoint,
-       .add_watchpoint = NULL,
-       .remove_watchpoint = NULL,
+       .add_watchpoint = arm_dpm_add_watchpoint,
+       .remove_watchpoint = arm_dpm_remove_watchpoint,
 
        .commands = cortex_r4_command_handlers,
        .target_create = cortex_r4_target_create,

-- 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to