NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Debugging remotely on DaVinci using gdb
An alternative walkthrough more specific to MVL 5.0 debugging is available at Debugging a Linux Application with MontaVista 5.0
Remote debugging using GDB
This topic discusses how to debug Linux applications remotely on your target using GDB (the GNU Debugger). This procedure applies to user space applications. If you want to debug the Linux kernel you will want to use KGDB, BDI2000/BDI3000, Lauterbach or Ronetix_PEEDI.
We will discuss how to debug the decode demo included in the DVEVM, but the instructions apply to any Linux application.
The application you want to debug should have debugging symbols added using the -g flag, and preferably be compiled without optimization.
In our case this means we need the debug version of the decode demo. This executable is named decoded and is available from /path/to/DVEVM/demos/decode/debug/decoded.
On your target execute /sbin/ifconfig to find out the target ip address (assuming 192.168.1.101 going forward). Now execute ./loadmodules.sh as always to insert necessary kernel modules (CMEM on ARM Linux-based devices, and DSP Link for heterogeneous devices). Then execute:
gdbserver localhost:4567 ./decoded -v data/videos/davincieffect_ntsc.m2v
This will launch and halt the decode demo on the target. On your Linux host execute:
and enter the following commands:
target remote 192.168.1.101:4567 b main cont
GDB should now be halted in the
main() function of the decode demo.
Executing one or more of these commands every time can be tedious. Instead, put the commands you execute every time (one per line) in a file somewhere on your host file system and name it something like gdbstart.txt. To execute these commands when gdb is started execute arm_v5t_le-gdb -x gdbstart.txt. Alternatively if you are always working on one project you can put the commands in your .gdbinit file in your home directory (this way they will always be executed when you start gdb).
Note! The Montavista Linux target file system comes with a gdb compiled for ARM which you can execute locally on the target using gdb. This can sometimes be simpler than remote debugging.
Commonly used GDB commands
- help or h (optionally followed by command) brings up help on a topic.
- list or l (with optionally a function or file:line number) lists the source at a certain source line.
- next or n is "next source line" (or "step over" in CCS terms).
- step or s is "step into" function.
- si is "step exactly one instruction".
- print [variable] or p [variable] displays a variable.
- breakpoint [function] or b [function] sets a software breakpoint in a function. You can of course set breakpoints on line numbers in arbitrary files too (use help to get more info).
- info breakpoints lists all breakpoints with some information.
- delete [breakpoint number] to remove a breakpoint.
- disable [breakpoint number] to disable a breakpoint.
- x [address] to show what is at a specific address (use x/t for binary, x/x for hex and x/d for decimal display).
- backtrace shows the call stack.
- disas (with an optional argument) disassembles your application.
- info registers shows the contents of your ARM registers.
- display &[variable or function] shows the address where a variable is stored in memory every time the application stops.
- define [macroname] will allow you to enter commands for a macro (one command per line and end with 'end').
- detach will detach gdb from the remote server and reset the target.
You can display mixed C/ASM by executing display/i $pc. Then step using si to get a view of each source line as both C and ASM.
Note! If you press return without giving a command in GDB you will execute the last command you gave once again. This is particularly useful for single stepping.
Gdb is complete with a command line history, tab completion of variable names and commands, and scripting / aliasing of commands.
Wrapping Remote GDB with Eclipse
Eclipse provides an nice GUI that can sit on top of GDB. To configure Eclipse to remotely debug over gdb you need to do the following
- Download Eclipse from Eclipse Downloads page. Make sure that you download for your host OS. The C/C++ version is the one we want.
- Install Eclipse by following the procedures that are provided by their documentation
- To setup remote debug, you need to create and configure a project.
- In project configuration, there is a debug tab. Choose that tab
- Choose gdbserver Debugger as the Debugger option, and browse and choose the path to arm_v5t_le-gdb
- Under the connections sub-tab, choose TCP as the connection Type and configure the IP address and Port
Now you should be ready to debug any target application using the Eclipse GUI.