diff options
author | Stan Shebs <shebs@apple.com> | 2008-11-21 02:36:29 +0000 |
---|---|---|
committer | Stan Shebs <shebs@apple.com> | 2008-11-21 02:36:29 +0000 |
commit | 5292ac9d5a125ebdfa49c14b906c6981988022d3 (patch) | |
tree | 7f66454347ec9669f36420c5865e5b7f2ee74ce3 | |
parent | 20f0c60af9a23e73083530f15f8a4fdbac74a4eb (diff) | |
download | gdb-5292ac9d5a125ebdfa49c14b906c6981988022d3.tar.gz |
2008-11-20 Stan Shebs <stan@codesourcery.com>
2008-09-14 Stan Shebs <stan@codesourcery.com>
* gdb.multi/Makefile.in: New.
* gdb.multi/hello.c, hangout.c, goodbye.c: New source files.
* gdb.multi/base.exp: New file, basic multiprocess tests.
-rw-r--r-- | gdb/testsuite/gdb.multi/Makefile.in | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/base.exp | 149 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/goodbye.c | 45 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/hangout.c | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.multi/hello.c | 29 |
5 files changed, 256 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.multi/Makefile.in b/gdb/testsuite/gdb.multi/Makefile.in new file mode 100644 index 00000000000..2ae5bad03bb --- /dev/null +++ b/gdb/testsuite/gdb.multi/Makefile.in @@ -0,0 +1,24 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +EXECUTABLES = hello hello2 hangout goodbye sleeper + +MISCELLANEOUS = + +all info install-info dvi install uninstall installcheck check: + @echo "Nothing to be done for $@..." + +clean mostlyclean: + -find . -name '*.o' -print | xargs rm -f + -find . -name '*.ali' -print | xargs rm -f + -find . -name 'b~*.ad[sb]' -print | xargs rm -f + -rm -f *~ a.out xgdb *.x *.ci *.tmp + -rm -f *~ *.o a.out xgdb *.x *.ci *.tmp + -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES) + -rm -f $(MISCELLANEOUS) twice-tmp.c + +distclean maintainer-clean realclean: clean + -rm -f *~ core + -rm -f Makefile config.status config.log + -rm -f *-init.exp + -rm -fr *.log summary detail *.plog *.sum *.psum site.* diff --git a/gdb/testsuite/gdb.multi/base.exp b/gdb/testsuite/gdb.multi/base.exp new file mode 100644 index 00000000000..b1616f2aed6 --- /dev/null +++ b/gdb/testsuite/gdb.multi/base.exp @@ -0,0 +1,149 @@ +# Copyright 2008 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 3 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, see <http://www.gnu.org/licenses/>. + +# Test multi-exec / multi-process features that work for all configurations, +# even ones that cannot run multiple processes simultaneously. + +set testfile "base" + +set exec1 "hello" +set srcfile1 ${exec1}.c +set binfile1 ${objdir}/${subdir}/${exec1} + +set exec2 "hangout" +set srcfile2 ${exec2}.c +set binfile2 ${objdir}/${subdir}/${exec2} + +set exec3 "goodbye" +set srcfile3 ${exec3}.c +set binfile3 ${objdir}/${subdir}/${exec3} + +if { [prepare_for_testing ${testfile}.exp ${exec1} "${srcfile1}" {debug nowarnings}] } { + return -1 +} + +if { [prepare_for_testing ${testfile}.exp ${exec2} "${srcfile2}" {debug nowarnings}] } { + return -1 +} + +if { [prepare_for_testing ${testfile}.exp ${exec3} "${srcfile3}" {debug nowarnings}] } { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile1} + +send_gdb "add-file ${binfile2}\n" +gdb_expect { + -re ".*A program is being debugged already.*Are you sure you want to add another executable file. .y or n. $" { + send_gdb "y\n" + gdb_expect { + -re ".*Load new symbol table from.* .y or n. $" { + send_gdb "y\n" + gdb_expect { + -re "Reading symbols from.*$gdb_prompt $" {} + timeout { fail "loading symbols (timeout)"; return } + } + } + -re ".*gdb_prompt $" {} + timeout { fail "loading symbols (timeout)"; return } + } + } + -re "$gdb_prompt $" { fail "add-file" } + timeout { fail "(timeout) add-file" } +} + +send_gdb "add-file ${binfile3}\n" +gdb_expect { + -re ".*Load new symbol table from.* .y or n. $" { + send_gdb "y\n" + gdb_expect { + -re "Reading symbols from.*$gdb_prompt $" {} + timeout { fail "loading symbols (timeout)"; return } + } + } + -re "$gdb_prompt $" { fail "add-file" } + timeout { fail "(timeout) add-file" } +} + +# Test that we have multiple executables. + +gdb_test "info files" \ + "Symbols from .*Local exec file.*${exec1}.*${exec2}.*${exec3}.*" + +# Test that we have multiple symbol tables. + +gdb_test "info functions commonfun" "All functions.*${srcfile1}.*${srcfile3}.*" + +# Test the focus command. + +gdb_test "focus" "No focus has been set.*" "focus (initial default)" + +gdb_test "focus ${exec1}" "Current exec is .*${exec1}.*" + +gdb_test "focus ${exec2}" "Current exec is .*${exec2}.*" + +gdb_test "focus" "Focus is .${exec2}..*(current exec is .*${exec2}).*" \ + "focus (after setting focus)" + +gdb_test "focus ${exec2}" "Current exec is .*${exec2}.*" "focus ${exec2} (again)" + +gdb_test "focus ${exec1}" "Current exec is .*${exec1}.*" "focus ${exec1} (again)" + +gdb_test "set listsize 1" "" + +gdb_test "list commonfun" "5\[ \t\]+int commonfun\[(\]\[)\] \{ bar\[(\]\[)\]; \}" + +gdb_test "print hglob" "1" + +gdb_test "print glob" "92" "print glob (${exec1})" + +gdb_test "focus ${exec3}" "Current exec is .*${exec3}.*" + +gdb_test "print gglob" "2" + +gdb_test "print glob" "45" "print glob (${exec3})" + +gdb_test "list commonfun" "41\[ \t\]+void commonfun\[(\]\[)\] \{ mailand\[(\]\[)\]; \}" + +# Test the #-syntax. + +gdb_test "list #${exec1}#commonfun" \ + "5\[ \t\]+int commonfun\[(\]\[)\] \{ bar\[(\]\[)\]; \}" + +gdb_test "list #${exec3}#commonfun" \ + "41\[ \t\]+void commonfun\[(\]\[)\] \{ mailand\[(\]\[)\]; \}" + +# Test execution. + +gdb_test "focus ${exec1}" "Current exec is .*${exec1}.*" "focus ${exec1} (yet again)" + +if { ![runto_main] } then { + gdb_suppress_tests +} + +gdb_test "break hello" "" + +gdb_test "continue" "Breakpoint \[0-9\].*, hello.*" + +gdb_test "break #hello#26" "" + +gdb_test "break #goodbye#commonfun" "" + +# Observe that breakpoints are per-executable. + +gdb_test "continue" "Breakpoint \[0-9\], main.*26\[\t \]*glob = tmpx;.*" diff --git a/gdb/testsuite/gdb.multi/goodbye.c b/gdb/testsuite/gdb.multi/goodbye.c new file mode 100644 index 00000000000..aa1f99569b8 --- /dev/null +++ b/gdb/testsuite/gdb.multi/goodbye.c @@ -0,0 +1,45 @@ +int gglob = 2; + +int glob = 45; + +int verylongfun() +{ + glob += 2; + glob *= 2; + glob += 3; + glob *= 3; + glob += 4; + glob *= 4; + glob += 5; + glob *= 5; + glob += 6; + glob *= 6; + glob += 7; + glob *= 7; + glob += 8; + glob *= 8; + glob += 9; + glob *= 9; +} + +main() { + mailand(); + foo(glob); + verylongfun(); + goodbye(); +} + +foo(int x) { + return x + 92; +} + +mailand() +{ + glob = 46; +} + +void commonfun() { mailand(); } + +goodbye() { + ++glob; +} diff --git a/gdb/testsuite/gdb.multi/hangout.c b/gdb/testsuite/gdb.multi/hangout.c new file mode 100644 index 00000000000..1b0b7f5f518 --- /dev/null +++ b/gdb/testsuite/gdb.multi/hangout.c @@ -0,0 +1,9 @@ +main(int argc, char *argv[]) +{ + int i; + + for (i = 0; i < argc; ++i) + { + printf("Arg %d is %s\n", i, argv[i]); + } +} diff --git a/gdb/testsuite/gdb.multi/hello.c b/gdb/testsuite/gdb.multi/hello.c new file mode 100644 index 00000000000..652618e454a --- /dev/null +++ b/gdb/testsuite/gdb.multi/hello.c @@ -0,0 +1,29 @@ +short hglob = 1; + +short glob = 92; + +int commonfun() { bar(); } + +bar() +{ + if (glob == 0) + exit(1); +} + +hello(int x) +{ + x *= 2; + return x + 45; +} + +main() +{ + int tmpx; + + bar(); + tmpx = hello(glob); + commonfun(); + glob = tmpx; + commonfun(); +} + |