source: rtems-testing/sim-scripts/gdb-sim.in @ e997f7a

4.11
Last change on this file since e997f7a was ee6207c, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 7, 2014 at 11:35:23 PM

gdb-sim.in: Symbol is now _Terminate

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#! /bin/bash
2#
3#  Framework script tailored for the @CPU@/@BSP@
4#
5#  NOTE: If the does not have the name of a specific CPU/BSP pair, then
6#        this is the source file.  If it does have specific CPU/BSP pair,
7#        then this is generated output and should NOT be edited.
8
9trap "test_exit 1" 1 2 3 13 14 15
10
11inGDBScript=yes
12
13progname=${0##*/}        # fast basename hack for ksh, bash
14
15USAGE=\
16"usage: $progname [ -opts ] test
17        -i         -- interactive (default=no time limit)
18
19System V IPC and Coverage are not supported by all BSPs or simulators.
20"
21
22for v in 4.11 4.10 4.9 4.8 4.7 ""
23do
24  type @CPU_TARGET@-rtems${v}-gdb >/dev/null 2>&1
25  if [ $? -eq 0 ] ; then
26    GDB=@CPU_TARGET@-rtems${v}-gdb
27    break
28  fi
29done
30
31if [ X${GDB} = X ] ; then
32  echo "Unable to find a GDB for @CPU_TARGET@ along your PATH"
33  exit 1
34fi
35
36test_exit()
37{
38  exit_code=$1
39  rm -f @BSP@-cmds
40  exit $exit_code
41}
42
43#   log an error to stderr
44prerr()
45{
46    echo "$*" >&2
47}
48
49fatal() {
50    [ "$1" ] && prerr $*
51    prerr "$USAGE"
52    exit 1
53}
54
55warn() {
56    [ "$1" ] && prerr $*
57}
58
59check_status()
60{
61  if [ $1 -ne 0 ] ; then
62    shift
63    echo "FAILED: " "$*" >&2
64    test_exit 1
65  fi
66}
67
68type ${runBSP}
69check_status $? "Path appears to be broken (cannot find ${runBSP})"
70
71if [ $# -eq 0 ] ; then
72  echo "No arguments .. no executable specified"
73  exit 1
74fi
75
76use_sysv_ipc="no"
77doTrace="no"
78while getopts s OPT
79do
80 case "$OPT" in
81   s) use_sysv_ipc="yes";;
82   *) ;;
83 esac
84done
85
86shiftcount=`expr $OPTIND - 1`
87shift $shiftcount
88
89args=$*
90
91### Set BSP defaults.  If BSP does not have default, it will override
92bspGeneratesGDBCommands="no"
93bspGeneratesDeviceTree="no"
94bspSupportsLCD="no"
95bspSupportsTCPIP="no"
96bspDoTrace="no"
97
98###################################################################
99###################################################################
100###################################################################
101##INSERT BSP SUPPORT HERE
102###################################################################
103###################################################################
104###################################################################
105
106## Some BSPs must generate device trees to provide to the simulator
107if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
108  TREE_FILE=@BSP@_tree.${LOGNAME}
109  bspGenerateDeviceTree ${baseToRun} >${TREE_FILE}
110fi
111
112### generate bsp specific load command
113if [ ${bspGeneratesGDBCommands} = "no" ] ; then
114  cat <<EOF
115tar sim
116load
117EOF
118else
119  bspGenerateGDBCommands
120fi >@BSP@-cmds
121
122###  Add CPU specific commands
123case @CPU_TARGET@ in
124  *powerpc*) echo  "b C_exception_handler" ;;
125  *)       ;;
126esac >>@BSP@-cmds
127
128###  Add generic commands which break on known bad places
129cat >>@BSP@-cmds <<EOF
130b _Terminate
131condition 1 (the_source != RTEMS_FATAL_SOURCE_EXIT) || (the_error != 0)
132b rtems_fatal_error_occurred
133b __assert
134printf "Use run to start the RTEMS application\\n"
135EOF
136
137### Now source the rtems gdb
138vfile=`dirname $0`/rtems-gdb-macros-${v}
139if [ ! -r ${vfile} ] ; then
140  echo WARNING!!! RTEMS GDB Macro files not found
141else
142  echo "source ${vfile}" >>@BSP@-cmds
143fi
144
145${GDB} --command=@BSP@-cmds $*
146
147if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
148  rm -f @BSP@_tree.${LOGNAME}
149fi
150test_exit $?
Note: See TracBrowser for help on using the repository browser.