Recommendations
QT
RACE
-
U
SER
M
ANUAL
© 2018 PDQLogic Ltd.
QTrace User Manual Rev 1.01
Page 45
9.
Recommendations
There are a number of factors which can affect tracing. The points below are recommendations and tips
which will help to avoid problems when tracing and improve its effectiveness.
9.1
General
1.
Disable all IDE trace options including SWO trace.
2.
Avoid using functions that execute WFE/WFI sleep instructions as this will cause trace output to be
suspended and will lead to erratic tracing behaviour. It is recommended to comment out WFE/WFI
instructions for builds to be used for tracing. The QTrace Analyser will detect if these instructions
are being used and will highlight their location(s).
If there is no associated source for the WFE/WFI instruction e.g. it is located in a library file, then
the WFE/WFI instruction will need to be patched with a NOP instruction. See Appendix C NoSleep
Utility for details of the NoSleep utility that can patch WFE/WFI instructions.
3.
When using a debugger script
6
, it is important that the firmware does not write to any of the trace
pin GPIO configuration registers or to the trace hardware registers as this will cause tracing to fail.
4.
Avoid running other CPU intensive PC applications while tracing.
5.
To reset the target processor from within the IDE:
a)
Stop the processor running
b)
Issue a target reset from within the IDE
c)
Manually start the processor running again
These steps will ensure the QTrace Analyser has enough time to detect the reset and to re-sync to
the target trace before execution restarts.
6.
Disable instruction simulation when using a Segger J-Link, see section 12.3.
7.
Connect a second screen to display the QTrace Analyser so that it can be viewed side by side with
the IDE/debugger.
8.
Do not place breakpoints on exception handlers. The buffered trace data is several instructions
behind the current instruction and a breakpoint will prevent the exception being decoded.
9.2
Programming Tips
1.
Turn off compiler optimisations for best results. As with conventional debugging, aggressive
compiler optimisation will affect the accuracy and effectiveness of source level debugging.
2.
Ensure maximum debug information is selected in the IDE compiler settings to give the most
accurate source level tracing information. For example, when using the GCC compiler use the
following compiler switches:
-gdwarf-3
&
-g3
.
3.
Do not have an empty ‘idle’ call-back function when using a RTOS as this is likely to generate a lot
of unnecessary trace data due to the way the call to this function is usually implemented.
4.
Place multiple conditionals on separate lines for easy identification of passed and failed conditions,
see Figure 9 on page 15 for an example.
5.
If the IDE automatically halts the CPU when it detects an exception, simply start the CPU running
again. This will flush the offending instruction through the CPU trace hardware which the QTrace
Analyser will then detect and present an 8M instruction history prior to the exception event in the
trace capture view. The same procedure is required if a break point is placed on an exception
handler.
6
See section 6.1.13 for further details