#!/bin/bash
ex=(
    -ex "run main"
    -ex "set logging overwrite off" 
    -ex "set logging file /home/pcscale/scale/log/gdb.log" 
    -ex "set logging on" 
    -ex "set pagination off"
    -ex "handle SIG33 pass nostop noprint"
    -ex "echo \n\n------------------- LOG START ---------------------------\n"
    -ex "shell echo $(date +'%x %T') >> /home/pcscale/scale/log/gdb.log"
    -ex "echo ---------------------------------------------------------\n"
    -ex "echo backtrace:\n"
    -ex "backtrace full"
    -ex "echo \n\nregisters:\n"
    -ex "info registers"
    -ex "echo \n\ncurrent instructions:\n"
    -ex "x/16i \$pc"
    -ex "echo \n\nthreads backtrace:\n"
    -ex "thread apply all backtrace"
    -ex "set logging off"
    -ex "quit"
)
# echo 0 | gdb -batch-silent "${ex[@]}" --args "$@"
cd /usr/bin
gdb pcscale -batch-silent "${ex[@]}"




