X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/28c176b668c841a3b7fb093faccf0efa39257603..refs/heads/eme/usr-header-gen:/lunaix-os/live_debug.sh?ds=sidebyside diff --git a/lunaix-os/live_debug.sh b/lunaix-os/live_debug.sh index e10f71c..39f9841 100755 --- a/lunaix-os/live_debug.sh +++ b/lunaix-os/live_debug.sh @@ -4,14 +4,47 @@ hmp_port=45454 gdb_port=1234 default_cmd="console=/dev/ttyS0" -make CMDLINE=${default_cmd} ARCH=${ARCH} MODE=debug image -j5 || exit -1 +if [[ -z "${ARCH}" ]]; then + echo "error: please specify ARCH=" + exit 1 +fi -./scripts/qemu.py \ - scripts/qemus/qemu_x86_dev.json \ - --qemu-dir "${QEMU_DIR}" \ - -v KIMG=build/lunaix.iso \ - -v QMPORT=${hmp_port} \ - -v GDB_PORT=${gdb_port} \ - -v ARCH=${ARCH} & +make ARCH="${ARCH}" MODE="${MODE:-debug}" all -j"$(nproc)" || exit 1 -QMPORT=${hmp_port} gdb build/bin/kernel.bin -ex "target remote localhost:${gdb_port}" \ No newline at end of file +launch_script=._launch_debug.sh + +cat << EOF > ${launch_script} && chmod +x ${launch_script} +#!/usr/bin/env sh +./scripts/qemu.py \\ + scripts/qemus/qemu_x86_dev.json \\ + --qemu-dir "${QEMU_DIR}" \\ + -v QMPORT=${hmp_port} \\ + -v GDB_PORT=${gdb_port} \\ + -v ROOTFS=lunaix_rootfs.ext2 \\ + -v ARCH=${ARCH} \\ + -v KBIN=build/bin/kernel.bin \\ + -v "KCMD=${default_cmd} rootfs=/dev/block/sda init=/bin/init" \\ + -- \\ + -nographic || exit 1 & + +AUTOQEMU_DAEMON=\$! +echo "autoqemu daemon launched (pid=\$AUTOQEMU_DAEMON)" + +gdb-multiarch \\ + build/bin/kernel.bin \\ + -ex "target remote localhost:${gdb_port}" + +if ps -p \$AUTOQEMU_DAEMON > /dev/null +then + kill -9 \$AUTOQEMU_DAEMON +fi +EOF + +echo "debugger launch script written to: ${launch_script}" + +if [[ -z "${TMUX}" ]]; then + echo "for best effect, use tmux" + GDB_NOSPLIT=1 "./${launch_script}" +else + tmux new-window -a -n "[lunaix-debug]" -e "QMPORT=${hmp_port}" "./${launch_script}" +fi