Debugging programs: Difference between revisions
(Updated for latest nspire_emu/Ndless SDK version) |
|||
Line 2: | Line 2: | ||
'''[[Emulators#nspire_emu|nspire_emu]]''' includes a simple command-line ARM debugger you can bring up from the ''Emulation > Enter debugger'' menu. It features ARM disassembly, instruction stepping, memory and instruction breakpoints, backtracing and memory dumping. The debugger commands available can be shown with the command '<tt>?</tt>'. | '''[[Emulators#nspire_emu|nspire_emu]]''' includes a simple command-line ARM debugger you can bring up from the ''Emulation > Enter debugger'' menu. It features ARM disassembly, instruction stepping, memory and instruction breakpoints, backtracing and memory dumping. The debugger commands available can be shown with the command '<tt>?</tt>'. | ||
== | ==GDB support== | ||
GDB is the [http://www.gnu.org/software/gdb/ GNU Project Debugger]. The | GDB is the [http://www.gnu.org/software/gdb/ GNU Project Debugger]. The nspire_emu emulator implements the [http://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html#Remote-Protocol GDB Remote Serial Protocol] for compatibility with any [http://en.wikipedia.org/wiki/Debugger_front_end GDB front end] such as the standard command-line interface, [http://sourceware.org/insight/ Insight], [http://www.eclipse.org/cdt/ Eclipse CDT] or the scite-debug SciTE plugin available with the Windows NdlessEditor. | ||
GDB allows source-level debugging, which means: | GDB allows source-level debugging, which means: | ||
Line 9: | Line 9: | ||
*you can execute line-by-line your C programs, view the content of C variables during execution and set breakpoints from the source code | *you can execute line-by-line your C programs, view the content of C variables during execution and set breakpoints from the source code | ||
=== | ===With the NdlessEditor=== | ||
Follow the [http://ndlessly.wordpress.com/debugging-with-gdb/ tutorial on ndlessly]. | |||
===With the GDB command line interface=== | |||
nspire_emu (... usual options) /G= | |||
This will make | Run nspire_emu with the <tt>/G</tt> option: | ||
nspire_emu (... usual options) /G=3333 | |||
This will make nspire_emu listen for GDB commands on the TCP port 3333. | |||
You can now launch your favorite GDB front end and connect it to <tt>localhost:1000</tt>. | You can now launch your favorite GDB front end and connect it to <tt>localhost:1000</tt>. | ||
On Windows, [http://www.yagarto.de/ YAGARTO] GNU ARM toolchain includes the standard GDB client, run with <tt>arm-none-eabi-gdb</tt> from a command prompt. | |||
[http://www.yagarto.de/ YAGARTO] GNU ARM toolchain includes the standard GDB client, run with <tt>arm-none-eabi-gdb</tt> from a command prompt. | |||
The following GDB commands can be used to connect to Ncubate: | The following GDB commands can be used to connect to Ncubate: | ||
file <your_program. | file <your_program.gdb> | ||
target remote localhost: | target remote localhost:3333 | ||
break main | break main | ||
Running the ''file'' command before the ''target'' command is important for address relocation. | Running the ''file'' command before the ''target'' command is important for address relocation. | ||
You can the run the program from | You can the run the program from nspire_emu with the latest Ndless. The program will break on the ''main()'' function. Then use <tt>s</tt> (step), <tt>n</tt> (next) and [http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf other GDB commands]. | ||
===With Eclipse CDT=== | |||
[http://www.eclipse.org/cdt/ Eclipse CDT] | [http://www.eclipse.org/cdt/ Eclipse CDT] is a GUI for C and C++ development based on GNU tools. | ||
On Windows, make sure that MSYS's <tt>bin</tt> directory is [http://www.computerhope.com/issues/ch000549.htm on the PATH] before running Eclipse, else you won't be able to build your program. | On Windows, make sure that MSYS's <tt>bin</tt> directory is [http://www.computerhope.com/issues/ch000549.htm on the PATH] before running Eclipse, else you won't be able to build your program. | ||
Line 39: | Line 36: | ||
If running a 64-bit operating system, ensure that Yagarto is ''not'' located in <tt>C:\Program Files (x86)</tt>. By default, Yagarto will install here. Simply move it to <tt>C:\Yagarto</tt> and update your path by removing the old reference to Yagarto and adding <tt>C:\Yagarto\bin</tt> | If running a 64-bit operating system, ensure that Yagarto is ''not'' located in <tt>C:\Program Files (x86)</tt>. By default, Yagarto will install here. Simply move it to <tt>C:\Yagarto</tt> and update your path by removing the old reference to Yagarto and adding <tt>C:\Yagarto\bin</tt> | ||
Once your source code is imported into an Eclipse project and can be built within Eclipse, the visual debugger can be used to connect to | Once your source code is imported into an Eclipse project and can be built within Eclipse, the visual debugger can be used to connect to nspire_emu. | ||
This [http://www.youtube.com/watch?v=JB-SnyZpbA4 video tutorial] shows how to set up use the main features of Eclipse CDT's debugger | This [http://www.youtube.com/watch?v=JB-SnyZpbA4 video tutorial] shows how to set up use the main features of Eclipse CDT's debugger (note: the tutorial features the now out-of-date Ncubate emulator and an old version of Eclipse CDT). |
Latest revision as of 11:42, 19 July 2013
nspire_emu's native debugger
nspire_emu includes a simple command-line ARM debugger you can bring up from the Emulation > Enter debugger menu. It features ARM disassembly, instruction stepping, memory and instruction breakpoints, backtracing and memory dumping. The debugger commands available can be shown with the command '?'.
GDB support
GDB is the GNU Project Debugger. The nspire_emu emulator implements the GDB Remote Serial Protocol for compatibility with any GDB front end such as the standard command-line interface, Insight, Eclipse CDT or the scite-debug SciTE plugin available with the Windows NdlessEditor.
GDB allows source-level debugging, which means:
- for ARM developments, you can see you assembly symbols while debugging
- you can execute line-by-line your C programs, view the content of C variables during execution and set breakpoints from the source code
With the NdlessEditor
Follow the tutorial on ndlessly.
With the GDB command line interface
Run nspire_emu with the /G option:
nspire_emu (... usual options) /G=3333
This will make nspire_emu listen for GDB commands on the TCP port 3333.
You can now launch your favorite GDB front end and connect it to localhost:1000.
On Windows, YAGARTO GNU ARM toolchain includes the standard GDB client, run with arm-none-eabi-gdb from a command prompt. The following GDB commands can be used to connect to Ncubate:
file <your_program.gdb> target remote localhost:3333 break main
Running the file command before the target command is important for address relocation.
You can the run the program from nspire_emu with the latest Ndless. The program will break on the main() function. Then use s (step), n (next) and other GDB commands.
With Eclipse CDT
Eclipse CDT is a GUI for C and C++ development based on GNU tools.
On Windows, make sure that MSYS's bin directory is on the PATH before running Eclipse, else you won't be able to build your program.
If running a 64-bit operating system, ensure that Yagarto is not located in C:\Program Files (x86). By default, Yagarto will install here. Simply move it to C:\Yagarto and update your path by removing the old reference to Yagarto and adding C:\Yagarto\bin
Once your source code is imported into an Eclipse project and can be built within Eclipse, the visual debugger can be used to connect to nspire_emu.
This video tutorial shows how to set up use the main features of Eclipse CDT's debugger (note: the tutorial features the now out-of-date Ncubate emulator and an old version of Eclipse CDT).