Trace From Trigger A to Trigger B

To set triggers, A and B in the Automatic (One-buffer) mode in the Disassembly view:

  1. In the CodeWarrior Projects view, select the Sources folder of your project.
  2. Double-click the source file, for example, main.c to display its contents in the editor area. Replace the source code of the main.c file with the source code shown in Listing: Source code for trace collection.
  3. Save and build the project.
  4. Open the Debug Configurations dialog box, and select your project in the tree structure.
  5. Click the Trace and Profile tab, and check the Enable Trace and Profiling checkbox.
  6. Select the Automatic (One-buffer) option from the Select Trace Mode group.
  7. Check the Halt the Target when Trace Buffer Gets Full checkbox.
  8. Select Trace from Trigger A to Trigger B from the Trace Start/Stop Conditions drop-down list.
  9. Click Apply to save the settings.
  10. Click Debug to debug the application.
  11. Open the Disassembly view.
  12. Right-click the marker bar corresponding to the statement, f();.
  13. Select Trace Triggers > Toggle Trace Trigger A from the context menu. The trigger A icon appears in green color on the marker bar, in the editor area and the Disassembly view.
  14. Right-click the marker bar corresponding to the statement, f2();.
  15. Select Trace Triggers > Toggle Trace Trigger B from the context menu. The trigger B icon appears in red color on the marker bar, in the editor area and the Disassembly view.
  16. Click Resume. The application stops automatically after some time and trace data is collected.
  17. Open the Trace Data viewer following the steps explained in the topic Viewing Data to view the trace results.

The figure below shows the data files that are generated by the application in which the data has been collected after setting triggers, A and B, in the Disassembly view and selecting the Automatic (One-buffer) mode. The Trace Data viewer in the figure shows that the trace data starts collecting from the f() function where you set trigger A. The application stops automatically when the trace buffer gets full and the trace data is collected till that trace buffer.

Figure 1. Trace Data View After Setting Trace From Trigger A to Trigger B in Automatic Mode
Trace Data View After Setting Trace From Trigger A to Trigger B in Automatic Mode

In this example, the trace buffer got full before trigger B was executed, therefore, the Trace Data viewer, as shown in the above figure, displays only the trace data collected from trigger A till first buffer full. If you resume the application at this point, trace will continue to collect till other part of the trace buffer gets full and so on till trigger B is hit. Once trigger B is hit, trace stops collecting.

Similarly, you can set the trace conditions, Trace from Trigger B to Trigger A , Trace from Trigger A to Trigger C , Trace from Trigger C to Trigger A , Trace from Trigger B to Trigger C , Trace from Trigger C to trigger B in both Continuous and Automatic modes and collect the trace data accordingly.

The Tracepoints on Data and Memory topic explains how to set trigger C.