1## @file
2# GDB startup script
3#
4# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
5#
6# This program and the accompanying materials
7# are licensed and made available under the terms and conditions of the BSD License
8# which accompanies this distribution. The full text of the license may be found at
9# http://opensource.org/licenses/bsd-license.php
10#
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13#
14##
15
16#
17# Gdb will set $_exitcode when the program exits.  Pre-init it to an unlikely
18# return value.
19#
20set $_exitcode = 42
21
22#
23# Gdb will call hook-stop on each break.  Check to see if $_exitcode was
24# changed from the value we pre-initialized it to.  If so, the program
25# had exited, so gdb should now quit.
26#
27define hook-stop
28  if $_exitcode != 42
29    quit
30  else
31    source Host.gdb
32  end
33end
34
35#
36# We keep track of the number of symbol files we have loaded via gdb
37# scripts in the $SymbolFilesAdded variable
38#
39set $SymbolFileChangesCount = 0
40
41#
42# This macro adds a symbols file for gdb
43#
44# @param  $arg0 - Symbol file changes number
45# @param  $arg1 - Symbol file name
46# @param  $arg2 - Image address
47#
48define AddFirmwareSymbolFile
49  if $SymbolFileChangesCount < $arg0
50    add-symbol-file $arg1 $arg2
51    set $SymbolFileChangesCount = $arg0
52  end
53end
54
55#
56# This macro removes a symbols file for gdb
57#
58# @param  $arg0 - Symbol file changes number
59# @param  $arg1 - Symbol file name
60#
61define RemoveFirmwareSymbolFile
62  if $SymbolFileChangesCount < $arg0
63    #
64    # Currently there is not a method to remove a single symbol file
65    #
66    set $SymbolFileChangesCount = $arg0
67  end
68end
69
70if gInXcode == 1
71  # in Xcode the program is already runing. Issuing a run command
72  # will cause a fatal debugger error. The break point sciprt that
73  # is used to source this script sets gInCode to 1.
74else
75  #
76  # Start the program running
77  #
78  run
79end
80