1# Copyright 2004-2013 Free Software Foundation, Inc.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15#
16# This file is part of the gdb testsuite.
17
18# Test rs6000 prologue analyzer.
19
20
21if ![istarget "powerpc-*-aix*"] then {
22    verbose "Skipping powerpc-aix prologue tests."
23    return
24}
25
26set testfile "powerpc-aix-prologue"
27set srcfile ${testfile}.c
28set binfile ${objdir}/${subdir}/${testfile}
29if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
30    unsupported "Testcase compile failed."
31    return -1
32}
33
34gdb_exit
35gdb_start
36gdb_reinitialize_dir $srcdir/$subdir
37gdb_load ${binfile}
38
39# Insert a breakpoint in FUNCTION and verifies that the breakpoint was
40# inserted at the expected location.  EXPECTED_LOCATION should be an
41# offset relative to the function start address.
42proc insert_breakpoint {function expected_location} {
43    global gdb_prompt
44    global expect_out
45    global hex
46
47    set address ""
48
49    # Insert a breakpoint using the given function name, and extract
50    # the breakpoint address for the output.
51    gdb_test_multiple "break $function" "set breakpoint in $function" {
52        -re "Breakpoint .* at ($hex).*$gdb_prompt $" {
53            set address $expect_out(1,string)
54        }
55        default {
56            fail "set breakpoint in $function"
57        }
58    }
59
60    # If we managed to get the breakpoing address, then check that
61    # we inserted it at the expected location by examining the
62    # instruction at that address (we're not interested in the insn
63    # itself, but rather at the address printed at the begining of
64    # the instruction).
65    if { $address != "" } then {
66       gdb_test "x /i $address" \
67                ".*<$function\\+$expected_location>.*" \
68                "check $function breakpoint address"
69    } else {
70       fail "unable to compute breakpoint address"
71    }
72
73}
74
75insert_breakpoint "li_stw" 12
76insert_breakpoint "stack_check_probe_1" 16
77insert_breakpoint "stack_check_probe_2" 40
78insert_breakpoint "stack_check_probe_loop_1" 68
79insert_breakpoint "stack_check_probe_loop_2" 60
80
81