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 !
Attachments (3)
-
gdbserver (1.2 MB) - added by 14 years ago.
8eb43afdb81c5486600af655c349f26e gdbserver
-
gdbreplay (571.6 KB) - added by 14 years ago.
ea1aa320e52773431cde4e4d4ad09131 gdbreplay
-
Makefile (414 bytes) - added by 14 years ago.
gdbtst sample Makefile
Download all attachments as: .zip