| |||
| Home > Examples > Debugging a system that must not be halted > Solution using the state machine | |||
This solution to the example is based on tracing the instructions
that are executed between entry to and exit from the MonitorRequests function.
This includes any interrupt handler code as well as functions that MonitorRequests calls.
If you are using ETM hardware implementing ETM version 1.2, it is quicker to configure start/stop points for this task. However, you can still use the state machine for this or other solutions.
This solution requires you to perform the following procedures:
In this procedure, you initialize the target and load the debugger with the debug information for the program. Follow these steps:
Load the program symbols into the debugger:
If the program is not already running, select Load Image from the File menu to load the executable for which you want to gather trace information.
If the program is already running, or loads or runs from ROM, select Load symbols only… from the File menu.
After you load an image into AXD, you might have to change
the top_of_memory variable value to correspond
to the top-of-memory address of your target hardware (see the Debugger
Internals window section in the AXD and armsd Debuggers
Guide).
Set the overall configuration of the ETM hardware by selecting Configure ETM from the Trace menu. The options configured in this dialog box apply to any subsequent tracing you perform (see Configure ETM).
In this procedure you set up the trace capture rules that define the data that is displayed in the Trace window. Follow these steps:
Set the tracing conditions by selecting Configure Capture from the Trace menu. The Configure capture dialog box is shown in Figure 8.35.
Double-click Go from State 1 to 2 in the Actions list to define a rule. The Go from State 1 to 2 Resource selection dialog box shown in Figure 8.36 is displayed.
Click on the drop-down list showing TRUE and select Address Point.
Click on Next>. The Include Address Point dialog box shown in Figure 8.37 is displayed.
In the Address field, enter %.MonitorRequests
Click Next> to display the end of rule dialog box.
Click Finish to create this rule. The Configure capture dialog box is updated as shown in Figure 8.38.
In this procedure you set up the trace capture rules that define the data that is displayed in the Trace window. Follow these steps:
Double-click Go from State 2 to 1 in the Actions list to define a rule. The Go from State 2 to 1 Resource selection dialog box shown in Figure 8.39 is displayed.
Click on the drop-down list showing TRUE and select Address Point.
Click on Next>. The Include Address Point dialog box shown in Figure 8.40 is displayed.
In the Address field, enter %,
where 437 is the line number of the function return code.MonitorRequests:437
Click Next> to display the end of rule dialog box.
Click Finish to create this rule. The Configure capture dialog box is updated as shown in Figure 8.41.
In this procedure you set up the trace capture rules that define the data that is displayed in the Trace window. Follow these steps:
Double-click Enable Tracing in the Actions list to define a rule. The Enable Tracing Resource selection dialog box shown in Figure 8.42 is displayed.
Click on the drop-down list showing TRUE and select In State 2.
Click Next> to display the end of rule dialog box.
Click Finish to create this rule. The Configure capture dialog box is updated as shown in Figure 8.43.
In this procedure you set up the trigger rule that defines the data that is displayed in the Trace window. Follow these steps:
Double-click Trigger in the Actions list to define a rule. The Trigger Resource selection dialog box shown in Figure 8.44 is displayed.
Click on the drop-down list showing TRUE and select Address Point.
Move the Trigger Position slider to the End of buffer position.
Setting up the trigger in this way causes the trace buffer to match on an address, which we will define next, and contain all the trace information up to the point the trigger matches.
Click on Next>. The Address Point dialog box shown in Figure 8.45 is displayed.
In the Address field, enter %MonitorRequests:437 ,
where 437 is the line number of the end of the function.
Click Next> to display the end of rule dialog box.
Click Finish to complete the rule. The Configure capture dialog box shown in Figure 8.46 now has four rules in the Rules list.
Click on OK to activate the rules.
To trace the target:
A dialog box is displayed asking if you want to Start tracing now?. Click on Yes. TDT writes the trace rules and the ETM configuration to the ETM hardware, and instructs the ETM to start collecting trace data based on these values
Click View Trace on the Trace menu. The trace output window appears.
If your program is not already running, select Go from the Execute menu. During execution, trace information is returned to the Trace window.
To analyze the trace data:
You can now:
compare the trace output with its corresponding area of code in the executable (see Viewing trace output with source code)
link a row of trace output to its corresponding area of memory in the Memory Window (see Viewing memory at a location derived from trace output)
save the trace output to a file (see Saving the trace output to file).
By examining the trace output you can try to determine what is happening.