SEARCH
TOOLBOX
LANGUAGES
modified on 6 April 2012 at 19:39 ••• 69,560 views

Using Eclipse/4

From Manuals

(Difference between revisions)
Jump to: navigation, search
Line 16: Line 16:
Advance to the ‘Debugger’ tab and if necessary, change the GDB debugger to match your toolchain.  Advance to the ‘Commands’ tab and enter the following for the initialization commands:
Advance to the ‘Debugger’ tab and if necessary, change the GDB debugger to match your toolchain.  Advance to the ‘Commands’ tab and enter the following for the initialization commands:
-
target remote localhost:3333
+
<code>target remote localhost:3333</code>
-
monitor jtag arp_init
+
 
-
monitor reset init
+
<code>monitor jtag arp_init</code>
-
b main
+
 
-
load
+
<code>monitor reset init</code>
 +
 
 +
<code>b main</code>
 +
 
 +
<code>load</code>
 +
 
Enter the following for the run commands:
Enter the following for the run commands:
-
jResetISR
+
 
 +
<code>jResetISR</code>
   
   
[[Image:GDB_Commands.png|center|frame|alt=GDB Commands|Figure 10 – Specifying GDB commands]]
[[Image:GDB_Commands.png|center|frame|alt=GDB Commands|Figure 10 – Specifying GDB commands]]

Revision as of 22:22, 15 June 2010

Debugging using Eclipse

OpenOCD

OpenOCD is open source application designed to assist in the debugging of embedded target devices and will provide a debugging interface to our device by acting as a GDB Server. It is necessary to have OpenOCD running before beginning a debug session. Eclipse can make this easier by configuring it as an external tool. To do this, select ‘Run,’ ‘External Tools,’ ‘External Tools Configurations…’ and double-click on ‘Program’ to create a new program configuration. Specify the name, location, and working directory of your OpenOCD configuration. Advance to the ‘Build’ tab, unselect ‘Build before launch,’ click ‘Apply’ and then ‘Close.’

Configuring OpenOCD
Figure 7 – Configuring OpenOCD as an external tool

To run OpenOCD, click the ‘Run Last Tool’ icon and select OpenOCD. This only needs to be done once you being a new Eclipse session as OpenOCD will remain running until Eclipse exits. Any output printed by OpenOCD can be viewed in the console tab.

Running OpenOCD
Figure 8 - Starting OpenOCD

Debug Configuration

Before beginning a debug session, a debug configuration must be made describing how Eclipse will handle debugging the application. To do this, right click on the project you wish to debug, select ‘Debug As,’ ‘Debug Configurations,’ and double-click ‘Zylin Embedded debug (Native)’ to create a new configuration. Specify the name for this configuration and browse to the application binary for this project.

New Debug Configuration
Figure 9 – Creating a new debug configuration

Advance to the ‘Debugger’ tab and if necessary, change the GDB debugger to match your toolchain. Advance to the ‘Commands’ tab and enter the following for the initialization commands:

target remote localhost:3333

monitor jtag arp_init

monitor reset init

b main

load

Enter the following for the run commands:

jResetISR

GDB Commands
Figure 10 – Specifying GDB commands

Click ‘Apply’ and ‘Close’ to complete the debug configuration. Debugging To begin a new debug session, click the arrow next to the Debug icon and select ‘Debug Configurations…’

Running Debug
Figure 11 – Running a debug configuration

Click ‘Debug’ and click ‘Yes’ when Eclipse prompts you to move to the debug configuration. Your perspective should look similar to the figure below. The Resume, Suspend, Terminate, Step Into, and Step Over buttons are highlighted in red.

Debugging Perspective
Figure 12 – Eclipse’s debug perspective

The program should be stopped at the first instruction in main. This is due to specifying the breakpoint main as one of the debug initialization commands. You can view your source code in the center of the screen and navigate through the project in the Outline tab on the right. Details about your current debug configuration can be seen in the Debug tab in the upper left hand corner. Current variables, breakpoints, and register values can be seen in their corresponding tabs in the upper right hand corner. Console output can be viewed in the Console tab at the bottom. To step to the next instruction, click the ‘Step Over’ icon. To step to the next assembly instruction, click the ‘Instruction Stepping Mode’ icon and click the ‘Step Over’ icon. Assembly code can then be viewed on the right next to the Outline tab. To insert a breakpoint, double-click on the bar to the left of the instruction that you wish to break at. To add a breakpoint condition, right click on the breakpoint and select ‘Breakpoint Properties,’ ‘Common,’ and enter the breakpoint condition. To watch an expression, select the variable, right click, and select ‘Add watch expression…’ The expression can then be viewed in the Expressions tab in the upper right hand corner of the screen. The Resume, Suspend, and Terminate buttons can simply be used to continue, break, or end the debugging session.