Hi,
trying to profile a cortex-M0 target (stm32F042) with a jlink . If I don't specify Start and End :
(gdb) monitor profile 5 test.out
[stm32f0x.cpu] Starting Cortex-M profiling. Sampling DWT_PCSR as fast as we can...
[stm32f0x.cpu] Profiling completed. 10000 samples.
openocd: src/target/target.c:4258: write_gmon: Assertion `address_space >= 2' failed.
[stm32f0x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x08002142 msp: 0x20001760
Remote connection closed
Should probably either
Sidenote, a hardcoded limit of 10k samples ??
yes, this code has two ugly abort() when it should just report an error or a warning.
That's a kind of old coding style that is still present here and there in OpenOCD.
In your case, the PC is sampled but it always returns the same value
Is target running in an infinite loop?
Or maybe your M0 does not implements PC sampling and reading register DWT_PCSR returns zero.
The code computes min and max PC and if it finds that min and max are the same it abort() instead of printing an error or something useful.
You can verify that the PC is always the same value running few times
mdw 0xE000101C
but not from GDB, because GDB let you type the command only with target halted.
You need to telnet in OpenOCD with
telnet 127.0.0.1 4444
then type few times the mdw command above
Thanks.
I doubt that - I eventually got a proper trace by giving Start and End args» :
Yes it does, DWT_PCSR is documented in the ref manual for stm32F042.
Still, for thoroughness, I just manually ran a few "mdw 0xE000101C" and getting different PC values, as should be.
Would you mind checking
https://review.openocd.org/7394/
and report if it fixes your use case?
Thanks, but no - see my comments on gerritt. I believe it has to do with cortex-M0 sometimes having the magic value 0xfffffff9 in LR/PC on return from interrupts
Last edit: fenugrec 2022-12-11
My bad - it does indeed fix the assert() failure , I got mixed up with 2 different targets with different firmware (one of which has an empty while(1) which indeed returns only 1 value for PC). I replied on gerritt but somehow the comment disappeared.
This extra patch addresses the case of PC constant due to 'while (1);'
https://review.openocd.org/7400/
Patches merged