Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Add rules for ObjC files
@ 2002-10-03 18:53 Adam Fedor
  2002-10-04  2:25 ` Klee Dienes
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Fedor @ 2002-10-03 18:53 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

This patch adds rules for the ObjC files but does not enable them.

2002-10-03  Adam Fedor  <fedor@gnu.org>

	* Makefile.in (SFILES): Add objc-exp.y objc-lang.c.
	(objc_lang_h): Define.
	(YYFILES): Add objc-exp.tab.c.
	(local-maintainer-clean): Remove objc-exp.tab.c.
	(objc-exp.tab.c, objc-exp.tab.o, objc-lang.o): New target.
	

[-- Attachment #2: objc2.patch --]
[-- Type: text/plain, Size: 3382 bytes --]

? gdb1.ChangeLog
? gdb1.patch
? make2.patch
? objc2.Ch
? objc2.patch
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.268
diff -u -p -r1.268 Makefile.in
--- gdb/Makefile.in	2 Oct 2002 21:33:58 -0000	1.268
+++ gdb/Makefile.in	4 Oct 2002 01:47:49 -0000
@@ -548,6 +548,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	macrotab.c macroexp.c macrocmd.c macroscope.c main.c maint.c \
 	mdebugread.c memattr.c mem-break.c minsyms.c mipsread.c \
 	nlmread.c \
+	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	regcache.c remote.c \
@@ -688,6 +689,7 @@ mipsnbsd_tdep_h = mipsnbsd-tdep.h
 monitor_h = monitor.h
 nbsd_tdep_h = nbsd-tdep.h
 ns32k_tdep_h = ns32k-tdep.h $(osabi_h)
+objc_lang_h = objc-lang.h
 objfiles_h = objfiles.h $(gdb_obstack_h) $(symfile_h)
 ocd_h = ocd.h
 osabi_h = osabi.h
@@ -864,6 +866,7 @@ SUBDIRS = @SUBDIRS@
 
 # For now, shortcut the "configure GDB for fewer languages" stuff.
 YYFILES = c-exp.tab.c \
+	objc-exp.tab.c \
 	ada-exp.tab.c \
 	jv-exp.tab.c \
 	f-exp.tab.c m2-exp.tab.c p-exp.tab.c
@@ -1126,6 +1129,7 @@ local-maintainer-clean:
 	@echo "it deletes files that may require special tools to rebuild."
 	rm -f c-exp.tab.c \
 		ada-lex.c ada-exp.tab.c \
+	        objc-exp.tab.c \
 		jv-exp.tab \
 		f-exp.tab.c m2-exp.tab.c p-exp.tab.c
 	rm -f TAGS $(INFOFILES)
@@ -1221,6 +1225,22 @@ c-exp.tab.c: c-exp.y
 	mv c-exp.new ./c-exp.tab.c
 
 # See comments above ...
+.PRECIOUS: objc-exp.tab.c
+objc-exp.tab.o: objc-exp.tab.c
+objc-exp.tab.c: objc-exp.y
+	$(SHELL) $(YLWRAP) "$(YACC)" $(srcdir)/objc-exp.y y.tab.c objc-exp.tmp -- $(YFLAGS) 
+	-sed -e '/extern.*malloc/d' \
+	     -e '/extern.*realloc/d' \
+	     -e '/extern.*free/d' \
+	     -e '/include.*malloc.h/d' \
+	     -e 's/malloc/xmalloc/g' \
+	     -e 's/realloc/xrealloc/g' \
+	     -e '/^#line.*y.tab.c/d' \
+	  < objc-exp.tmp > objc-exp.new
+	-rm objc-exp.tmp
+	mv objc-exp.new ./objc-exp.tab.c
+
+# See comments above ...
 .PRECIOUS: jv-exp.tab.c
 jv-exp.tab.o: jv-exp.tab.c
 jv-exp.tab.c: jv-exp.y
@@ -1436,6 +1456,10 @@ c-exp.tab.o: c-exp.tab.c $(defs_h) $(gdb
 	$(charset_h) \
 	$(symfile_h) $(objfiles_h)
 
+objc-exp.tab.o: objc-exp.tab.c $(objc_lang_h) $(defs_h) $(expression_h) \
+	$(gdbtypes_h) $(language_h) $(parser_defs_h) $(symtab_h) $(value_h) \
+	$(bfd_h) $(objfiles_h) $(symfile_h)
+
 jv-exp.tab.o: jv-exp.tab.c jv-lang.h $(defs_h) $(expression_h) \
 	$(gdbtypes_h) $(language_h) $(parser_defs_h) $(symtab_h) $(value_h) \
 	$(bfd_h) $(objfiles_h) $(symfile_h)
@@ -1938,6 +1962,11 @@ ns32k-tdep.o: ns32k-tdep.c $(defs_h) $(f
 ns32knbsd-nat.o: ns32knbsd-nat.c $(defs_h) $(inferior_h) $(target_h) \
 	$(gdbcore_h) $(regcache_h)
 ns32knbsd-tdep.o: ns32knbsd-tdep.c $(defs_h) $(ns32k_tdep_h) $(gdb_string_h)
+objc-lang.o: objc-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
+	$(parser_defs_h) $(language_h) $(c_lang_h) $(objc_lang_h) \
+	$(complaints_h) $(value_h) $(symfile_h) $(objfiles_h) \
+	$(gdb_string_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(frame_h) \
+	$(gdb_regex_h) $(regcache_h)
 objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \
 	$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(gdb_stat_h) \
 	$(gdb_obstack_h) $(gdb_string_h) $(breakpoint_h) $(mmalloc_h)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-03 18:53 Add rules for ObjC files Adam Fedor
@ 2002-10-04  2:25 ` Klee Dienes
  2002-10-04  9:07   ` Adam Fedor
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Klee Dienes @ 2002-10-04  2:25 UTC (permalink / raw)
  To: Adam Fedor; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

I'm not sure if this is something you want to hassle with at the  
moment, or if you'd prefer to let it wait as a modification once a  
working version of the Objective-C patches are successfully committed.

But just as a heads-up, I should mention that in more recent versions  
of our GDB, we've folded in all of the Objective-C support directly  
into c-exp.y, and removed objc-exp.y as a file entirely.  Most of  
objc-exp.y was always just an out-of-date copy of c-exp.y, anyway;  
moving the (rather small) changes into c-exp.y directly not only  
allowed us to track changes to the C parser much more smoothly, it  
should also allow for much better Objective-C++ support.

You'll probably want to look at the most recent version of our GDB tree  
(http://www.opensource.apple.com/projects/darwin/6.0/source/other/gdb- 
20020918.tar.gz; no registration or anything similar required), and  
check out our changes to c-exp.y; I've attached them for your  
convenience.


[-- Attachment #2: objc.diffs --]
[-- Type: application/octet-stream, Size: 9129 bytes --]

diff -u -r1.1.1.8 c-exp.y
--- c-exp.y	2002/09/26 20:56:42	1.1.1.8
+++ c-exp.y	2002/10/04 08:31:39
@@ -46,9 +46,11 @@
 #include "parser-defs.h"
 #include "language.h"
 #include "c-lang.h"
+#include "objc-lang.h" /* For Obj-C language constructs. */
 #include "bfd.h" /* Required by objfiles.h.  */
 #include "symfile.h" /* Required by objfiles.h.  */
 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+#include "completer.h" /* For skip_quoted. */
 #include "charset.h"
 
 /* Flag indicating we're dealing with HP-compiled objects */ 
@@ -140,6 +142,7 @@
     struct block *bval;
     enum exp_opcode opcode;
     struct internalvar *ivar;
+    struct objc_class_str class;
 
     struct type **tvec;
     int *ivec;
@@ -173,8 +176,11 @@
    nonterminal "name", which matches either NAME or TYPENAME.  */
 
 %token <sval> STRING
-%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
+%token <sval> NSSTRING		/* Obj-C Foundation "NSString" literal */ 
+%token <sval> SELECTOR		/* Obj-C "@selector" pseudo-operator   */ 
+%token <ssym> NAME		/* BLOCKNAME defined below to give it higher precedence. */
 %token <tsym> TYPENAME
+%token <class> CLASSNAME	/* Obj-C Class name */ 
 %type <sval> name
 %type <ssym> name_not_typename
 %type <tsym> typename
@@ -324,6 +330,71 @@
 			{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
 	;
 
+/* The rules below parse Obj-C message calls of the form:
+   '[' target selector {':' argument}* ']' */
+
+exp	: 	'[' TYPENAME
+			{
+			  CORE_ADDR class;
+
+			  class = lookup_objc_class (copy_name ($2.stoken));
+			  if (class == 0)
+			    error ("%s is not an ObjC Class", 
+				   copy_name ($2.stoken));
+			  write_exp_elt_opcode (OP_LONG);
+			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_longcst ((LONGEST) class);
+			  write_exp_elt_opcode (OP_LONG);
+			  start_msglist();
+			}
+		msglist ']'
+			{ write_exp_elt_opcode (OP_MSGCALL);
+			  end_msglist();
+			  write_exp_elt_opcode (OP_MSGCALL); 
+			}
+	;
+
+exp	:	'[' CLASSNAME
+			{
+			  write_exp_elt_opcode (OP_LONG);
+			  write_exp_elt_type (builtin_type_int);
+			  write_exp_elt_longcst ((LONGEST) $2.class);
+			  write_exp_elt_opcode (OP_LONG);
+			  start_msglist();
+			}
+		msglist ']'
+			{ write_exp_elt_opcode (OP_MSGCALL);
+			  end_msglist();
+			  write_exp_elt_opcode (OP_MSGCALL); 
+			}
+	;
+
+exp	:	'[' exp
+			{ start_msglist(); }
+		msglist ']'
+			{ write_exp_elt_opcode (OP_MSGCALL);
+			  end_msglist();
+			  write_exp_elt_opcode (OP_MSGCALL); 
+			}
+	;
+
+msglist :	name
+			{ add_msglist(&$1, 0); }
+	|	msgarglist
+	;
+
+msgarglist :	msgarg
+	|	msgarglist msgarg
+	;
+
+msgarg	:	name ':' exp
+			{ add_msglist(&$1, 1); }
+	|	':' exp	/* Unnamed argument. */
+			{ add_msglist(0, 1);   }
+	|	',' exp	/* Variable number of arguments. */
+			{ add_msglist(0, 0);   }
+	;
+ 
 exp	:	exp '(' 
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
@@ -499,6 +570,13 @@
 			/* Already written by write_dollar_variable. */
 	;
 
+exp	:	SELECTOR 
+			{
+			  write_exp_elt_opcode (OP_SELECTOR);
+			  write_exp_string ($1);
+			  write_exp_elt_opcode (OP_SELECTOR); }
+
+
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
 			  write_exp_elt_type (builtin_type_int);
@@ -531,6 +609,14 @@
 			  write_exp_elt_opcode (OP_ARRAY); }
 	;
 
+exp     :	NSSTRING	/* ObjC NextStep NSString constant
+				 * of the form '@' '"' string '"'.
+				 */
+			{ write_exp_elt_opcode (OP_NSSTRING);
+			  write_exp_string ($1);
+			  write_exp_elt_opcode (OP_NSSTRING); }
+	;
+
 /* C++.  */
 exp	:	THIS
 			{ write_exp_elt_opcode (OP_THIS);
@@ -804,6 +899,14 @@
 typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
 	:	TYPENAME
 			{ $$ = $1.type; }
+	|	CLASSNAME
+			{
+			  if ($1.type == NULL)
+			    error ("No symbol \"%s\" in current context.", 
+				   copy_name($1.stoken));
+			  else
+			    $$ = $1.type;
+			}
 	|	INT_KEYWORD
 			{ $$ = builtin_type_int; }
 	|	LONG
@@ -951,7 +1054,8 @@
 name	:	NAME { $$ = $1.stoken; }
 	|	BLOCKNAME { $$ = $1.stoken; }
 	|	TYPENAME { $$ = $1.stoken; }
-	|	NAME_OR_INT  { $$ = $1.stoken; }
+	|	CLASSNAME { $$ = $1.stoken; }
+	|	NAME_OR_INT { $$ = $1.stoken; }
 	;
 
 name_not_typename :	NAME
@@ -1239,6 +1343,7 @@
   int c;
   int namelen;
   unsigned int i;
+  int tokchr;
   char *tokstart;
   char *tokptr;
   int tempbufindex;
@@ -1284,7 +1389,7 @@
 	return tokentab2[i].token;
       }
 
-  switch (c = *tokstart)
+  switch (tokchr = *tokstart)
     {
     case 0:
       /* If we were just scanning the result of a macro expansion,
@@ -1331,7 +1436,8 @@
       c = *lexptr++;
       if (c != '\'')
 	{
-	  namelen = skip_quoted (tokstart) - tokstart;
+	  namelen = skip_quoted (tokstart, get_gdb_completer_word_break_characters ())
+	    - tokstart;
 	  if (namelen > 2)
 	    {
 	      lexptr = tokstart + namelen;
@@ -1349,14 +1455,14 @@
     case '(':
       paren_depth++;
       lexptr++;
-      return c;
+      return '(';
 
     case ')':
       if (paren_depth == 0)
 	return 0;
       paren_depth--;
       lexptr++;
-      return c;
+      return ')';
 
     case ',':
       if (comma_terminates
@@ -1364,7 +1470,7 @@
           && ! scanning_macro_expansion ())
 	return 0;
       lexptr++;
-      return c;
+      return ',';
 
     case '.':
       /* Might be a floating point number.  */
@@ -1445,7 +1572,6 @@
     case '^':
     case '~':
     case '!':
-    case '@':
     case '<':
     case '>':
     case '[':
@@ -1457,8 +1583,42 @@
     case '}':
     symbol:
       lexptr++;
-      return c;
+      return tokchr;
 
+    case '@':
+      if (strncmp (tokstart, "@selector", 9) == 0)
+	{
+	  tokptr = strchr (tokstart, '(');
+	  if (tokptr == NULL)
+	    error ("Missing '(' in @selector(...)");
+	  tempbufindex = 0;
+	  /* skip the '(' */
+	  tokptr++;
+	  do {
+	    /* Grow the static temp buffer if necessary, including allocating
+	       the first one on demand. */
+	    if (tempbufindex + 1 >= tempbufsize)
+	      {
+		tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
+	      }
+	    tempbuf[tempbufindex++] = *tokptr++;
+	  } while ((*tokptr != ')') && (*tokptr != '\0'));
+	  if (*tokptr++ != ')')
+	    error ("Missing ')' in @selector(...)");
+	  tempbuf[tempbufindex] = '\0';
+	  yylval.sval.ptr = tempbuf;
+	  yylval.sval.length = tempbufindex;
+	  lexptr = tokptr;
+	  return SELECTOR;
+	}
+      if (tokstart[1] != '"')
+        {
+          lexptr++;
+          return tokchr;
+        }
+      /* Obj-C NSString constant: fall through and parse like STRING. */
+      tokstart++;
+
     case '"':
 
       /* Build the gdb internal form of the input string in tempbuf,
@@ -1522,13 +1682,13 @@
       yylval.sval.ptr = tempbuf;
       yylval.sval.length = tempbufindex;
       lexptr = tokptr;
-      return (STRING);
+      return (tokchr == '@' ? NSSTRING : STRING);
     }
 
-  if (!(c == '_' || c == '$'
-	|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
+  if (!(tokchr == '_' || tokchr == '$' || 
+       (tokchr >= 'a' && tokchr <= 'z') || (tokchr >= 'A' && tokchr <= 'Z')))
     /* We must have come across a bad character (e.g. ';').  */
-    error ("Invalid character '%c' in expression.", c);
+    error ("Invalid character '%c' in expression.", tokchr);
 
   /* It's a name.  See how long it is.  */
   namelen = 0;
@@ -1672,16 +1832,22 @@
     char *tmp = copy_name (yylval.sval);
     struct symbol *sym;
     int is_a_field_of_this = 0;
+    int *need_this;
     int hextype;
 
+    if (current_language->la_language == language_cplus
+	|| current_language->la_language == language_objc
+	|| current_language->la_language == language_objcplus)
+      need_this = &is_a_field_of_this;
+    else
+      need_this = (int *) NULL;
+
     sym = lookup_symbol (tmp, expression_context_block,
-			 VAR_NAMESPACE,
-			 current_language->la_language == language_cplus
-			 ? &is_a_field_of_this : (int *) NULL,
+			 VAR_NAMESPACE, need_this,
 			 (struct symtab **) NULL);
     /* Call lookup_symtab, not lookup_partial_symtab, in case there are
        no psymtabs (coff, xcoff, or some future change to blow away the
-       psymtabs once once symbols are read).  */
+       psymtabs once symbols are read).  */
     if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
       {
 	yylval.ssym.sym = sym;
@@ -1794,6 +1960,23 @@
     if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
       return TYPENAME;
 
+    /* See if it's an Obj-C classname. */
+    if (!sym && should_lookup_objc_class ())  
+      {
+	extern struct symbol *lookup_struct_typedef ();
+	sym = lookup_struct_typedef (tmp, expression_context_block, 1);
+	if (sym)
+	  {
+	    CORE_ADDR Class = lookup_objc_class (tmp);
+	    if (Class)
+	      {
+		yylval.class.class = Class;
+		yylval.class.type = SYMBOL_TYPE (sym);
+		return CLASSNAME;
+	      }
+	  }
+      }
+
     /* Input names that aren't symbols but ARE valid hex numbers,
        when the input radix permits them, can be names or numbers
        depending on the parse.  Note we support radixes > 16 here.  */

[-- Attachment #3: Type: text/plain, Size: 482 bytes --]



One downside to having the changes directly in c-exp.y is that I don't 
know of any good way to conditionalize them; though I am by no means a 
bison guru.

The following diffs are unrelated to Objective-C; I'm attaching them 
just for your reference (the ones in generic.diffs are likely to be 
removed in our sources soon as well; the ones in number-parsing.diffs 
remove a memory leak caused by calling parse_number on invalid, but are 
unrelated to the Objective-C changes).


[-- Attachment #4: number-parsing.diffs --]
[-- Type: application/octet-stream, Size: 3114 bytes --]

Index: c-exp.y
===================================================================
RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/c-exp.y,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 c-exp.y
--- c-exp.y	2002/09/26 20:56:42	1.1.1.8
+++ c-exp.y	2002/10/04 08:33:41
@@ -1384,19 +1490,23 @@
     case '9':
       {
 	/* It's a number.  */
-	int got_dot = 0, got_e = 0, toktype;
+	/* Initialize toktype to anything other than ERROR. */
+	int got_dot = 0, got_e = 0, toktype = FLOAT;
 	register char *p = tokstart;
 	int hex = input_radix > 10;
+	int local_radix = input_radix;
 
-	if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
+	if (tokchr == '0' && (p[1] == 'x' || p[1] == 'X'))
 	  {
 	    p += 2;
 	    hex = 1;
+	    local_radix = 16;
 	  }
-	else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
+	else if (tokchr == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
 	  {
 	    p += 2;
 	    hex = 0;
+	    local_radix = 10;
 	  }
 
 	for (;; ++p)
@@ -1404,25 +1514,42 @@
 	    /* This test includes !hex because 'e' is a valid hex digit
 	       and thus does not indicate a floating point number when
 	       the radix is hex.  */
-	    if (!hex && !got_e && (*p == 'e' || *p == 'E'))
-	      got_dot = got_e = 1;
+
+	    if (!hex && (*p == 'e' || *p == 'E'))
+	      if (got_e)
+		toktype = ERROR;	/* only one 'e' in a float */
+	      else
+		got_e = 1;
 	    /* This test does not include !hex, because a '.' always indicates
 	       a decimal floating point number regardless of the radix.  */
-	    else if (!got_dot && *p == '.')
-	      got_dot = 1;
-	    else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
-		     && (*p == '-' || *p == '+'))
+	    else if (*p == '.')
+	      if (got_dot)
+		toktype = ERROR;	/* only one '.' in a float */
+	      else
+		got_dot = 1;
+	    else if (got_e && (p[-1] == 'e' || p[-1] == 'E') &&
+		    (*p == '-' || *p == '+'))
 	      /* This is the sign of the exponent, not the end of the
 		 number.  */
 	      continue;
-	    /* We will take any letters or digits.  parse_number will
-	       complain if past the radix, or if L or U are not final.  */
-	    else if ((*p < '0' || *p > '9')
-		     && ((*p < 'a' || *p > 'z')
-				  && (*p < 'A' || *p > 'Z')))
-	      break;
+	    /* Always take decimal digits; parse_number handles radix error */
+	    else if (*p >= '0' && *p <= '9')
+	      continue;
+	    /* We will take letters only if hex is true, and only 
+	       up to what the input radix would permit.  FSF was content
+	       to rely on parse_number to validate; but it leaks. */
+	    else if (*p >= 'a' && *p <= 'z') {
+	      if (!hex || *p >= ('a' + local_radix - 10))
+		toktype = ERROR;
+	    }
+	    else if (*p >= 'A' && *p <= 'Z') {
+	      if (!hex || *p >= ('A' + local_radix - 10))
+		toktype = ERROR;
+	    }
+	    else break;
 	  }
-	toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
+	if (toktype != ERROR)
+	  toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
         if (toktype == ERROR)
 	  {
 	    char *err_copy = (char *) alloca (p - tokstart + 1);

[-- Attachment #5: Type: text/plain, Size: 2 bytes --]




[-- Attachment #6: generic.diffs --]
[-- Type: application/octet-stream, Size: 1216 bytes --]

diff -u -r1.1.1.8 c-exp.y
--- c-exp.y	2002/09/26 20:56:42	1.1.1.8
+++ c-exp.y	2002/10/04 08:31:39
@@ -659,7 +745,7 @@
 						 builtin_type_int);
 			    }
 			  else
-			    if (!have_full_symbols () && !have_partial_symbols ())
+			    if (!have_full_symbols () && !have_partial_symbols () && !have_minimal_symbols ())
 			      error ("No symbol table is loaded.  Use the \"file\" command.");
 			    else
 			      error ("No symbol \"%s\" in current context.", name);
@@ -714,7 +809,7 @@
 						     lookup_function_type (builtin_type_int),
 						     builtin_type_int);
 				}
-			      else if (!have_full_symbols () && !have_partial_symbols ())
+			      else if (!have_full_symbols () && !have_partial_symbols () && !have_minimal_symbols ())
 				error ("No symbol table is loaded.  Use the \"file\" command.");
 			      else
 				error ("No symbol \"%s\" in current context.",
@@ -1825,5 +2008,8 @@
   if (prev_lexptr)
     lexptr = prev_lexptr;
 
-  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
+  if (*lexptr == '\0')
+    error("A %s near end of expression.",  (msg ? msg : "error"));
+  else
+    error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }

[-- Attachment #7: Type: text/plain, Size: 409 bytes --]




On Thursday, October 3, 2002, at 09:54 PM, Adam Fedor wrote:

> This patch adds rules for the ObjC files but does not enable them.
>
> 2002-10-03  Adam Fedor  <fedor@gnu.org>
>
> 	* Makefile.in (SFILES): Add objc-exp.y objc-lang.c.
> 	(objc_lang_h): Define.
> 	(YYFILES): Add objc-exp.tab.c.
> 	(local-maintainer-clean): Remove objc-exp.tab.c.
> 	(objc-exp.tab.c, objc-exp.tab.o, objc-lang.o): New target.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04  2:25 ` Klee Dienes
@ 2002-10-04  9:07   ` Adam Fedor
  2002-10-04  9:49   ` Stan Shebs
  2002-10-21 12:08   ` Andrew Cagney
  2 siblings, 0 replies; 10+ messages in thread
From: Adam Fedor @ 2002-10-04  9:07 UTC (permalink / raw)
  To: Klee Dienes; +Cc: gdb-patches

Klee Dienes wrote:
> I'm not sure if this is something you want to hassle with at the  
> moment, or if you'd prefer to let it wait as a modification once a  
> working version of the Objective-C patches are successfully committed.
> 
> But just as a heads-up, I should mention that in more recent versions  
> of our GDB, we've folded in all of the Objective-C support directly  
> into c-exp.y, and removed objc-exp.y as a file entirely.  Most of  
> objc-exp.y was always just an out-of-date copy of c-exp.y, anyway;  
> moving the (rather small) changes into c-exp.y directly not only  
> allowed us to track changes to the C parser much more smoothly, it  
> should also allow for much better Objective-C++ support.
> 

Good point. On second though, I think I will withdraw this patch for 
now.  I'll work on getting the other changes in, and by that time I 
might get around to looking at the most recent Apple changes and maybe 
I'll be be able to convince the gdb gods to switch directly to using 
Objective-C in c-exp.y


-- 
Adam Fedor, Digital Optics Corp.      | I'm glad I hate spinach, because
http://www.doc.com                    | if I didn't, I'd eat it, and you
                                       | know how I hate the stuff.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04  2:25 ` Klee Dienes
  2002-10-04  9:07   ` Adam Fedor
@ 2002-10-04  9:49   ` Stan Shebs
  2002-10-04 13:20     ` Klee Dienes
  2002-10-21 12:08   ` Andrew Cagney
  2 siblings, 1 reply; 10+ messages in thread
From: Stan Shebs @ 2002-10-04  9:49 UTC (permalink / raw)
  To: Klee Dienes; +Cc: Adam Fedor, gdb-patches

Klee Dienes wrote:

> I'm not sure if this is something you want to hassle with at the  
> moment, or if you'd prefer to let it wait as a modification once a  
> working version of the Objective-C patches are successfully committed.
>
> But just as a heads-up, I should mention that in more recent versions  
> of our GDB, we've folded in all of the Objective-C support directly  
> into c-exp.y, and removed objc-exp.y as a file entirely.  Most of  
> objc-exp.y was always just an out-of-date copy of c-exp.y, anyway;  
> moving the (rather small) changes into c-exp.y directly not only  
> allowed us to track changes to the C parser much more smoothly, it  
> should also allow for much better Objective-C++ support.
>
> You'll probably want to look at the most recent version of our GDB 
> tree  
> (http://www.opensource.apple.com/projects/darwin/6.0/source/other/gdb- 
> 20020918.tar.gz; no registration or anything similar required), and  
> check out our changes to c-exp.y; I've attached them for your  
> convenience.
>
> One downside to having the changes directly in c-exp.y is that I don't 
> know of any good way to conditionalize them; though I am by no means a 
> bison guru.

ObjC is supposed to be a strict superset of C, so at least in theory,
extensions don't need to be conditionalized at all, or they can be
disallowed after parsing, if you wanted to have a "strict C mode"
(although I note that the little array@45 extension is always available,
even though it's not valid C).

Stan




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04  9:49   ` Stan Shebs
@ 2002-10-04 13:20     ` Klee Dienes
  2002-10-04 14:49       ` Michael Snyder
  0 siblings, 1 reply; 10+ messages in thread
From: Klee Dienes @ 2002-10-04 13:20 UTC (permalink / raw)
  To: Stan Shebs; +Cc: Adam Fedor, gdb-patches

I definitely agree there's no need to conditionalize them long-term.  I 
just mean there's no way that I know of to check them in with an #ifdef 
WITH_OBJC for the period where the other changes that they depend on 
are still being submitted.  The objc-lang.y approach has the advantage 
that the file can be submitted, and optionally enabled or disabled in 
the Makefile (as I believe Adam was planning to do).

On Friday, October 4, 2002, at 12:48 PM, Stan Shebs wrote:

> ObjC is supposed to be a strict superset of C, so at least in theory,
> extensions don't need to be conditionalized at all, or they can be
> disallowed after parsing, if you wanted to have a "strict C mode"
> (although I note that the little array@45 extension is always 
> available,
> even though it's not valid C).


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04 13:20     ` Klee Dienes
@ 2002-10-04 14:49       ` Michael Snyder
  2002-10-04 15:31         ` Kevin Buettner
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2002-10-04 14:49 UTC (permalink / raw)
  To: Klee Dienes; +Cc: Stan Shebs, Adam Fedor, gdb-patches

Klee Dienes wrote:
> 
> I definitely agree there's no need to conditionalize them long-term.  I
> just mean there's no way that I know of to check them in with an #ifdef
> WITH_OBJC for the period where the other changes that they depend on
> are still being submitted.  The objc-lang.y approach has the advantage
> that the file can be submitted, and optionally enabled or disabled in
> the Makefile (as I believe Adam was planning to do).

I agree that ObjC is to C as C++ is to C, and therefore its grammar
can legitimately go into c-exp.y.  If cxx-like behavior is not disabled
when debugging C, then objc-like behavior shouldn't need to be either
(unles there's a conflict).

But, just to get over the initial hurdle, it might be easier to 
check the grammar in as if it was a whole new language (and thus
can't break C debugging) -- then merge them later.

Michael

> 
> On Friday, October 4, 2002, at 12:48 PM, Stan Shebs wrote:
> 
> > ObjC is supposed to be a strict superset of C, so at least in theory,
> > extensions don't need to be conditionalized at all, or they can be
> > disallowed after parsing, if you wanted to have a "strict C mode"
> > (although I note that the little array@45 extension is always
> > available,
> > even though it's not valid C).


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04 14:49       ` Michael Snyder
@ 2002-10-04 15:31         ` Kevin Buettner
  0 siblings, 0 replies; 10+ messages in thread
From: Kevin Buettner @ 2002-10-04 15:31 UTC (permalink / raw)
  To: Michael Snyder, Klee Dienes; +Cc: Stan Shebs, Adam Fedor, gdb-patches

On Oct 4,  2:47pm, Michael Snyder wrote:

> But, just to get over the initial hurdle, it might be easier to 
> check the grammar in as if it was a whole new language (and thus
> can't break C debugging) -- then merge them later.

I think that's a good idea.

Kevin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-04  2:25 ` Klee Dienes
  2002-10-04  9:07   ` Adam Fedor
  2002-10-04  9:49   ` Stan Shebs
@ 2002-10-21 12:08   ` Andrew Cagney
  2002-10-21 15:40     ` Adam Fedor
  2 siblings, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2002-10-21 12:08 UTC (permalink / raw)
  To: Klee Dienes, Adam Fedor; +Cc: gdb-patches

> Klee Dienes wrote:
> 
> I'm not sure if this is something you want to hassle with at the  moment, or if you'd prefer to let it wait as a modification once a  working version of the Objective-C patches are successfully committed.
> 
> But just as a heads-up, I should mention that in more recent versions  of our GDB, we've folded in all of the Objective-C support directly  into c-exp.y, and removed objc-exp.y as a file entirely.  Most of  objc-exp.y was always just an out-of-date copy of c-exp.y, anyway;  moving the (rather small) changes into c-exp.y directly not only  allowed us to track changes to the C parser much more smoothly, it  should also allow for much better Objective-C++ support.
> 
> You'll probably want to look at the most recent version of our GDB tree  (http://www.opensource.apple.com/projects/darwin/6.0/source/other/gdb- 20020918.tar.gz; no registration or anything similar required), and  check out our changes to c-exp.y; I've attached them for your  convenience.
> 
> One downside to having the changes directly in c-exp.y is that I don't know of any good way to conditionalize them; though I am by no means a bison guru.
> 
> ObjC is supposed to be a strict superset of C, so at least in theory,
> extensions don't need to be conditionalized at all, or they can be
> disallowed after parsing, if you wanted to have a "strict C mode"
> (although I note that the little array@45 extension is always available,
> even though it's not valid C).

(time passes)

(array@45 is documented as a GDB CLI extension).

Keeping the objective C .y separate from the C .y, I think, is a better 
long term strategy.  While it will mean that someone needs to keep the 
two files in sync, it also means that the objective C, C and C++ parsers 
are guarenteed to not stomp on each others toes.

Andrew



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-21 12:08   ` Andrew Cagney
@ 2002-10-21 15:40     ` Adam Fedor
  2002-10-24 20:33       ` Adam Fedor
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Fedor @ 2002-10-21 15:40 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Klee Dienes, gdb-patches

Andrew Cagney wrote:
>> Klee Dienes wrote:
>> ObjC is supposed to be a strict superset of C, so at least in theory,
>> extensions don't need to be conditionalized at all, or they can be
>> disallowed after parsing, if you wanted to have a "strict C mode"
>> (although I note that the little array@45 extension is always available,
>> even though it's not valid C).
> 
> 
> (time passes)
> 
> (array@45 is documented as a GDB CLI extension).
> 
> Keeping the objective C .y separate from the C .y, I think, is a better 
> long term strategy.  While it will mean that someone needs to keep the 
> two files in sync, it also means that the objective C, C and C++ parsers 
> are guarenteed to not stomp on each others toes.
> 

But aren't the C and C++ parsers combined?

It would probably be good to keep the Objective-C parser separate for a 
while until people get used to the idea. However, eventually, gcc will 
support mixing Objective-C and C++ (Objective-C++) and it will be very 
contrived to have separate parsers for each language. The languages are 
quite compatible. The only syntax Objective-C adds is the message call 
syntax:

   [MyObject myMethod: arg1 here: arg2]

and

    @something (where 'something' can be a string or one of a few 
keywords defined in Objective-C)

which looks almost nothing like what you would encounter in C or C++.


-- 
Adam Fedor, Digital Optics Corp.      | I'm glad I hate spinach, because
http://www.doc.com                    | if I didn't, I'd eat it, and you
                                       | know how I hate the stuff.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Add rules for ObjC files
  2002-10-21 15:40     ` Adam Fedor
@ 2002-10-24 20:33       ` Adam Fedor
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Fedor @ 2002-10-24 20:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Cagney, Klee Dienes

  Andrew Cagney wrote:

>> Klee Dienes wrote:
>> ObjC is supposed to be a strict superset of C, so at least in theory,
>> extensions don't need to be conditionalized at all, or they can be
>> disallowed after parsing, if you wanted to have a "strict C mode"
>> (although I note that the little array@45 extension is always available,
>> even though it's not valid C).
>
>
>
> (time passes)
>
> (array@45 is documented as a GDB CLI extension).
>
> Keeping the objective C .y separate from the C .y, I think, is a 
> better long term strategy.  While it will mean that someone needs to 
> keep the two files in sync, it also means that the objective C, C and 
> C++ parsers are guarenteed to not stomp on each others toes.
>

Well since the parsers probably aren't going to be combined yet :-) I'll 
un-withdraw this patch. Can someone approve it?

-- 
Adam Fedor, Digital Optics Corp.      | I'm glad I hate spinach, because
http://www.doc.com                    | if I didn't, I'd eat it, and you
                                       | know how I hate the stuff.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-10-25  3:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-03 18:53 Add rules for ObjC files Adam Fedor
2002-10-04  2:25 ` Klee Dienes
2002-10-04  9:07   ` Adam Fedor
2002-10-04  9:49   ` Stan Shebs
2002-10-04 13:20     ` Klee Dienes
2002-10-04 14:49       ` Michael Snyder
2002-10-04 15:31         ` Kevin Buettner
2002-10-21 12:08   ` Andrew Cagney
2002-10-21 15:40     ` Adam Fedor
2002-10-24 20:33       ` Adam Fedor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox