Debugging programs: Difference between revisions

From Hackspire
Jump to navigation Jump to search
(Creation)
 
(Add How to use it - GDB CLI)
Line 8: Line 8:
*for ARM developments, you can see you assembly symbols while debugging
*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
*you can execute line-by-line your C programs, view the content of C variables during execution and set breakpoints from the source code
===How to use it===
For any debugging session, make sure to rebuild (<tt>make clean all</tt>) your whole program with the following additional <tt>nspire-gcc</tt> flags (set with the variable <tt>GCCFLAGS</tt> in Ndless sample Makefiles):
GCCFLAGS = -O0 -g (... other flags)
Then run Ncubate with the <tt>/G</tt> option:
nspire_emu (... usual options) /G=1000
This will make Ncubate listen for GDB commands on the TCP port 1000. Your firewall may prompt to open the port.
You can now launch your favorite GDB front end and connect it to <tt>localhost:1000</tt>.
Programs built with [[Ndless]] require Ndless v1.7 to be intalled on the OS image.
====With GDB command line interface====
[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:
file <your_program.elf>
target remote localhost:1000
break main
Running the ''file'' command before the ''target'' command is important for address relocation.
You can the run the program from Ncubate, which will break on the ''main()'' function, and then use <tt>s</tt> (step), <tt>n</tt> (next) and [http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf other GDB commands].

Revision as of 09:26, 6 November 2010

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 '?'.

Ncubate's GDB support

GDB is the GNU Project Debugger. The Ncubate emulator implements the GDB Remote Serial Protocol for compatibility with any GDB front end such as the standard command-line interface, Insight or Eclipse CDT.

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

How to use it

For any debugging session, make sure to rebuild (make clean all) your whole program with the following additional nspire-gcc flags (set with the variable GCCFLAGS in Ndless sample Makefiles):

GCCFLAGS = -O0 -g (... other flags)

Then run Ncubate with the /G option:

nspire_emu (... usual options) /G=1000

This will make Ncubate listen for GDB commands on the TCP port 1000. Your firewall may prompt to open the port.

You can now launch your favorite GDB front end and connect it to localhost:1000.

Programs built with Ndless require Ndless v1.7 to be intalled on the OS image.

With GDB command line interface

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.elf>
target remote localhost:1000
break main

Running the file command before the target command is important for address relocation.

You can the run the program from Ncubate, which will break on the main() function, and then use s (step), n (next) and other GDB commands.