Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Adam Fedor <fedor@doc.com>
To: Michael Elizabeth Chastain <mec@shout.net>
Cc: fedor@gnu.org,  fnasser@redhat.com,  msalter@redhat.com,
	 ezannoni@redhat.com,  gdb-gnats@sources.redhat.com,
	 gdb-patches@sources.redhat.com
Subject: Re: [RFA] ObjC Testsuite
Date: Tue, 04 Mar 2003 04:45:00 -0000	[thread overview]
Message-ID: <3E642F7E.5060302@doc.com> (raw)
In-Reply-To: <200303031615.h23GFBc26561@duracef.shout.net>

[-- 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 } {

  reply	other threads:[~2003-03-04  4:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-03 16:15 Michael Elizabeth Chastain
2003-03-04  4:45 ` Adam Fedor [this message]
2003-03-04  6:42 ` richard
2003-03-04 14:54   ` Andrew Cagney
2003-03-05  6:15     ` richard
  -- strict thread matches above, loose matches on Subject: below --
2003-02-20  2:19 [RFA]: " Adam Fedor
2003-03-03  2:47 ` Elena Zannoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E642F7E.5060302@doc.com \
    --to=fedor@doc.com \
    --cc=ezannoni@redhat.com \
    --cc=fedor@gnu.org \
    --cc=fnasser@redhat.com \
    --cc=gdb-gnats@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mec@shout.net \
    --cc=msalter@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox