wiki:gdb_remote

GDB remote debugging

gdbserver binary

I compiled the attached gdbserver binary using the arm-linux-gnueabi toolchain using the -static link flag.

It can be used without any extra software on the arm device.

Copy it to the phone using:

adb push gdbserver /data/local

Starting gdbserver

Start debugging your remote executable using:

/data/local/gdbserver :3050 ./gdbtst

Assuming the the file gdbtest is the executable that you want to debug and the executable is in your current directory

Redirect a port

On your local PC use:

adb forward tcp:1234 tcp:3050

to forward the local port 1234 to the remote port 3050

Debug

Start the debugger using:

arm-linux-gnueabi-gdb ./gdbtst

And the in gdb use

target remote :1234

to start the remote debug session. Then do something like:

break main
continue

to step through the program.

Using Eclipse

The goal of this exercise is to use the Eclipse IDE for remote debugging.

Create a normal Standard Makefile C Project in Eclipse, create a Makefile for the arm-linux-gnueabi toolchain(attached there is a sample for the program gdbtst) and compile the project.

Create a gdb command file and put it somewhere in the home directory. The content of mine is:

set remotetimeout 0
set solib-absolute-prefix /usr/arm-linux-gnueabi/lib/

Debug Configuration

Create a Debug Configuration using the following steps:

  • From the Menu select: Run -> Debug Configurations...
  • In the Dialog press the "New lauch configuration"

Main-Tab

In the Main-Tab enter the following info:

  • project
  • C/C++ Application (from the file system using the Browse Button)

Debugger-Tab

In the Debugger-Tab enter the following info (Sub Tabs are indicated by <Tabname> - <Field>:

  • Debugger = gdbserver Debugger
  • Main - GDB Debugger: /usr/bin/arm-linux-gnueabi-gdb
  • Main - GDB Command file: <path to the command file you created>
  • Shared Libraries - Load shared library symbols automatically: Check
  • Connection - Type: TCP
  • Connection - Host name or IP address: localhost
  • Connection - Port number: 1234

Save you config and start debugging !

Last modified 10 years ago Last modified on 04/17/11 20:37:57

Attachments (3)

Download all attachments as: .zip