summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.objc
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.objc')
-rw-r--r--gdb/testsuite/gdb.objc/basicclass.exp12
-rw-r--r--gdb/testsuite/gdb.objc/nondebug.exp77
-rw-r--r--gdb/testsuite/gdb.objc/nondebug.m38
-rw-r--r--gdb/testsuite/gdb.objc/objcdecode.exp86
-rw-r--r--gdb/testsuite/gdb.objc/objcdecode.m49
5 files changed, 254 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.objc/basicclass.exp b/gdb/testsuite/gdb.objc/basicclass.exp
index 39cf296042a..c92534bdbea 100644
--- a/gdb/testsuite/gdb.objc/basicclass.exp
+++ b/gdb/testsuite/gdb.objc/basicclass.exp
@@ -1,4 +1,4 @@
-# Copyright 2003 Free Software Foundation, Inc.
+# Copyright 2003, 2004 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
@@ -125,13 +125,9 @@ gdb_test continue \
#
# Test resetting breakpoints when re-running program
#
-send_gdb "run\n"
+gdb_run_cmd
gdb_expect {
- -re "The program .* has been started already.*y or n. $" {
- send_gdb "y\n"
- exp_continue
- }
- -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
+ -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
{ pass "resetting breakpoints when rerunning" }
-re ".*$gdb_prompt $" { fail "resetting breakpoints when rerunning" }
timeout { fail "resetting breakpoints when rerunning" }
@@ -178,7 +174,7 @@ gdb_test continue \
# Test calling Objective-C methods
#
gdb_test "print \[self printHi\]" \
- "Hi.*\\$\[0-9\] = -?\[0-9\]+" \
+ "Hi.*\\$\[0-9\] = \\(.*objc_object \\*\\) 0x\[0-9a-f\]+" \
"Call an Objective-C method with no arguments"
gdb_test "print \[self printNumber: 42\]" \
diff --git a/gdb/testsuite/gdb.objc/nondebug.exp b/gdb/testsuite/gdb.objc/nondebug.exp
new file mode 100644
index 00000000000..9c7a7443524
--- /dev/null
+++ b/gdb/testsuite/gdb.objc/nondebug.exp
@@ -0,0 +1,77 @@
+# Copyright 2003 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.
+
+# This file tests decoding non-debuggable Objective-C symbols
+
+# This file was written by Adam Fedor (fedor@gnu.org)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile "nondebug"
+set srcfile ${testfile}.m
+set binfile ${objdir}/${subdir}/${testfile}
+
+#
+# Objective-C program compilation isn't standard. We need to figure out
+# which libraries to link in. Most of the time it uses pthread
+#
+if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list ] ] != "" } {
+ return -1
+}
+
+proc do_objc_tests {} {
+ global prms_id
+ global bug_id
+ global subdir
+ global objdir
+ global srcdir
+ global binfile
+ global gdb_prompt
+
+ set prms_id 0
+ set bug_id 0
+
+ # Start with a fresh gdb.
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load $binfile
+
+}
+
+do_objc_tests
+
+#
+# Break on multiply defined non-debuggable symbol (PR objc/1236)
+#
+set name "break on non-debuggable method"
+gdb_test_multiple "break someMethod" $name \
+{
+ -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\]\[ \]+-.NonDebug someMethod.*\\\[3\\\]\[ \]+-.NonDebug2 someMethod.*" {
+ send_gdb "2\n"
+ exp_continue
+ }
+ -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n> " {
+ gdb_test "0" "" ""
+ kfail "gdb/1236" $name
+ }
+ -re "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+.*$gdb_prompt $" { pass $name }
+ -re ".*$gdb_prompt $" { kfail "gdb/1236" $name }
+}
+
diff --git a/gdb/testsuite/gdb.objc/nondebug.m b/gdb/testsuite/gdb.objc/nondebug.m
new file mode 100644
index 00000000000..dcbdde936c7
--- /dev/null
+++ b/gdb/testsuite/gdb.objc/nondebug.m
@@ -0,0 +1,38 @@
+#include <objc/Object.h>
+
+@interface NonDebug: Object
+{
+}
+@end
+@interface NonDebug2: Object
+{
+}
+@end
+
+@implementation NonDebug
+
+- someMethod
+{
+ printf("method someMethod\n");
+ return self;
+}
+
+@end
+@implementation NonDebug2
+
+- someMethod
+{
+ printf("method2 someMethod\n");
+ return self;
+}
+
+@end
+
+
+int main (int argc, const char *argv[])
+{
+ id obj;
+ obj = [NonDebug new];
+ [obj someMethod];
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.objc/objcdecode.exp b/gdb/testsuite/gdb.objc/objcdecode.exp
new file mode 100644
index 00000000000..e00bffeae77
--- /dev/null
+++ b/gdb/testsuite/gdb.objc/objcdecode.exp
@@ -0,0 +1,86 @@
+# Copyright 2003 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.
+
+# This file tests decoding of Objective-C symbols
+
+# This file was written by Adam Fedor (fedor@gnu.org)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile "objcdecode"
+set srcfile ${testfile}.m
+set binfile ${objdir}/${subdir}/${testfile}
+
+#
+# Objective-C program compilation isn't standard. We need to figure out
+# which libraries to link in. Most of the time it uses pthread
+#
+if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+proc do_objc_tests {} {
+ global prms_id
+ global bug_id
+ global subdir
+ global objdir
+ global srcdir
+ global binfile
+ global gdb_prompt
+
+ set prms_id 0
+ set bug_id 0
+
+ # Start with a fresh gdb.
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load $binfile
+
+}
+
+do_objc_tests
+
+#
+# Break on multiply defined method (PR objc/1236)
+#
+set name "break on multiply defined method"
+gdb_test_multiple "break multipleDef" $name \
+{
+ -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" {
+ send_gdb "3\n"
+ exp_continue
+ }
+ -re "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*\r\n$gdb_prompt $" { pass $name }
+ -re ".*$gdb_prompt $" { kfail "gdb/1236" $name }
+}
+
+set name "continue after break on multiply defined symbol"
+gdb_test_multiple "run" $name \
+{
+ -re "Starting program.*Breakpoint \[0-9\]+, multipleDef \\\(\\\) at .*\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Starting program.*\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" {
+ send_gdb "0\n"
+ kfail "gdb/1238" $name
+ # gdb is in a bad state here.
+ # It would be difficult to do any more tests after this.
+ }
+}
diff --git a/gdb/testsuite/gdb.objc/objcdecode.m b/gdb/testsuite/gdb.objc/objcdecode.m
new file mode 100644
index 00000000000..5e99618d115
--- /dev/null
+++ b/gdb/testsuite/gdb.objc/objcdecode.m
@@ -0,0 +1,49 @@
+#include <objc/Object.h>
+
+@interface Decode: Object
+{
+}
+- multipleDef;
+- (const char *) myDescription;
+@end
+
+@implementation Decode
+
+- multipleDef
+{
+ printf("method multipleDef\n");
+ return self;
+}
+
+- (const char *) myDescription
+{
+ return "Decode gdb test object";
+}
+
+@end
+
+int
+multipleDef()
+{
+ printf("function multipleDef\n");
+ return 0;
+}
+
+int main (int argc, const char *argv[])
+{
+ id obj;
+ obj = [Decode new];
+ multipleDef();
+ [obj multipleDef];
+ return 0;
+}
+
+const char *_NSPrintForDebugger(id object)
+{
+ /* This is not really what _NSPrintForDebugger should do, but it
+ is a simple test if gdb can call this function */
+ if (object && [object respondsTo: @selector(myDescription)])
+ return [object myDescription];
+
+ return NULL;
+}