run_gdb 1.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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
38
39
40
41
$SUDO echo "echo \n\nVariables:\n"            >> $gdb_file
$SUDO echo "info variables"                   >> $gdb_file
$SUDO echo "echo \n\nlocals:\n"               >> $gdb_file
$SUDO echo "info locals"                      >> $gdb_file
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$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