aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Head <chead@zaber.com>2019-06-14 15:12:28 -0700
committerAntonio Borneo <borneo.antonio@gmail.com>2020-10-30 22:00:49 +0000
commita7502ee8b9d3fbb3ceb1fc151c3bc6fbfce3dbaa (patch)
tree37d2b27000c90a31e3c176f5a298232e14bf71c7
parentc1f4d9e6e8f9cdab122db36299e039a73151ffe4 (diff)
downloadriscv-openocd-a7502ee8b9d3fbb3ceb1fc151c3bc6fbfce3dbaa.zip
riscv-openocd-a7502ee8b9d3fbb3ceb1fc151c3bc6fbfce3dbaa.tar.gz
riscv-openocd-a7502ee8b9d3fbb3ceb1fc151c3bc6fbfce3dbaa.tar.bz2
target: allow profiling from running
There are a handful of implementations of profiling. There is the default implementation, which repeatedly halts and resumes the target, sampling PC each time. There is the Cortex-M implementation, which uses PCSR if available, otherwise falling back to halting and resuming and sampling PC. There is the OR1K implementation, which reads NPC repeatedly. Finally, there is the NDS32 implementation which uses some kind of AICE commands with which I am unfamiliar. None of these (with the possible exception of the NDS32 implementation) actually require the target to be halted when starting profiling. The Cortex-M and OR1K actually resume the target as pretty much their first action. The default implementation doesn’t do this, but is written in such a way that the target just flips back and forth between halted and running, and the code will do the right thing from either initial state. The NDS32 implementation I don’t know about. As such, for everything except NDS32, it is not really necessary that the target be halted to start profiling. For the non-PCSR Cortex-M and default implementations, there is no real harm in such a requirement, because profiling is intrusive anyway, but there is no benefit. For the PCSR-based Cortex-M and the OR1K, requiring that the target is halted is annoying because it makes profiling more intrusive. Remove the must-be-halted check from the target_profiling function. Add it to the NDS32 implementation because I am not sure if that will break when invoked with a running target. Do not add it to any of the other implementations because they don’t need it. Change-Id: I479dce999a80eccccfd3be4fa192c904f0a45709 Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5235 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
-rw-r--r--src/target/nds32.c6
-rw-r--r--src/target/target.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/target/nds32.c b/src/target/nds32.c
index 487e19c..add66b2 100644
--- a/src/target/nds32.c
+++ b/src/target/nds32.c
@@ -2496,6 +2496,12 @@ int nds32_profiling(struct target *target, uint32_t *samples,
struct aice_port_s *aice = target_to_aice(target);
struct nds32 *nds32 = target_to_nds32(target);
+ /* REVISIT: can nds32 profile without halting? */
+ if (target->state != TARGET_HALTED) {
+ LOG_WARNING("target %s is not halted (profiling)", target->cmd_name);
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
if (max_num_samples < iteration)
iteration = max_num_samples;
diff --git a/src/target/target.c b/src/target/target.c
index fa609ef..d1399ed 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1324,10 +1324,6 @@ unsigned target_address_bits(struct target *target)
int target_profiling(struct target *target, uint32_t *samples,
uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
{
- if (target->state != TARGET_HALTED) {
- LOG_WARNING("target %s is not halted (profiling)", target->cmd_name);
- return ERROR_TARGET_NOT_HALTED;
- }
return target->type->profiling(target, samples, max_num_samples,
num_samples, seconds);
}