This is an automated email from Gerrit.

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

-- gerrit

commit b6af3c45af490a6ad6f9e33c443a50510262acec
Author: Karl Palsson <[email protected]>
Date:   Fri Sep 8 10:49:30 2017 +0000

    hla_target: allow non-intrusive profiling on cortex-m
    
    Leverages the existing work that added profiling via DWT_PCSR.
    
    hla_target doesn't have direct access to the mem_ap for doing a bulk
    repeated read, but simply reading the DWT_PCSR register repeatedly is
    still ~2 order of magnitude faster than halt/resume.
    
    Change-Id: Ibe451aa95143694398370fdad6939cfb6191d56f
    Signed-off-by: Karl Palsson <[email protected]>

diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index e51581f..e4532e6 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -1713,7 +1713,7 @@ void cortex_m_deinit_target(struct target *target)
        free(cortex_m);
 }
 
-static int cortex_m_profiling(struct target *target, uint32_t *samples,
+int cortex_m_profiling(struct target *target, uint32_t *samples,
                              uint32_t max_num_samples, uint32_t *num_samples, 
uint32_t seconds)
 {
        struct timeval timeout, now;
@@ -1755,13 +1755,18 @@ static int cortex_m_profiling(struct target *target, 
uint32_t *samples,
 
        for (;;) {
                if (use_pcsr) {
-                       uint32_t read_count = max_num_samples - sample_count;
-                       if (read_count > 1024)
-                               read_count = 1024;
-                       retval = mem_ap_read_buf_noincr(armv7m->debug_ap,
+                       if (armv7m && armv7m->debug_ap) {
+                               uint32_t read_count = max_num_samples - 
sample_count;
+                               if (read_count > 1024)
+                                       read_count = 1024;
+
+                               retval = 
mem_ap_read_buf_noincr(armv7m->debug_ap,
                                                        (void 
*)&samples[sample_count],
                                                        4, read_count, 
DWT_PCSR);
-                       sample_count += read_count;
+                               sample_count += read_count;
+                       } else {
+                               target_read_u32(target, DWT_PCSR, 
&samples[sample_count++]);
+                       }
                } else {
                        target_poll(target);
                        if (target->state == TARGET_HALTED) {
diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h
index dbf9ac8..f2c82df 100644
--- a/src/target/cortex_m.h
+++ b/src/target/cortex_m.h
@@ -213,5 +213,7 @@ void cortex_m_enable_breakpoints(struct target *target);
 void cortex_m_enable_watchpoints(struct target *target);
 void cortex_m_dwt_setup(struct cortex_m_common *cm, struct target *target);
 void cortex_m_deinit_target(struct target *target);
+int cortex_m_profiling(struct target *target, uint32_t *samples,
+                              uint32_t max_num_samples, uint32_t *num_samples, 
uint32_t seconds);
 
 #endif /* OPENOCD_TARGET_CORTEX_M_H */
diff --git a/src/target/hla_target.c b/src/target/hla_target.c
index 78dc8c5..a3e6835 100644
--- a/src/target/hla_target.c
+++ b/src/target/hla_target.c
@@ -814,4 +814,5 @@ struct target_type hla_target = {
        .remove_breakpoint = cortex_m_remove_breakpoint,
        .add_watchpoint = cortex_m_add_watchpoint,
        .remove_watchpoint = cortex_m_remove_watchpoint,
+       .profiling = cortex_m_profiling,
 };

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to