This is an automated email from Gerrit.

"Tarek BOCHKATI <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6550

-- gerrit

commit 525653eeb546862ae80cdfd3df96d5e84628c87c
Author: Tarek BOCHKATI <[email protected]>
Date:   Tue Sep 7 16:05:34 2021 +0100

    target: remove useless calls to target_set_examined()
    
    in target infrastructure the target::examined flag is set to true if the
    target::examine() returns ERROR_OK
    
    while at there add these notes:
     - cortex_m_examine : highlight that setting the examined flag is mandatory
       to complete the target examination
     - FIXME notes in targets where we are not sure if this setting the examined
       flag is really mandatory to complete the examination.
    
    Change-Id: If71a3f92971a835211a967b5eb11d7cc9d15e3aa
    Signed-off-by: Tarek BOCHKATI <[email protected]>

diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 70e727cf9..3786af240 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -2677,7 +2677,10 @@ static int aarch64_examine_first(struct target *target)
        target->state = TARGET_UNKNOWN;
        target->debug_reason = DBG_REASON_NOTHALTED;
        aarch64->isrmasking_mode = AARCH64_ISRMASK_ON;
+
+       /* FIXME is this needed to complete the execution aarch64_examine() ? */
        target_set_examined(target);
+
        return ERROR_OK;
 }
 
diff --git a/src/target/arc.c b/src/target/arc.c
index 4b546c3b4..82dd72847 100644
--- a/src/target/arc.c
+++ b/src/target/arc.c
@@ -741,8 +741,6 @@ static int arc_examine(struct target *target)
 
                /* Read BCRs and configure optional registers. */
                CHECK_RETVAL(arc_configure(target));
-
-               target_set_examined(target);
        }
 
        return ERROR_OK;
diff --git a/src/target/arm11.c b/src/target/arm11.c
index e3b0975fb..ddc219115 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -1238,8 +1238,6 @@ static int arm11_examine(struct target *target)
                CHECK_RETVAL(etm_setup(target));
        }
 
-       target_set_examined(target);
-
        return ERROR_OK;
 }
 
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index cf77a81a7..26f49e090 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -2687,6 +2687,8 @@ int arm7_9_examine(struct target *target)
                                        &arm7_9->jtag_info,
                                        arm7_9->arm.etm);
 
+               /* FIXME is this needed to complete the execution 
arm7_9_examine()
+                * and feroceon_examine() ? */
                target_set_examined(target);
        }
 
diff --git a/src/target/avr32_ap7k.c b/src/target/avr32_ap7k.c
index 4cf0276d6..edd2fca43 100644
--- a/src/target/avr32_ap7k.c
+++ b/src/target/avr32_ap7k.c
@@ -538,7 +538,9 @@ static int avr32_ap7k_examine(struct target *target)
        struct avr32_ap7k_common *ap7k = target_to_ap7k(target);
 
        if (!target_was_examined(target)) {
+               /* FIXME is this needed to complete the execution 
avr32_ap7k_examine() ? */
                target_set_examined(target);
+
                avr32_jtag_nexus_read(&ap7k->jtag, AVR32_OCDREG_DID, &devid);
                LOG_INFO("device id: %08" PRIx32, devid);
                avr32_ocd_setbits(&ap7k->jtag, AVR32_OCDREG_DC, OCDREG_DC_DBE);
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index b1f22067f..424ff6fc1 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -3067,7 +3067,9 @@ static int cortex_a_examine_first(struct target *target)
        /* select debug_ap as default */
        swjdp->apsel = armv7a->debug_ap->ap_num;
 
+       /* FIXME is this needed to complete the execution cortex_a_examine() ? 
*/
        target_set_examined(target);
+
        return ERROR_OK;
 }
 
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index 08f2eb911..3656a0abe 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -2057,6 +2057,9 @@ int cortex_m_examine(struct target *target)
        }
 
        if (!target_was_examined(target)) {
+               /* setting target to examined is needed to execute 
target_read_u32
+                * if this cortex_m_examine() fails, the examined flag will be 
reset
+                * to false by the target infrastructure */
                target_set_examined(target);
 
                /* Read from Device Identification Registers */
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index 0d80ed367..b7aa61b6e 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -929,6 +929,7 @@ static int dsp563xx_examine(struct target *target)
        }
 
        if (!target_was_examined(target)) {
+               /* FIXME is this needed to complete the execution 
dsp563xx_examine() ? */
                target_set_examined(target);
 
                /* examine core and chip derivate number */
diff --git a/src/target/esirisc.c b/src/target/esirisc.c
index e49f5f659..d48662ba1 100644
--- a/src/target/esirisc.c
+++ b/src/target/esirisc.c
@@ -1648,8 +1648,6 @@ static int esirisc_examine(struct target *target)
                        }
                }
 
-               target_set_examined(target);
-
                LOG_INFO("%s: %d bit, %d registers, %s%s%s", 
target_name(target),
                                esirisc->num_bits, esirisc->num_regs,
                                target_endianness(target),
diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c
index eef05b44b..9b764a784 100644
--- a/src/target/mem_ap.c
+++ b/src/target/mem_ap.c
@@ -140,7 +140,10 @@ static int mem_ap_examine(struct target *target)
 
        if (!target_was_examined(target)) {
                mem_ap->ap = dap_ap(mem_ap->dap, mem_ap->ap_num);
+
+               /* FIXME is this needed to complete the execution of 
mem_ap_init() ? */
                target_set_examined(target);
+
                target->state = TARGET_UNKNOWN;
                target->debug_reason = DBG_REASON_UNDEFINED;
                return mem_ap_init(mem_ap->ap);
diff --git a/src/target/mips32.c b/src/target/mips32.c
index c82536931..c2130c9fa 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -547,8 +547,6 @@ int mips32_examine(struct target *target)
        struct mips32_common *mips32 = target_to_mips32(target);
 
        if (!target_was_examined(target)) {
-               target_set_examined(target);
-
                /* we will configure later */
                mips32->bp_scanned = 0;
                mips32->num_inst_bpoints = 0;
diff --git a/src/target/mips64.c b/src/target/mips64.c
index 347cdfc4b..467c04d27 100644
--- a/src/target/mips64.c
+++ b/src/target/mips64.c
@@ -479,8 +479,6 @@ int mips64_examine(struct target *target)
        mips64->num_inst_bpoints = 0;
        mips64->num_inst_bpoints_avail = 0;
 
-       target_set_examined(target);
-
        return ERROR_OK;
 }
 
diff --git a/src/target/nds32_v2.c b/src/target/nds32_v2.c
index 49a5758f7..fb2c6185f 100644
--- a/src/target/nds32_v2.c
+++ b/src/target/nds32_v2.c
@@ -630,8 +630,6 @@ static int nds32_v2_examine(struct target *target)
        nds32->target->state = TARGET_RUNNING;
        nds32->target->debug_reason = DBG_REASON_NOTHALTED;
 
-       target_set_examined(target);
-
        return ERROR_OK;
 }
 
diff --git a/src/target/nds32_v3.c b/src/target/nds32_v3.c
index fde86d6e8..797b753ff 100644
--- a/src/target/nds32_v3.c
+++ b/src/target/nds32_v3.c
@@ -462,8 +462,6 @@ static int nds32_v3_examine(struct target *target)
        nds32->target->state = TARGET_RUNNING;
        nds32->target->debug_reason = DBG_REASON_NOTHALTED;
 
-       target_set_examined(target);
-
        return ERROR_OK;
 }
 
diff --git a/src/target/nds32_v3m.c b/src/target/nds32_v3m.c
index ffd646f33..48844daff 100644
--- a/src/target/nds32_v3m.c
+++ b/src/target/nds32_v3m.c
@@ -449,8 +449,6 @@ static int nds32_v3m_examine(struct target *target)
        nds32->target->state = TARGET_RUNNING;
        nds32->target->debug_reason = DBG_REASON_NOTHALTED;
 
-       target_set_examined(target);
-
        return ERROR_OK;
 }
 
diff --git a/src/target/openrisc/or1k.c b/src/target/openrisc/or1k.c
index 8fbcd9620..f1c9f0c9b 100644
--- a/src/target/openrisc/or1k.c
+++ b/src/target/openrisc/or1k.c
@@ -1136,6 +1136,7 @@ static int or1k_examine(struct target *target)
 
        if (!target_was_examined(target)) {
 
+               /* FIXME is this needed to complete the execution of 
or1k_examine() ? */
                target_set_examined(target);
 
                int running;
diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c
index 7a5e990ca..98d6c5fbe 100644
--- a/src/target/riscv/riscv-011.c
+++ b/src/target/riscv/riscv-011.c
@@ -1586,7 +1586,9 @@ static int examine(struct target *target)
        if (result != ERROR_OK)
                return result;
 
+       /* FIXME is this needed to complete the execution of this examine() 
function ? */
        target_set_examined(target);
+
        riscv_set_current_hartid(target, 0);
        for (size_t i = 0; i < 32; ++i)
                reg_cache_set(target, i, -1);
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 24fb79ccf..494298908 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1761,6 +1761,7 @@ static int examine(struct target *target)
                        riscv013_step_or_resume_current_hart(target, false, 
false);
        }
 
+       /* FIXME is this needed to complete the execution of this examine() 
function ? */
        target_set_examined(target);
 
        if (target->smp) {
diff --git a/src/target/stm8.c b/src/target/stm8.c
index 21fc8c54f..7bb63920b 100644
--- a/src/target/stm8.c
+++ b/src/target/stm8.c
@@ -1716,8 +1716,6 @@ static int stm8_examine(struct target *target)
                        }
                }
 
-               target_set_examined(target);
-
                return ERROR_OK;
        }
 
diff --git a/src/target/target.c b/src/target/target.c
index e6c1ade84..a2144b524 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -728,7 +728,6 @@ static inline void target_reset_examined(struct target 
*target)
 
 static int default_examine(struct target *target)
 {
-       target_set_examined(target);
        return ERROR_OK;
 }
 

-- 

Reply via email to