Permalink
Browse files

Test to debug user-space programs in ARM QEMU guest from host with gd…

…bserver.
  • Loading branch information...
1 parent a4700bd commit 5e7de526d2e086d509bc080fdf6789e4b5f52c55 @balau committed Oct 2, 2011
Showing with 36 additions and 0 deletions.
  1. +29 −0 qemu-debug/Makefile
  2. +7 −0 qemu-debug/rcS
View
29 qemu-debug/Makefile
@@ -0,0 +1,29 @@
+KERNEL = linux-2.6.35/arch/arm/boot/zImage
+BUSYBOX_INSTALL_DIR = busybox-1.17.1/_install
+LIBC_DIR = ~/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc
+HELLO = hello-2.6/src/hello
+
+.PHONY: run all debug
+
+all: $(KERNEL) rootfs.img.gz
+
+run: $(KERNEL) rootfs.img.gz
+ @echo Run inside guest prompt:
+ @echo gdbserver --multi 10.0.2.15:1234
+ qemu-system-arm -M versatilepb -kernel $(KERNEL) -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/sbin/init" -redir tcp:1234::1234
+
+debug:
+ ddd --debugger "arm-none-linux-gnueabi-gdb -x hello-remote.gdb"
+
+rootfs.img.gz: rcS $(HELLO)
+ cd $(BUSYBOX_INSTALL_DIR) && mkdir -p dev lib proc sys etc/init.d
+ cp $(LIBC_DIR)/lib/ld-linux.so.3 $(BUSYBOX_INSTALL_DIR)/lib/
+ cp $(LIBC_DIR)/lib/libm.so.6 $(BUSYBOX_INSTALL_DIR)/lib/
+ cp $(LIBC_DIR)/lib/libc.so.6 $(BUSYBOX_INSTALL_DIR)/lib/
+ cp $(LIBC_DIR)/lib/libdl.so.2 $(BUSYBOX_INSTALL_DIR)/lib/
+ cp $(LIBC_DIR)/lib/libgcc_s.so.1 $(BUSYBOX_INSTALL_DIR)/lib/
+ cp $(LIBC_DIR)/usr/bin/gdbserver $(BUSYBOX_INSTALL_DIR)/usr/bin/
+ cp $(HELLO) $(BUSYBOX_INSTALL_DIR)/usr/bin/
+ cp rcS $(BUSYBOX_INSTALL_DIR)/etc/init.d/
+ cd $(BUSYBOX_INSTALL_DIR);\
+ find . | cpio -o --format=newc | gzip > ../../rootfs.img.gz
View
7 qemu-debug/rcS
@@ -0,0 +1,7 @@
+#!/bin/sh
+mount -t proc none /proc
+mount -t sysfs none /sys
+/sbin/mdev -s
+ifconfig lo up
+ifconfig eth0 10.0.2.15 netmask 255.255.255.0
+route add default gw 10.0.2.1

0 comments on commit 5e7de52

Please sign in to comment.