I will try and explain the setup here :-
1. You need a gdbserver running on the target. This is target specific. E.g if you are compiling for a ARM target , make sure you have a gdbserver compiled for ARM.
2. A gdb debugger running on the host. This is where many of the tutorials on the net are not clear. The gdb running on the host has to debug programs built for the target architecture but still run on the host machine ( Just like gcc cross compiler).
3. The program to be debugged has to be the same --both on the target and the host. However you can run a stripped version of the program on the host. Apart from this they should be exactly the same.
steps:-
Get the iptables mess out of the way
#iptables -P INPUT ACCEPT
#iptables -P OUTPUT ACCEPT
#iptables -P FORWARD ACCEPT
#iptables --flush
on the board start the gdbserver
#gdbserver :1234 debug-program
here it means thats gdbserver would listen for connection on port 1234. The program which is to be debugged is "debug-program". The above command is same as using :-
#gdbserver localhost:1234 debug-program
or even
#gdbserver 127.0.0.1:1234 debug-program
on the host start the gdb
#gdb debug-program
At the gdb prompt type the following
(gdb) target remote 192.168.1.1:1234
This instructs the gdb to connect to gdbserver on the machine with IP 192.168.1.1 on port 1234.
No comments:
Post a Comment