1# Copyright 2004 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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# Test stepping into and continuing on from a function in
21# a shared library (PR gdb/1555, was PR shlib/1280, shlib/1237).
22# Tested on ppc-yellowdog-linux (Yellow Dog Linux 3.0 3.2.2-2a)
23
24if $tracelevel then {
25    strace $tracelevel
26}
27
28set testfile gdb1555-main
29set libfile gdb1555
30set srcfile ${testfile}.c
31set binfile ${objdir}/${subdir}/${testfile}
32
33remote_exec build "rm -f ${binfile}"
34
35# get the value of gcc_compiled
36if [get_compiler_info ${binfile}] {
37    return -1
38}
39
40if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
41    return -1
42}
43
44# Build the shared libraries this test case needs.
45#
46
47if {$gcc_compiled == 0} {
48    if [istarget "hppa*-hp-hpux*"] then {
49        set additional_flags "additional_flags=+z"
50    } elseif { [istarget "mips-sgi-irix*"] } {
51        # Disable SGI compiler's implicit -Dsgi
52        set additional_flags "additional_flags=-Usgi"
53    } else {
54        # don't know what the compiler is...
55        set additional_flags ""
56    }
57} else {
58    if { ([istarget "powerpc*-*-aix*"]
59    || [istarget "rs6000*-*-aix*"]) } {
60        set additional_flags ""
61    } else {
62        set additional_flags "additional_flags=-fpic"
63    }
64}
65
66set additional_flags "$additional_flags -shared"
67if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.so" executable [list debug $additional_flags "incdir=${objdir}"]] != ""} {
68    return -1
69}
70
71if { ($gcc_compiled
72&&  ([istarget "powerpc*-*-aix*"]
73|| [istarget "rs6000*-*-aix*"] )) } {
74    set additional_flags "additional_flags=-L${objdir}/${subdir}"
75} elseif { [istarget "mips-sgi-irix*"] } {
76    set additional_flags "additional_flags=-rpath ${objdir}/${subdir}"
77} else {
78    set additional_flags ""
79}
80
81if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.so" "${binfile}" executable [list debug $additional_flags]] != ""} {
82    return -1
83}
84
85
86gdb_exit
87gdb_start
88gdb_reinitialize_dir $srcdir/$subdir
89gdb_load ${binfile}
90
91if ![runto_main] then {
92    fail "Can't run to main"
93    return 0
94}
95
96# PR/1555 (was shlib 1280)
97set name "Step into shared lib function"
98gdb_test_multiple "s" $name \
99{
100    -re "hithere2 \\(\\) at.*${libfile}.c:25\r\n25.*a = 21;.*$gdb_prompt $"  {
101	pass $name
102    }
103    -re "0x\[0-9a-f\]+ in .* \\(\\) from /lib/ld.so.1.*$gdb_prompt $" {
104	kfail "gdb/1555" $name
105    }
106}
107
108# PR/1555 (was shlib 1237)
109set name "Next while in a shared lib function"
110gdb_test_multiple "n" $name \
111{
112    -re "26.*return a;.*$gdb_prompt $" {
113	pass $name
114    }
115    -re "Single stepping until exit from function .*, \r\nwhich has no line number information.\r\n\r\nProgram exited normally.*$gdb_prompt $" {
116	kfail "gdb/1555" $name
117    }
118}
119
120