blob: 185491129609feecb13b8bc70ac75a81a12c3e3f [file] [log] [blame]
# Copyright 2003, 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.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file was written by Jason Molenda (jmolenda@apple.com)
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "a.out"
set binfile ${objdir}/${subdir}/${testfile}
set timeout 30
set arch "i386"
if [target_info exists darwin64] {
set arch "x86_64"
}
if [istarget "powerpc-apple-darwin*"] {
set arch "ppc"
}
remote_exec build "sh ${srcdir}/${subdir}/../set-up-objdir.sh ${srcdir}/${subdir} ${objdir}/${subdir}"
remote_exec build "make ARCH=${arch} -C ${objdir}/${subdir} stage1"
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
if ![runto_main] then {
fail "small c fix and continue tests suppressed"
return -1
}
gdb_test "next" ".*I am in main.*" "first step"
gdb_test "next" ".*I am in bar in b.c version 1.*I am in fred.*" "step over bar() version 1"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage1_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage1"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage1"
}
timeout {
fail "get addr of foo() at stage1 (timeout)"
}
}
# Build a new b.c
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage2" ".*gcc.*b2.o.*b-bundlized.o.*b2.o" "make version 2 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o2 $objdir/$subdir/b.c" ".*Fix succeeded." "Bring in fixed b.c version 2"
gdb_test "next" ".*I am in bar in b.c version 2.*I am in fred.*" "step over bar() version 2"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage2_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage2"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage2"
}
timeout {
fail "get addr of foo() at stage2 (timeout)"
}
}
if { $stage1_foo_addr != $stage2_foo_addr } then {
pass "stage1 foo() and stage2 foo() are different."
} else {
fail "stage1 foo() and stage2 foo() are different."
}
# Build a newer b.c
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage3" ".*gcc.*b3.o" "make version 3 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o3 $objdir/$subdir/b.c" ".*Fix succeeded." "Bring in fixed b.c version 3"
gdb_test "next" ".*I am in bar in b.c version 3.*I am in fred.*" "step over bar() version 3"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage3_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage3"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage3"
}
timeout {
fail "get addr of foo() at stage3 (timeout)"
}
}
if { $stage2_foo_addr != $stage3_foo_addr } then {
pass "stage2 foo() and stage3 foo() are different."
} else {
fail "stage2 foo() and stage3 foo() are different."
}
# Build a newest b.c
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage4" ".*gcc.*b4.o" "make version 4 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o4 $objdir/$subdir/b.c" ".*Fix succeeded." "Bring in fixed b.c version 4"
gdb_test "next" ".*I am in bar in b.c version 4.*I am in fred.*" "step over bar() version 4"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage4_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage4"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage4"
}
timeout {
fail "get addr of foo() at stage4 (timeout)"
}
}
if { $stage3_foo_addr != $stage4_foo_addr } then {
pass "stage3 foo() and stage4 foo() are different."
} else {
fail "stage3 foo() and stage4 foo() are different."
}
# Build invalid b.c #1
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage5" ".*-o b-bundlized.o5 b5.o" "make version 5 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o5 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Changing the type of global variable 'bss_int' from 'int' to 'float' is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject change of global variable's type."
}
-re ".*$gdb_prompt $" {
fail "Reject change of global variable's type."
}
timeout {
fail "Reject change of global variable's type. (timeout)"
}
}
# Build invalid b.c #2
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage6" ".*-o b-bundlized.o6 b6.o" "make version 6 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o6 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Changing function 'foo' to a variable is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject change of function to variable."
}
-re ".*$gdb_prompt $" {
fail "Reject change of function to variable."
}
timeout {
fail "Reject change of function to variable. (timeout)"
}
}
# Build invalid b.c #3
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage7" ".*-o b-bundlized.o7 b7.o" "make version 7 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o7 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Changing variable 'global_var' to a function is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject change of variable to function."
}
-re ".*$gdb_prompt $" {
fail "Reject change of variable to function."
}
timeout {
fail "Reject change of variable to function. (timeout)"
}
}
# Build valid b.c #1
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage9" ".*-o b-bundlized.o9 b9.o" "make version 9 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o9 $objdir/$subdir/b.c" ".*Fix succeeded." "fix in b-bundlized version 9"
gdb_test "next" ".*I am in bar in b.c version 9.*I am in fred.*" "step over bar() version 9"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage9_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage9"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage9"
}
timeout {
fail "get addr of foo() at stage9 (timeout)"
}
}
if { $stage4_foo_addr != $stage9_foo_addr } then {
pass "stage4 foo() and stage9 foo() are different."
} else {
fail "stage4 foo() and stage9 foo() are different."
}
# Build invalid b.c #5
gdb_test "break bar" "Breakpoint 2 at.*" "Set a breakpoint in bar"
gdb_test "continue" "Continuing.*Breakpoint 2, bar.*" "Continue to bar"
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage10" ".*-o b-bundlized.o10 b10.o" "make version 10 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o10 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Changing number of local variables from 0 to 1 for function 'bar' while active on the stack is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject adding local variable to function on the stack."
}
-re ".*$gdb_prompt $" {
fail "Reject adding local variable to function on the stack."
}
timeout {
fail "Reject adding local variable to function on the stack. (timeout)"
}
}
gdb_test "finish" "Value returned is.*" "Finish back to main"
# Build invalid b.c #6
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage11" ".*-o b-bundlized.o11 b11.o" "make version 11 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o11 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Changing number of arguments from 0 to 1 for function 'bar' is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject adding argument to function on the stack."
}
-re ".*$gdb_prompt $" {
fail "Reject adding argument to function on the stack."
}
timeout {
fail "Reject adding argument to function on the stack. (timeout)"
}
}
# Build invalid b.c #7
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage12" ".*-o b-bundlized.o12 b12.o" "make version 12 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o12 $objdir/$subdir/b.c\n"
gdb_expect {
-re "In function 'slurry', argument 'a' changed from type 'char' to type 'int', which is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject changing funtion arg type (char to int)."
}
-re ".*$gdb_prompt $" {
fail "Reject changing funtion arg type (char to int)."
}
timeout {
fail "Reject changing funtion arg type (char to int). (timeout)"
}
}
# Build invalid b.c #8
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage13" ".*-o b-bundlized.o13 b13.o" "make version 13 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o13 $objdir/$subdir/b.c\n"
gdb_expect {
-re "In function 'slurry', argument 'a' changed from type 'char' to type 'struct lkj \\*', which is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject changing funtion arg type (char to ptr to struct)."
}
-re ".*$gdb_prompt $" {
fail "Reject changing funtion arg type (char to ptr to struct)."
}
timeout {
fail "Reject changing funtion arg type (char to ptr to struct). (timeout)"
}
}
# Build invalid b.c #9
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage14" ".*-o b-bundlized.o14 b14.o" "make version 14 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o14 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Function 'slurry' was changed from returning 'int ' to 'struct lkj ', which is not supported.\[\r\n\]+$gdb_prompt $" {
pass "Reject changing funtion return type (int to struct)."
}
-re ".*$gdb_prompt $" {
fail "Reject changing funtion return type (int to struct)."
}
timeout {
fail "Reject changing funtion return type (int to struct). (timeout)"
}
}
# Build valid b.c #4
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage18" ".*-o b-bundlized.o18 b18.o" "make version 18 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o18 $objdir/$subdir/b.c" ".*Fix succeeded." "fix in b-bundlized version 18"
gdb_test "next" ".*I am in bar in b.c version 18.*I am in fred.*" "step over bar() version 18"
send_gdb "p foo\n"
gdb_expect {
-re ".*$decimal = \{int \\((void|)\\)\} ($hex) <foo>\[\r\n\]+$gdb_prompt $" {
set stage18_foo_addr $expect_out(2,string)
pass "get addr of foo() at stage18"
}
-re ".*$gdb_prompt $" {
fail "get addr of foo() at stage18"
}
timeout {
fail "get addr of foo() at stage18 (timeout)"
}
}
if { $stage4_foo_addr != $stage18_foo_addr } then {
pass "stage4 foo() and stage18 foo() are different."
} else {
fail "stage4 foo() and stage18 foo() are different."
}
# Build invalid b.c #10
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage17" ".*-o b-bundlized.o17 b17.o" "make version 17 of b.c"
send_gdb "fix $objdir/$subdir/b-bundlized.o17 $objdir/$subdir/b.c\n"
gdb_expect {
-re "Not able to load Fix bundle with error:.*Symbol not found: _mprintf.*\[\r\n\]+$gdb_prompt $" {
pass "Reject reference to undefined external function."
}
-re ".*$gdb_prompt $" {
fail "Reject reference to undefined external function."
}
timeout {
fail "Reject reference to undefined external function. (timeout)"
}
}
# Build valid b.c #5
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage19" ".*-o b-bundlized.o19 b19.o" "make version 19 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o19 $objdir/$subdir/b.c" ".*Fix succeeded." "fix in b-bundlized version 19"
gdb_test "next" ".*I am in bar in b.c version 19.*I am in fred.*" "step over bar() version 19"
gdb_test "print newly_added_integer" "\\$$decimal = 0" "check that new global is printable and zeroed"
send_gdb "set newly_added_integer = 15\n"
gdb_expect {
-re "No symbol \"newly_added_integer\" in current context.*$gdb_prompt $"
{
fail "Set newly_added_integer by hand"
}
-re "$gdb_prompt $"
{
pass "Set newly_added_integer by hand"
}
-re ".*$gdb_prompt $"
{
fail "Set newly_added_integer by hand"
}
timeout {
fail "Set newly_added_integer by hand (timeout)"
}
}
gdb_test "print newly_added_integer" "\\$$decimal = 15" "setting of newly_added_integer took"
# Build valid b.c #6
gdb_test "shell make ARCH=${arch} -C $objdir/$subdir stage20" ".*-o b-bundlized.o20 b20.o" "make version 20 of b.c"
gdb_test "fix $objdir/$subdir/b-bundlized.o20 $objdir/$subdir/b.c" ".*Fix succeeded." "fix in b-bundlized version 20"
gdb_test "next" ".*I am in bar in b.c version 20.*I am in fred.*" "step over bar() version 20"
gdb_test "print newly_added_integer" "\\$$decimal = 15" "setting of newly_added_integer persisted across another fix"
# FIXME: Check that we only have three copies of b-bundlized loaded, maybe
# do more.
gdb_test "info sharedlibrary" ".*b-bundlized.*" "get list of dylibs at end"
gdb_exit
return 0