Skip to content
Snippets Groups Projects
qrun.sh.in 1.75 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tobias Klaus's avatar
    Tobias Klaus committed
    #!/bin/bash
    # a shell script to run in the Qemu PC emulator an eCos
    # application that's been built with "Grub" startup mode.
    #
    # It runs Qemu with a 
    # single serial port connected to a telnet
    # server socket.
    #
    # An instance of the "xterm" X11 terminal emulator is started with
    # telnet command to connect to that virtual serial port on port
    #
    # When $2 is 'ddd' a debugger window is opened accordingly
    
    PORTFILENAME=/tmp/$USER.portnum
    @STARTUP_SCRIPTS@/findport.pl > $PORTFILENAME
    PORTNUM=`head -n 1 /tmp/$USER.portnum`
    SERIALPORTNUM=`tail -n 1 /tmp/$USER.portnum`
    GDB_BIN=gdb
    GDB_TUI_BIN=gdbtui
    TERMINAL=urxvt
    
    BINARY="$1"
    echo $PWD
    echo "target remote :$PORTNUM" > .gdbinit
    echo "br cyg_user_start" >> .gdbinit
    
    if [[ $1 == "ddd" ]] || [[ $1 == "gdb" ]] || [[ $1 == "cgdb" ]]; then
      DEBUG="-s -S -gdb tcp::$PORTNUM"
    fi
    
    XTERMEXE="telnet localhost $SERIALPORTNUM"
    
    # start a terminal that will telnet to the virtual machine's serial port
    (sleep 0.5; $TERMINAL -geometry 120x80 -title "eCos Serial 0" -name "eCos Serial 0" -e $XTERMEXE )&
    
    sleep 0.5
    # start ddd Debugger
    if [[ "$2" == "ddd" ]]; then
    	(sleep 0.5;	$TERMINAL -e ddd --command .gdbinit --gdb --debugger $GDB_BIN   $BINARY ) &
    fi
    
    # start GDB in xterm terminal
    if [[ "$2" == "gdb" ]]; then
    	(sleep 0.5; $TERMINAL -e $GDB_BIN  $BINARY ) &
    fi
    
    # start GDBTUI in xterm terminal
    if [[ "$2" == "gdbtui" ]]; then
    	(sleep 0.5; $TERMINAL -e $GDB_TUI_BIN  $BINARY ) &
    fi
    
    
    # start cgdb in xterm terminal
    if [[ "$2" == "cgdb" ]]; then
    	(sleep 0.5; $TERMINAL -e cgdb  $BINARY ) &
    fi
    
    
    # MACHINE=$(gcc -dumpmachine|cut -f1 -d-)
    # if [[ $MACHINE == "x86_64" ]]; then
    #   BITS="64"
    # else
    #   BITS="32"
    # fi
    
    qemu-system-i386 -machine pc,accel=tcg \
      $DEBUG \
      -kernel $BINARY \
      -serial telnet:localhost:$SERIALPORTNUM,server,nowait