* Re: [RFA] ObjC Testsuite
2003-03-03 16:15 [RFA] ObjC Testsuite Michael Elizabeth Chastain
@ 2003-03-04 4:45 ` Adam Fedor
2003-03-04 6:42 ` richard
1 sibling, 0 replies; 7+ messages in thread
From: Adam Fedor @ 2003-03-04 4:45 UTC (permalink / raw)
To: Michael Elizabeth Chastain
Cc: fedor, fnasser, msalter, ezannoni, gdb-gnats, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 851 bytes --]
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.
[-- Attachment #2: suite1.patch --]
[-- Type: text/plain, Size: 11350 bytes --]
2003-03-03 Adam Fedor <fedor@gnu.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@gnu.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>
+
+@interface BasicClass: Object
+{
+ id object;
+}
++ newWithArg: arg;
+- doIt;
+- takeArg: arg;
+- printHi;
+- (int) printNumber: (int)number;
+- (const char *) myDescription;
+@end
+
+@interface BasicClass (Private)
+- hiddenMethod;
+@end
+
+@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";
+}
+
+@end
+
+@implementation BasicClass (Private)
+- hiddenMethod
+{
+ return self;
+}
+@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 } {
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFA] ObjC Testsuite
2003-03-03 16:15 [RFA] ObjC Testsuite Michael Elizabeth Chastain
2003-03-04 4:45 ` Adam Fedor
@ 2003-03-04 6:42 ` richard
2003-03-04 14:54 ` Andrew Cagney
1 sibling, 1 reply; 7+ messages in thread
From: richard @ 2003-03-04 6:42 UTC (permalink / raw)
To: Michael Elizabeth Chastain
Cc: gdb-patches, gdb-gnats, ezannoni, msalter, fnasser, fedor
On Monday, March 3, 2003, at 04:15 pm, Michael Elizabeth Chastain
wrote:
>
> 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.
I've been lurking following this process and trying to figure out
what's going
on, and I wholeheartedly agree that sorting out a few individuals to get
things moving makes sense.
I was getting increasingly worried that, while stuff is being reviewed,
none
of it actually seems to be getting into CVS ... even one of the
earliest patches
to simply add the existing objc code into the configure/make process and
activate it (which I think one reviewer said was a no-brainer or
something
similar) is still outstanding.
I've noticed that the objc patches supplied in the last few months have
already begun to bit-rot.
Surely to avoid that sort of thing, the turnaround between submission
for review and addition to CVS needs to be closer to three days than
three months for most changes. I'm very aware that the sheer number
of patches submitted for review for gdb overall will be putting a lot of
load on reviewers, so hopefully having one or two people making a
particular effort to focus on the ObjC code will help solve this
problem.
Incidentally, I have Adams patches (with some modifications to account
for the recent removal of SYMBOL_NAME) running on debian intel and ppc
successfully, so if I can herlp in any way I'm willing.
^ permalink raw reply [flat|nested] 7+ messages in thread