summaryrefslogtreecommitdiffstats
path: root/sim-scripts/gdb-sim.in
blob: 94a3aa4c8bd8e443c15f2acdd78ce41a30c49f2f (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#! /usr/bin/eval bash
#
#  Framework script tailored for the @CPU@/@BSP@
#
#  NOTE: If the does not have the name of a specific CPU/BSP pair, then
#        this is the source file.  If it does have specific CPU/BSP pair,
#        then this is generated output and should NOT be edited.

trap "test_exit 1" 1 2 3 13 14 15

inGDBScript=yes

progname=${0##*/}        # fast basename hack for ksh, bash

USAGE=\
"usage: $progname [ -opts ] test
	-i	   -- interactive (default=no time limit)

System V IPC and Coverage are not supported by all BSPs or simulators.
"

for v in 4.11 4.10 4.9 4.8 4.7 ""
do
  type @CPU_TARGET@-rtems${v}-gdb >/dev/null 2>&1
  if [ $? -eq 0 ] ; then
    GDB=@CPU_TARGET@-rtems${v}-gdb
    break
  fi
done

if [ X${GDB} = X ] ; then
  echo "Unable to find a GDB for @CPU_TARGET@ along your PATH"
  exit 1
fi

test_exit()
{
  exit_code=$1
  rm -f @BSP@-cmds
  exit $exit_code
}

#   log an error to stderr
prerr()
{
    echo "$*" >&2
}

fatal() {
    [ "$1" ] && prerr $*
    prerr "$USAGE"
    exit 1
}

warn() {
    [ "$1" ] && prerr $*
}

check_status()
{
  if [ $1 -ne 0 ] ; then
    shift 
    echo "FAILED: " "$*" >&2
    test_exit 1
  fi
}

type ${runBSP}
check_status $? "Path appears to be broken (cannot find ${runBSP})"

if [ $# -eq 0 ] ; then
  echo "No arguments .. no executable specified"
  exit 1 
fi

use_sysv_ipc="no"
doTrace="no"
while getopts s OPT
do
 case "$OPT" in
   s) use_sysv_ipc="yes";;
   *) ;;
 esac
done

shiftcount=`expr $OPTIND - 1`
shift $shiftcount

args=$*

### Set BSP defaults.  If BSP does not have default, it will override
bspGeneratesGDBCommands="no"
bspGeneratesDeviceTree="no"
bspSupportsLCD="no"
bspSupportsTCPIP="no"
bspDoTrace="no"

###################################################################
###################################################################
###################################################################
##INSERT BSP SUPPORT HERE
###################################################################
###################################################################
###################################################################

## Some BSPs must generate device trees to provide to the simulator
if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
  TREE_FILE=@BSP@_tree.${LOGNAME}
  bspGenerateDeviceTree ${baseToRun} >${TREE_FILE}
fi

### generate bsp specific load command
if [ ${bspGeneratesGDBCommands} = "no" ] ; then
  cat <<EOF
tar sim 
load
EOF
else
  bspGenerateGDBCommands 
fi >@BSP@-cmds

###  Add CPU specific commands
case @CPU_TARGET@ in
  *powerpc*) echo  "b C_exception_handler" ;;
  *)       ;;
esac >>@BSP@-cmds

###  Add generic commands which break on known bad places
cat >>@BSP@-cmds <<EOF
b _Terminate
condition 1 (the_source != RTEMS_FATAL_SOURCE_EXIT) || (the_error != 0)
b rtems_fatal_error_occurred
b __assert
printf "Use run to start the RTEMS application\\n"
EOF

### Now source the rtems gdb
vfile=`dirname $0`/rtems-gdb-macros-${v}
if [ ! -r ${vfile} ] ; then
  echo WARNING!!! RTEMS GDB Macro files not found
else
  echo "source ${vfile}" >>@BSP@-cmds
fi

${GDB} --command=@BSP@-cmds $*

if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
  rm -f @BSP@_tree.${LOGNAME}
fi
test_exit $?