#!/usr/bin/env bash . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common" after= before= lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\ " kgdb=false docontinue=true while getopts A:a:b:CgkL:n:X OPT; do case "$OPT" in A) after="$OPTARG" ;; a) common_arch="$OPTARG" ;; b) before="$OPTARG" ;; C) # No Continue. docontinue=false ;; g) common_gem5=true ;; k) kgdb=true ;; L) common_linux_variant="$OPTARG" ;; n) common_run_id="$OPTARG" ;; X) lx_symbols= ;; ?) exit 2 ;; esac done shift "$(($OPTIND - 1))" if [ "$#" -gt 0 ]; then brk="-ex 'break ${1}' \\ " shift else brk= fi common_setup gdb="${common_host_dir}/usr/bin/${common_arch}-linux-gdb \\ ${before}" if "$kgdb"; then cmd="\ ${gdb} \ -q \\ -ex 'add-auto-load-safe-path $(pwd)' \\ -ex 'file vmlinux' \\ -ex 'target remote localhost:${common_gdb_port}' \\ " else # ## lx-symbols # # ### lx-symbols after continue # # lx symbols must be run after continue. # # running it immediately after the connect on the bootloader leads to failure, # likely because kernel structure on which it depends are not yet available. # # With this setup, continue runs, and lx-symbols only runs when a break happens, # either by hitting the breakpoint, or by entering Ctrl + C. # # Sure, if the user sets a break on a raw address of the bootloader, # problems will still arise, but let's think about that some other time. # # ### lx-symbols autoload # # The lx-symbols commands gets loaded through the file vmlinux-gdb.py # which gets put on the kernel build root when python debugging scripts are enabled. cmd="\ ${gdb} \ -q \\ -ex 'add-auto-load-safe-path $(pwd)' \\ -ex 'file vmlinux' \\ -ex 'target remote localhost:${common_gdb_port}' \\ ${brk} \ " fi if "$docontinue"; then echo asdf cmd="${cmd} \ -ex continue \\ ${lx_symbols} \ " fi "${common_root_dir}/eeval" "cd '${common_linux_variant_dir}' && \\ $cmd $after" "${common_run_dir}/rungdb.sh"