This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Objective-C language support.


The function stabsread_objc_colon should be static to stabsread.c, no?
If that's so, then it should be renamed to something like
`find_name_end', with a comment above the strchr ('[') != 0 case
explaining its relevance to Objective-C.  Since this function gets
called on every symbol, it's not an Objective-C specific function;
only part of it is.

The code needs a comment.  Most of GDB's maintainers don't know
Objective-C, so it would be helpful just to say something like,
"Objective-C symbols can have names like -[foo:bar:baz]:skun

Michael Snyder <msnyder@redhat.com> writes:

> Adam Fedor wrote:
> > 
> > This patch adds Objective-C language support to gdb based upon a patch
> > provided by Apple Computer Inc from their version of gdb. Note that the
> > patch only contains changes to existing files. New files (objc-lang.h,
> > objc-lang.c, objc-exp.y) and a gdb.objc testsuite directory are located at
> > 
> > ftp://ftp.gnustep.org/pub/gnustep/contrib/gdb-objc-patch.tar.gz
> 
> Jim, can you look at this one too?  I can explain it for you -- 
> objective c symbols sometimes contain colons, which will trip up
> the stabs reader unles they're detected and allowed for.
> 
> Adam, I think the function is not used outside of stabsread.c, so 
> how about making it static, droping the "stabsread_" from its name, 
> and omitting the declaration from stabsread.h?
> 
> 
> >         * stabsread.c (stabsread_objc_colon): New function.
> >         (define_symbol): Use it.
> >         * stabsread.h: Declare it.
> 
> > Index: gdb/stabsread.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/stabsread.c,v
> > retrieving revision 1.39
> > diff -u -p -r1.39 stabsread.c
> > --- gdb/stabsread.c     14 Sep 2002 02:09:39 -0000      1.39
> > +++ gdb/stabsread.c     17 Sep 2002 19:31:03 -0000
> > @@ -1273,7 +1273,7 @@ define_symbol (CORE_ADDR valu, char *str
> >                struct objfile *objfile)
> >  {
> >    register struct symbol *sym;
> > -  char *p = (char *) strchr (string, ':');
> > +  char *p = (char *) stabsread_objc_colon (string);
> >    int deftype;
> >    int synonym = 0;
> >    register int i;
> > @@ -2006,7 +2006,8 @@ define_symbol (CORE_ADDR valu, char *str
> >           a typedef for "foo".  Unfortunately, cfront never makes the typedef
> >           when translating C++ into C.  We make the typedef here so that
> >           "ptype foo" works as expected for cfront translated code.  */
> > -      else if (current_subfile->language == language_cplus)
> > +      else if ((current_subfile->language == language_cplus)
> > +              || (current_subfile->language == language_objc))
> >         synonym = 1;
> > 
> >        SYMBOL_TYPE (sym) = read_type (&p, objfile);
> > @@ -5615,6 +5616,30 @@ finish_global_stabs (struct objfile *obj
> >        patch_block_stabs (global_symbols, global_stabs, objfile);
> >        xfree (global_stabs);
> >        global_stabs = NULL;
> > +    }
> > +}
> > +
> > +char *
> > +stabsread_objc_colon (name)
> > +     char *name;
> > +{
> > +  char *s = name;
> > +  if (s[0] == '-' || *s == '+')
> > +    {
> > +      if (s[1] != '[')
> > +       {
> > +         error ("invalid symbol name \"%s\"", name);
> > +       }
> > +      s = strchr (s, ']');
> > +      if (s == NULL)
> > +       {
> > +         error ("invalid symbol name \"%s\"", name);
> > +       }
> > +      return strchr (s, ':');
> > +    }
> > +  else
> > +    {
> > +      return strchr (s, ':');
> >      }
> >  }
> > 
> > Index: gdb/stabsread.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/stabsread.h,v
> > retrieving revision 1.8
> > diff -u -p -r1.8 stabsread.h
> > --- gdb/stabsread.h     18 Jul 2002 17:22:50 -0000      1.8
> > +++ gdb/stabsread.h     17 Sep 2002 19:31:04 -0000
> > @@ -219,6 +219,8 @@ extern struct symbol *ref_search (int);
> >  extern int resolve_cfront_continuation
> >    (struct objfile *objfile, struct symbol *sym, char *p);
> > 
> > +extern char *stabsread_objc_colon (char *name);
> > +
> >  extern void free_header_files (void);
> > 
> >  extern void init_header_files (void);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]