plesiv
12/22/2014 - 8:12 PM

Remote debugging of embedded system with GDB/GDBSERVER over the network

Remote debugging of embedded system with GDB/GDBSERVER over the network

Debugging embedded system over ethernet with GDB (and gdbserver)

Prerequisite: host and target should be connected over network.


I - on target
	* needed:
		- compiled program that needs to be debugged (doesn't need
		  debugging symbols in it),
		- gdbserver executable
	* procedure:
		0) determine the IP address ("inet addr") of the target with
			bash> ifconfig
			(let's assume target's IP is 192.168.0.80)
		1) go to directory where program is located,
		2) start gdbserver:
			bash> gdbserver host:2345 program

	
II - on host
	* needed:
		- compiled program that needs to be debugged (has to have
		  debugging symbols in it!),
		- gdb executable - must correspond to gdbserver executable on
		  the target (from the same gdb distribution)
		- whole filesystem from the target (libraries for running
		  program are needed on correct locations)
	* procedure:
		1) go to directory where program is located,
		2) start gdb as root (lets assume corresponding gdb program is
		   arm-xilinx-linux-gdb):
			bash# arm-xilinx-linux-gdb program
		3) connect to the remote gdbserver with:
			gdb# target remote 192.168.0.80:2345
		4) change sysroot to the location of target's filesystem (we
		   assume it's in "~/target-fs") on the host:
			gdb# set sysroot /home/zplesivcak/target-fs
		5) set gdb path to shared libraries (e.g.):
			gdb# set solib-search-path /opt/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/2011.09-50/arm-xilinx-linux-gnueabi/libc/lib:/home/zplesivcak/target-fs/lib:/home/zplesivcak/target-fs/usr/lib:/home/zplesivcak/target-fs/mnt/qt/lib
		[6) optional] set breakpoints etc.:
			gdb# b dfb_surface_pools_negotiate
			gdb# b dfb_surface_pools_allocate
		7) start debugging of the program ("c" is short for
		   "continue"):
			gdb# c