This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
pending/1114: Re: [RFA] ObjC Testsuite
- From: Adam Fedor <fedor at doc dot com>
- To: Michael Elizabeth Chastain <mec at shout dot net>
- Cc: fedor at gnu dot org, fnasser at redhat dot com, msalter at redhat dot com, ezannoni at redhat dot com, gdb-gnats at sources dot redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Mon, 03 Mar 2003 21:45:50 -0700
- Subject: pending/1114: Re: [RFA] ObjC Testsuite
- References: <200303031615.h23GFBc26561@duracef.shout.net>
>Number: 1114
>Category: pending
>Synopsis: Re: [RFA] ObjC Testsuite
>Confidential: yes
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: unknown
>Arrival-Date: Tue Mar 04 04:48:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:
>Release:
>Organization:
>Environment:
>Description:
This is a multi-part message in MIME format.
--------------000409020101050900050304
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Michael Elizabeth Chastain wrote:
>
> On the next submission, please use 'cvs diff -N' to include the new
> files in the diff, rather than attaching a diff + a tarball.
> That's easier for me.
>
> We need one or more maintainers for the new gdb.objc. I volunteer to
> be one of the maintainers. Adam, are you willing to be a maintainer?
>
Ok. I'm willing.
> Also, this whole review process is getting messy, we are going to have
> several people pushing Adam in different directions. I would like to
> figure out *first* who are going to be the maintainer(s) of
> gdb.objc, and then those people should be the reviewers of this patch.
>
Here's an update. I changed the filenames to basicclass from myclass
(perhaps not much better), added proc gdb_compile_objc and added
linenumbers to the breakpoint tests so they are more specific.
--------------000409020101050900050304
Content-Type: text/plain;
name="suite1.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="suite1.patch"
2003-03-03 Adam Fedor <fedor at gnu dot org>
* Makefile.in (ALL_SUBDIRS): Add gdb.objc
* configure.in (AC_OUTPUT): Add gdb.objc/Makefile.
* lib/gdb.exp (proc gdb_compile_objc): New procedure.
* gdb.objc, gdb.objc/Makefile.in, gdb.objc/basicclass.exp,
gdb.objc/basicclass.m: New files.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/Makefile.in,v
retrieving revision 1.5
diff -u -r1.5 Makefile.in
--- Makefile.in 9 Jan 2003 18:50:21 -0000 1.5
+++ Makefile.in 4 Mar 2003 04:39:17 -0000
@@ -36,7 +36,7 @@
SUBDIRS = @subdirs@
RPATH_ENVVAR = @RPATH_ENVVAR@
ALL_SUBDIRS = gdb.arch gdb.asm gdb.base gdb.c++ gdb.disasm gdb.java gdb.mi \
- gdb.threads gdb.trace $(SUBDIRS)
+ gdb.objc gdb.threads gdb.trace $(SUBDIRS)
EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \
echo $${rootme}/../../expect/expect ; \
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/configure.in,v
retrieving revision 1.8
diff -u -r1.8 configure.in
--- configure.in 4 Jan 2003 15:37:36 -0000 1.8
+++ configure.in 4 Mar 2003 04:39:24 -0000
@@ -115,4 +115,4 @@
AC_CONFIG_SUBDIRS($configdirs)
AC_OUTPUT([Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
gdb.c++/Makefile gdb.disasm/Makefile gdb.java/Makefile gdb.mi/Makefile \
- gdb.threads/Makefile gdb.trace/Makefile])
+ gdb.objc/Makefile gdb.threads/Makefile gdb.trace/Makefile])
Index: gdb.objc/Makefile.in
===================================================================
RCS file: gdb.objc/Makefile.in
diff -N gdb.objc/Makefile.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.objc/Makefile.in 4 Mar 2003 04:39:25 -0000
@@ -0,0 +1,22 @@
+VPATH = @srcdir@
+srcdir = @srcdir@
+
+EXECUTABLES = basicclass
+
+all:
+ @echo "Nothing to be done for all..."
+
+info:
+install-info:
+dvi:
+install:
+uninstall: force
+installcheck:
+check:
+
+clean mostlyclean:
+ -rm -f *~ *.o *.ci
+ -rm -f core ${EXECUTABLES}
+
+distclean maintainer-clean realclean: clean
+ -rm -f Makefile config.status config.log
Index: gdb.objc/basicclass.exp
===================================================================
RCS file: gdb.objc/basicclass.exp
diff -N gdb.objc/basicclass.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.objc/basicclass.exp 4 Mar 2003 04:39:25 -0000
@@ -0,0 +1,199 @@
+# 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 was written by Adam Fedor (fedor at gnu dot org)
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile "basicclass"
+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 ]] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+#
+# Deduce language of main()
+#
+
+proc deduce_language_of_main {} {
+ global gdb_prompt
+
+ # See what language gdb thinks main() is, prior to reading full symbols.
+ # I think this fails for COFF targets.
+ send_gdb "show language\n"
+ gdb_expect {
+ -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
+ pass "deduced language is Objective-C, before full symbols"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "source language not correct for Objective-C (psymtabs only)"
+ return
+ }
+ timeout {
+ fail "can't show language (timeout)"
+ return
+ }
+ }
+
+ runto_main
+
+ # See if our idea of the language has changed.
+
+ send_gdb "show language\n"
+ gdb_expect {
+ -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
+ pass "deduced language is Objective-C, after full symbols"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "source language not correct for Objective-C (full symbols)"
+ return
+ }
+ timeout {
+ fail "can't show language (timeout)"
+ return
+ }
+ }
+}
+
+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
+
+ deduce_language_of_main
+}
+
+do_objc_tests
+
+#
+# Breakpoint tests
+#
+gdb_test "break doIt" \
+ "Breakpoint.*at.* file .*$srcfile, line.29.*" \
+ "breakpoint method"
+
+gdb_test "break takeArg:" \
+ "Breakpoint.*at.* file .*$srcfile, line.34.*" \
+ "breakpoint method with colon"
+
+gdb_test "break newWithArg:" \
+ "Breakpoint.*at.* file .*$srcfile, line.22.*" \
+ "breakpoint class method with colon"
+
+#
+# Continue until breakpoint (test re-setting breakpoint)
+#
+gdb_test continue \
+ "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
+ "continue until method breakpoint"
+
+#
+# Test resetting breakpoints when re-running program
+#
+send_gdb "run\n"
+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 $"\
+ { pass "resetting breakpoints when rerunning" }
+ -re ".*$gdb_prompt $" { fail "resetting breakpoints when rerunning" }
+ timeout { fail "resetting breakpoints when rerunning" }
+}
+
+#
+# Continue until breakpoint (test re-setting breakpoint)
+#
+gdb_test continue \
+ "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
+ "continue until method breakpoint"
+
+#
+# Test printing objects
+#
+gdb_test "print object" \
+ "\\$\[0-9\] = .*0x0" \
+ " print an ivar of self"
+
+gdb_test "print self" \
+ "\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
+ " print self"
+
+gdb_test "print \*self" \
+ "\\$\[0-9\] = \{isa = 0x\[0-9a-f\]+, object = 0x0\}" \
+ " print contents of self"
+
+#
+# Break in a category
+#
+gdb_test "break hiddenMethod" \
+ "Breakpoint.*at.* file .*$srcfile, line.61." \
+ "breakpoint in category method"
+
+
+#
+# Continue until breakpoint (test re-setting category breakpoint)
+#
+gdb_test continue \
+ "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
+ "continue until category method"
+
+#
+# Test calling Objective-C methods
+#
+gdb_test "print \[self printHi\]" \
+ "Hi.*\\$\[0-9\] = \[0-9\]+" \
+ "Call an Objective-C method with no arguments"
+
+gdb_test "print \[self printNumber: 42\]" \
+ "42.*\\$\[0-9\] = 43" \
+ "Call an Objective-C method with one argument"
+
+#
+# Test printing the object description
+#
+gdb_test "print-object object" \
+ "BasicClass gdb test object" \
+ "Use of the print-object command"
+
+gdb_test "po self" \
+ "BasicClass gdb test object" \
+ "Use of the po (print-object) command"
+
+
Index: gdb.objc/basicclass.m
===================================================================
RCS file: gdb.objc/basicclass.m
diff -N gdb.objc/basicclass.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.objc/basicclass.m 4 Mar 2003 04:39:25 -0000
@@ -0,0 +1,81 @@
+#include <objc/Object.h>
+
+ at interface BasicClass: Object
+{
+ id object;
+}
++ newWithArg: arg;
+- doIt;
+- takeArg: arg;
+- printHi;
+- (int) printNumber: (int)number;
+- (const char *) myDescription;
+ at end
+
+ at interface BasicClass (Private)
+- hiddenMethod;
+ at end
+
+ at implementation BasicClass
++ newWithArg: arg
+{
+ id obj = [self new];
+ [obj takeArg: arg];
+ return obj;
+}
+
+- doIt
+{
+ return self;
+}
+
+- takeArg: arg
+{
+ object = arg;
+ [self hiddenMethod];
+ return self;
+}
+
+- printHi
+{
+ printf("Hi\n");
+ return self;
+}
+
+- (int) printNumber: (int)number
+{
+ printf("%d\n", number);
+ return number+1;
+}
+
+- (const char *) myDescription
+{
+ return "BasicClass gdb test object";
+}
+
+ at end
+
+ at implementation BasicClass (Private)
+- hiddenMethod
+{
+ return self;
+}
+ at end
+
+int main (int argc, const char *argv[])
+{
+ id obj;
+ obj = [BasicClass new];
+ [obj takeArg: obj];
+ 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;
+}
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.34
diff -u -r1.34 gdb.exp
--- lib/gdb.exp 31 Jan 2003 00:38:33 -0000 1.34
+++ lib/gdb.exp 4 Mar 2003 04:39:26 -0000
@@ -1274,6 +1274,46 @@
}
}
+# This is just like gdb_compile_pthreads, above, except that we always add the
+# objc library for compiling Objective-C programs
+proc gdb_compile_objc {source dest type options} {
+ set built_binfile 0
+ set why_msg "unrecognized error"
+ foreach lib {-lobjc -lpthreads -lpthread -lthread solaris} {
+ # This kind of wipes out whatever libs the caller may have
+ # set. Or maybe theirs will override ours. How infelicitous.
+ if { $lib == "solaris" } {
+ set lib "-lpthread -lposix4"
+ }
+ if { $lib != "-lobjc" } {
+ set lib "-lobjc $lib"
+ }
+ set options_with_lib [concat $options [list libs=$lib quiet]]
+ set ccout [gdb_compile $source $dest $type $options_with_lib]
+ switch -regexp -- $ccout {
+ ".*no posix threads support.*" {
+ set why_msg "missing threads include file"
+ break
+ }
+ ".*cannot open -lpthread.*" {
+ set why_msg "missing runtime threads library"
+ }
+ ".*Can't find library for -lpthread.*" {
+ set why_msg "missing runtime threads library"
+ }
+ {^$} {
+ pass "successfully compiled objc with posix threads test case"
+ set built_binfile 1
+ break
+ }
+ }
+ }
+ if {!$built_binfile} {
+ unsupported "Couldn't compile $source: ${why_msg}"
+ return -1
+ }
+}
+
proc send_gdb { string } {
global suppress_flag;
if { $suppress_flag } {
--------------000409020101050900050304--
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: