Datasheet
Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
30
How can trace help me find problems ?
Trace, either SWV or ETM, adds significant power to debugging efforts. Tells you where the program has been, how it got
there, how long it took, when did the interrupts fire and all about data reads and writes.
With RTOS and interrupt driven events – many programs are now asynchronous. Trace helps sort this out and
provides for the dynamic analysis of running code.
Putting test or printf code in your project sometimes changes or erases the problem. Trace is non-intrusive.
Trace can often find nasty problems very quickly. Weeks or months can be replaced by minutes. Really !
….especially where the bug occurs a long time before the consequences are seen.
Or where the state of the system disappears with a change in scope(s).
Plus – you don’t have to stop the program t see the trace. This is crucial to some applications.
No trace availability is responsible for unsolved bugs – some of these problems are too hard to find without it.
Pointer problems. Is your pointer really reading or writing what you think it is ? Where is it pointing to ?
Illegal instructions and data aborts (such as misaligned writes).
Code overwrites – writes to Flash, unexpected writes to peripheral registers.
Profile Analyzer. Where is the CPU spending its time ? Where should I start to optimize my program ?
Code Coverage. Can be a certification requirement. Was this instruction executed ?
Serial Wire Viewer and ETM Trace Summary:
Serial Wire Viewer can see:
Global variables.
Static variables.
Structures.
Peripheral registers – just read or write to them.
Can’t see local variables. (just make them global or static).
Can’t see DMA transfers – DMA bypasses CPU and CoreSight by definition.
Serial Wire Viewer displays in various ways:
PC Samples.
Data reads and writes.
Exception and interrupt events.
CPU counters.
Timestamps for these.
These are the types of problems that can be found with a quality ETM trace:
Pointer problems.
Illegal instructions and data aborts (such as misaligned writes).
Code overwrites – writes to Flash, unexpected writes to peripheral registers (SFRs), a corrupted stack.
How did I get here ?
Out of bounds data. Uninitialized variables and arrays.
Stack overflows. What causes the stack to grow bigger than it should ?
Runaway programs: your program has gone off into the weeds and you need to know what instruction caused this.
Is very tough to find these problems without a trace. ETM trace is best for this.
Communication protocol and timing issues. System timing problems.