target: allow profiling from running 35/5235/5
authorChristopher Head <chead@zaber.com>
Fri, 14 Jun 2019 22:12:28 +0000 (15:12 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 30 Oct 2020 22:00:49 +0000 (22:00 +0000)
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>
src/target/nds32.c
src/target/target.c

index 487e19c6ad054d4b2a9845cea1523e96c5ceb156..add66b22f48fc9b535d37e7150cc432ebf1c456e 100644 (file)
@@ -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;
 
index fa609efdb3af350df4d5fe7c4ba100e10ff19d9b..d1399eddfe82c72e3e5932d4cba2930686f99176 100644 (file)
@@ -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);
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)