GDB is a debugger that allows you to see what is going on `inside’ another program while it executes — or what another program was doing at the moment it crashed.
Since version r848 Ndless and the Ndless SDK feature compatibility with GDB through:
- The GDB remote stub of Goplat’s nspire_emu TI-Nspire emulator distributed with the SDK, compatible with GDB’s target remote command
- The scite-debug plugin in the NdlessEditor slightly adapted for the TI-Nspire
- Special support in Ndless, installed on the emulator
To run a debug session, make sure you are using the latest SDK. First open the NdlessEditor.
If you want to change the default TCP port 3333 used during debugging, choose Options > Open Global Options File, change the property ndless.gdb.port and save the file.
Run the emulator with Tools > TI-Nspire emulator. The emulator must have been first set up. Install the latest version of Ndless on it.
Open the Makefile of the Ndless-based ARM, C or C++ program you want to debug. We will use _samples/helloworld-cpp as an example.
Set the variable DEBUG to TRUE at the beginning of the file.
Fully rebuild your program with Tools > Clean Build. This will create a *.gdb file used by the debugger. After the debug session don’t forget to reset the DEBUG variable to FALSE before releasing your program as this will turn some optimizations off.
Then send your program to the emulator with Tools > Transfer the program.
Set a breakpoint in the source code of program with Tools > Breakpoint or F9. We will set it at the beginning of the main() function in main.cpp.
Connect GDB to the emulator with Tools > Run. Run the program in the emulator from the TI-Nspire OS document screen. The breakpoint should be hit and the current line shown in the editor.
You may now use the different commands provided by scite-debug available for debugging in the Tools menu, such as Step, Step Over (a function call), Run (to continue the execution) and Inspect (or mouse hover) to view the content of a variable. You may also set other breakpoints. For advance debugging, you may also type in some of the GDB commands in the lower pane once a breakpoint is hit.
Don’t forget to disconnect the debugger with Tools > Kill, else you will get arm-none-eabi-gdb processes leaking. You can safely kill them from Windows task manager if forgot this step before closing the editor.
scite-debug is a basic GDB front-end, and you may want to have a look into more advanced front-ends such Eclipse CDT. Note that this requires additional set up steps to remote connect to the emulator by specifying the debugger (arm-none-eabi-gdb in yagarto/bin), host (localhost) and port (the default is 3333).