diff options
author | Karl Palsson <karlp@tweak.net.au> | 2017-09-08 10:49:30 +0000 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2018-01-13 09:31:36 +0000 |
commit | 4e0371bf718c9eb3a862e3c9b113c95cd4c3a479 (patch) | |
tree | b71a6a5c06fbe54b27142bb077958e3f72ef8b73 /src/target/cortex_m.c | |
parent | 64b0d5aac0c5214db01f938550e8b126891d5a08 (diff) |
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 <karlp@tweak.net.au>
Reviewed-on: http://openocd.zylin.com/4220
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'src/target/cortex_m.c')
-rw-r--r-- | src/target/cortex_m.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 988323b0..24063a7e 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1707,7 +1707,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; @@ -1749,13 +1749,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) { |