blob: f22ff34cc37ca801a3b731fb5cdd6e31b832fad3 [file] [log] [blame]
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Test the environment of someone working on dyld. Which is
#
# 1. The dyld they're working on is not installed as /usr/lib/dyld -- it's no
# fun to trash your system while you're working on a bug.
# 2. dyld was built as "dyld" by Xcode, so when Xcode sets breakpoints
# it'll specify a shlib for those breakpoints of "dyld" and they'll never
# hit when the actual dynamic loader is "dyld-tst". So /tmp/dyld-tst becomes
# a symlink to the dyld in the built directory.
# i.e. at runtime we have
#
# BUILDDIR/test-program (some random program we don't care about)
# BUILDDIR/dyld (the dyld we're debugging)
# /tmp/dyld-tst -> BUILDDIR/dyld
#
# The test-program has /usr/lib/dyld listed as its dynamic linker, so we
# need to post-process BUILDDIR/test-program to change the string
# "/usr/lib/dyld" to "/tmp/dyld-tst" so it will use the symlink to
# BUILDDIR/dyld which we want to debug.
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "nick"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/$srcfile" "${binfile}" executable {debug}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
remote_exec build "perl -pi -e s#/usr/lib/dyld#/tmp/dyld-tst# $binfile"
remote_exec build "rm -f ${objdir}/${subdir}/dyld"
remote_exec build "cp /usr/lib/dyld ${objdir}/${subdir}/dyld"
remote_exec build "rm -f /tmp/dyld-tst"
remote_exec build "ln -s ${objdir}/${subdir}/dyld /tmp/dyld-tst"
set dyld_before_event __dyld__ZN4dyld24initializeMainExecutableEv
# Start with a fresh gdb
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test "break -shlib dyld $dyld_before_event" "Breakpoint 1 at $hex.*" "setting breakpoint at dyld initializeMainExecutable, shlib-restricted"
gdb_test "break main" "Breakpoint 2 at $hex: file.*" "setting breakpoint on main"
gdb_test "run" "Starting program: $binfile *\r\n\.*Breakpoint 1, .*$dyld_before_event.*" "stopped in dyld"
gdb_test "continue" "Continuing\\..*Breakpoint 2, main.*" "stopped at main"
gdb_test "info shared" "dyld.*dyld Y Y.*nick.*exec Y Y.*libSystem.B.dylib.*dyld Y Y.*" "gdb is getting load notifications"
send_gdb "info shared\n"
gdb_expect {
-re ".*dyld-tst.*$gdb_prompt $" {
fail "dyld-tst should not be in info shared output"
}
-re ".*libSystem.B.dylib.*$gdb_prompt $" {
pass "dyld-tst should not be in info shared output"
}
-re "$gdb_prompt $" {
fail "dyld-tst should not be in info shared output"
}
timeout {
fail "(timeout) dyld-tst should not be in info shared output"
}
}
gdb_test "info shared" ".*${objdir}/${subdir}/dyld.*" "copy of dyld should be in info shared output"
gdb_test "maint info br" ".*-$decimal *shlib events *keep y *$hex.*gdb_image_notifier.*" "dylib notification internal breakpoint was set"
gdb_exit
return 0