I don't have the right filesystem in front of me to debug, but this recipe should work for debugging PID 1 with gdb (assuming you have a platform already set up with a populated root filesystem etc.):
Connect a keyboard and monitor before booting.
Boot with rdinit=/bin/sh console=<appropriate serial console device>
mkdir /proc /sys /mnt
mount -ntproc proc /proc
mount -ntsysfs sysfs /sys
mknod -m0666 /dev/null c 1 3
udevd --daemon &
# wait a moment
udevadm trigger
# wait a moment
ps
kill <pid of parent udevd process>
mount -oro -text4 /dev/mmcblk0p2 /mnt
LD_LIBRARY_PATH=/mnt/lib:/mnt/usr/lib:/lib; export LD_LIBRARY_PATH
for x in 9 10 11 12; do /mnt/usr/bin/setsid /mnt/bin/bash </dev/tty$x >/dev/tty$x 2>&1 & done
# now you have some usable ttys
# on one of them, type:
/mnt/usr/bin/gdb
attach 1
tcatch exec
continue
# one the console, type
exec /init
# /bin/sh should get exec'd as PID 1, and gdb will stop it
# you'll probably have to load the relevant debug symbols manually etc.
I don't have the right filesystem in front of me to debug, but this recipe should work for debugging PID 1 with gdb (assuming you have a platform already set up with a populated root filesystem etc.):
Connect a keyboard and monitor before booting.
Boot with rdinit=/bin/sh console= <appropriate serial console device>
mkdir /proc /sys /mnt PATH=/mnt/ lib:/mnt/ usr/lib: /lib; export LD_LIBRARY_PATH
mount -ntproc proc /proc
mount -ntsysfs sysfs /sys
mknod -m0666 /dev/null c 1 3
udevd --daemon &
# wait a moment
udevadm trigger
# wait a moment
ps
kill <pid of parent udevd process>
mount -oro -text4 /dev/mmcblk0p2 /mnt
LD_LIBRARY_
for x in 9 10 11 12; do /mnt/usr/bin/setsid /mnt/bin/bash </dev/tty$x >/dev/tty$x 2>&1 & done
# now you have some usable ttys
# on one of them, type:
/mnt/usr/bin/gdb
attach 1
tcatch exec
continue
# one the console, type
exec /init
# /bin/sh should get exec'd as PID 1, and gdb will stop it
# you'll probably have to load the relevant debug symbols manually etc.