diff --git a/cmake_targets/autotests/tools/run_gdb b/cmake_targets/autotests/tools/run_gdb new file mode 100755 index 0000000000000000000000000000000000000000..aeb46bc3989af563f1a291750d4742fdb3980eec --- /dev/null +++ b/cmake_targets/autotests/tools/run_gdb @@ -0,0 +1,52 @@ +#!/bin/bash + +#arg0 -> Name of executable +#args[1...N] -> arguments to be passed to executable +if [ -z "$OPENAIR_DIR" ] +then + echo "OPENAIR_DIR environment not set. Exiting.." + exit +fi + +source $OPENAIR_DIR/cmake_targets/tools/build_helper + +args=($*) +exec_name=${args[0]} +exe_args=(${args[@]:1}) +gdb_file=$OPENAIR_DIR/targets/bin/gdb_file +gdb_log=$OPENAIR_DIR/targets/bin/gdb_log.bt + +echo "args = ${args[@]}" +echo "exec_name = $exec_name" +echo "exe_args = ${exe_args[@]}" +echo "gdb log file = $gdb_log" + +$SUDO rm -fr $gdb_file $gdb_log +$SUDO touch $gdb_file $gdb_log +$SUDO chmod 777 $gdb_file $gdb_log + +$SUDO echo "file $exec_name" >> $gdb_file +$SUDO echo "set args ${exe_args[@]}" >> $gdb_file +$SUDO echo "run" >> $gdb_file +$SUDO echo "set logging overwrite on" >> $gdb_file +$SUDO echo "set logging file $gdb_log" >> $gdb_file +$SUDO echo "set logging on" >> $gdb_file +$SUDO echo "set pagination off" >> $gdb_file +$SUDO echo "handle SIG33 pass nostop noprint" >> $gdb_file +$SUDO echo "echo backtrace:\n" >> $gdb_file +$SUDO echo "backtrace full" >> $gdb_file +$SUDO echo "echo \n\nregisters:\n" >> $gdb_file +$SUDO echo "info registers" >> $gdb_file +$SUDO echo "echo \n\ncurrent instructions:\n" >> $gdb_file +$SUDO echo "x/16i \$pc" >> $gdb_file +$SUDO echo "echo \n\nthreads backtrace:\n" >> $gdb_file +$SUDO echo "thread apply all backtrace" >> $gdb_file +$SUDO echo "set logging off" >> $gdb_file +$SUDO echo "quit" >> $gdb_file + +echo "Contents of gdb_file...start" +$SUDO cat $gdb_file +echo "Contents of gdb_file...finish" + +$SUDO gdb -n -x $gdb_file 2>&1 +