Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC]: Better ObjC symbol skipping in decode_line_1
@ 2003-07-31 15:05 Adam Fedor
  2003-07-31 16:32 ` Elena Zannoni
  2003-09-08 13:46 ` David Ayers
  0 siblings, 2 replies; 6+ messages in thread
From: Adam Fedor @ 2003-07-31 15:05 UTC (permalink / raw)
  To: gdb-patches

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

This patch fixes a problem with ObjC symbols not being properly skipped
over during decode_line_1 processing. ObjC symbols can have spaces and
parenthesis in them, so they need special handling, otherwise you get
odd warnings like:

Error in re-setting breakpoint 2:
Function "-[NSObject(NEXTSTEP)" not defined.

or

Error in re-setting breakpoint 2:
Function "" not defined.




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

2003-07-31  Adam Fedor  <fedor@gnu.org>

	* gdb/linespec.c (is_objc_method_format): New function
	(decode_line_1, locate_first_half): Use it.

Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.49.4.1
diff -u -p -r1.49.4.1 linespec.c
--- linespec.c	23 Jul 2003 19:28:35 -0000	1.49.4.1
+++ linespec.c	31 Jul 2003 14:43:47 -0000
@@ -94,6 +94,8 @@ static void build_canonical_line_spec (s
 
 static char *find_toplevel_char (char *s, char c);
 
+static int is_objc_method_format (const char *s);
+
 static struct symtabs_and_lines decode_line_2 (struct symbol *[],
 					       int, int, char ***);
 
@@ -443,6 +445,25 @@ find_toplevel_char (char *s, char c)
   return 0;
 }
 
+/* Determines if the gives string corresponds to an Objective-C method
+   representation, such as -[Foo bar:] or +[Foo bar]. Objective-C symbols
+   are allowed to have spaces and parentheses in them.  */
+
+static int 
+is_objc_method_format (const char *s)
+{
+  if (s == NULL || *s == '\0')
+    return 0;
+  /* Handle arguments with the format FILENAME:SYMBOL.  */
+  if ((s[0] == ':') && (strchr ("+-", s[1]) != NULL) 
+      && (s[2] == '[') && strchr(s, ']'))
+    return 1;
+  /* Handle arguments that are just SYMBOL.  */
+  else if ((strchr ("+-", s[0]) != NULL) && (s[1] == '[') && strchr(s, ']'))
+    return 1;
+  return 0;
+}
+
 /* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
    operate on (ask user if necessary).
    If CANONICAL is non-NULL return a corresponding array of mangled names
@@ -669,8 +690,7 @@ decode_line_1 (char **argptr, int funfir
 
   /* Check if this is an Objective-C method (anything that starts with
      a '+' or '-' and a '[').  */
-  if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL) 
-      && (p[2] == '['))
+  if (is_objc_method_format (p))
     {
       is_objc_method = 1;
       paren_pointer  = NULL; /* Just a category name.  Ignore it.  */
@@ -972,8 +992,7 @@ locate_first_half (char **argptr, int *i
 	}
       /* Check for a colon and a plus or minus and a [ (which
          indicates an Objective-C method) */
-      if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL) 
-	  && (p[2] == '['))
+      if (is_objc_method_format (p))
 	{
 	  break;
 	}

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

* Re: [RFC]: Better ObjC symbol skipping in decode_line_1
  2003-07-31 15:05 [RFC]: Better ObjC symbol skipping in decode_line_1 Adam Fedor
@ 2003-07-31 16:32 ` Elena Zannoni
  2003-09-08 13:46 ` David Ayers
  1 sibling, 0 replies; 6+ messages in thread
From: Elena Zannoni @ 2003-07-31 16:32 UTC (permalink / raw)
  To: Adam Fedor; +Cc: gdb-patches

Adam Fedor writes:
 > This patch fixes a problem with ObjC symbols not being properly skipped
 > over during decode_line_1 processing. ObjC symbols can have spaces and
 > parenthesis in them, so they need special handling, otherwise you get
 > odd warnings like:
 > 
 > Error in re-setting breakpoint 2:
 > Function "-[NSObject(NEXTSTEP)" not defined.
 > 
 > or
 > 
 > Error in re-setting breakpoint 2:
 > Function "" not defined.
 > 
 > 
 > 
 > 2003-07-31  Adam Fedor  <fedor@gnu.org>
 > 
 > 	* gdb/linespec.c (is_objc_method_format): New function
 > 	(decode_line_1, locate_first_half): Use it.

I like this. A function clearly marked as objC only.  Another place
where language specific behavior is necessary. One day we'll move all
these to a proper place....

until then, ok.

elena


 > 
 > Index: linespec.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/linespec.c,v
 > retrieving revision 1.49.4.1
 > diff -u -p -r1.49.4.1 linespec.c
 > --- linespec.c	23 Jul 2003 19:28:35 -0000	1.49.4.1
 > +++ linespec.c	31 Jul 2003 14:43:47 -0000
 > @@ -94,6 +94,8 @@ static void build_canonical_line_spec (s
 >  
 >  static char *find_toplevel_char (char *s, char c);
 >  
 > +static int is_objc_method_format (const char *s);
 > +
 >  static struct symtabs_and_lines decode_line_2 (struct symbol *[],
 >  					       int, int, char ***);
 >  
 > @@ -443,6 +445,25 @@ find_toplevel_char (char *s, char c)
 >    return 0;
 >  }
 >  
 > +/* Determines if the gives string corresponds to an Objective-C method
 > +   representation, such as -[Foo bar:] or +[Foo bar]. Objective-C symbols
 > +   are allowed to have spaces and parentheses in them.  */
 > +
 > +static int 
 > +is_objc_method_format (const char *s)
 > +{
 > +  if (s == NULL || *s == '\0')
 > +    return 0;
 > +  /* Handle arguments with the format FILENAME:SYMBOL.  */
 > +  if ((s[0] == ':') && (strchr ("+-", s[1]) != NULL) 
 > +      && (s[2] == '[') && strchr(s, ']'))
 > +    return 1;
 > +  /* Handle arguments that are just SYMBOL.  */
 > +  else if ((strchr ("+-", s[0]) != NULL) && (s[1] == '[') && strchr(s, ']'))
 > +    return 1;
 > +  return 0;
 > +}
 > +
 >  /* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
 >     operate on (ask user if necessary).
 >     If CANONICAL is non-NULL return a corresponding array of mangled names
 > @@ -669,8 +690,7 @@ decode_line_1 (char **argptr, int funfir
 >  
 >    /* Check if this is an Objective-C method (anything that starts with
 >       a '+' or '-' and a '[').  */
 > -  if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL) 
 > -      && (p[2] == '['))
 > +  if (is_objc_method_format (p))
 >      {
 >        is_objc_method = 1;
 >        paren_pointer  = NULL; /* Just a category name.  Ignore it.  */
 > @@ -972,8 +992,7 @@ locate_first_half (char **argptr, int *i
 >  	}
 >        /* Check for a colon and a plus or minus and a [ (which
 >           indicates an Objective-C method) */
 > -      if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL) 
 > -	  && (p[2] == '['))
 > +      if (is_objc_method_format (p))
 >  	{
 >  	  break;
 >  	}


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

* Re: [RFC]: Better ObjC symbol skipping in decode_line_1
  2003-07-31 15:05 [RFC]: Better ObjC symbol skipping in decode_line_1 Adam Fedor
  2003-07-31 16:32 ` Elena Zannoni
@ 2003-09-08 13:46 ` David Ayers
  2003-09-08 18:43   ` Elena Zannoni
  1 sibling, 1 reply; 6+ messages in thread
From: David Ayers @ 2003-09-08 13:46 UTC (permalink / raw)
  To: Adam Fedor; +Cc: gdb-patches

Adam Fedor wrote:

>This patch fixes a problem with ObjC symbols not being properly skipped
>over during decode_line_1 processing. ObjC symbols can have spaces and
>parenthesis in them, so they need special handling, otherwise you get
>odd warnings like:
>
>Error in re-setting breakpoint 2:
>Function "-[NSObject(NEXTSTEP)" not defined.
>
>or
>
>Error in re-setting breakpoint 2:
>Function "" not defined.
>
>
>
>  
>
>------------------------------------------------------------------------
>
>2003-07-31  Adam Fedor  <fedor@gnu.org>
>
>	* gdb/linespec.c (is_objc_method_format): New function
>	(decode_line_1, locate_first_half): Use it.
>  
>
I know Adam has asked this before, but I'm unsure if there was a 
definite reply, so let me reiterate...

Can this patch go into 6.0? (Please... :-) )

It really makes ObjC support look much better on its debut, and as 
Michael Chastain already mentioned, it has been on mainline for quite 
some time now working beautifully.

Cheers,
David Ayers



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

* Re: [RFC]: Better ObjC symbol skipping in decode_line_1
  2003-09-08 13:46 ` David Ayers
@ 2003-09-08 18:43   ` Elena Zannoni
  2003-09-08 18:58     ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Elena Zannoni @ 2003-09-08 18:43 UTC (permalink / raw)
  To: David Ayers; +Cc: Adam Fedor, gdb-patches

David Ayers writes:
 > Adam Fedor wrote:
 > 
 > >This patch fixes a problem with ObjC symbols not being properly skipped
 > >over during decode_line_1 processing. ObjC symbols can have spaces and
 > >parenthesis in them, so they need special handling, otherwise you get
 > >odd warnings like:
 > >
 > >Error in re-setting breakpoint 2:
 > >Function "-[NSObject(NEXTSTEP)" not defined.
 > >
 > >or
 > >
 > >Error in re-setting breakpoint 2:
 > >Function "" not defined.
 > >
 > >
 > >
 > >  
 > >
 > >------------------------------------------------------------------------
 > >
 > >2003-07-31  Adam Fedor  <fedor@gnu.org>
 > >
 > >	* gdb/linespec.c (is_objc_method_format): New function
 > >	(decode_line_1, locate_first_half): Use it.
 > >  
 > >
 > I know Adam has asked this before, but I'm unsure if there was a 
 > definite reply, so let me reiterate...
 > 
 > Can this patch go into 6.0? (Please... :-) )
 > 
 > It really makes ObjC support look much better on its debut, and as 
 > Michael Chastain already mentioned, it has been on mainline for quite 
 > some time now working beautifully.
 > 
 > Cheers,
 > David Ayers
 > 


I don't think it would do any harm on gdb-6. So it could go in, if
changes are still allowed.

elena


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

* Re: [RFC]: Better ObjC symbol skipping in decode_line_1
  2003-09-08 18:43   ` Elena Zannoni
@ 2003-09-08 18:58     ` Andrew Cagney
  2003-09-09  3:58       ` Adam Fedor
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2003-09-08 18:58 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: David Ayers, Adam Fedor, gdb-patches


> I don't think it would do any harm on gdb-6. So it could go in, if
> changes are still allowed.

ok.

Andrew



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

* Re: [RFC]: Better ObjC symbol skipping in decode_line_1
  2003-09-08 18:58     ` Andrew Cagney
@ 2003-09-09  3:58       ` Adam Fedor
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Fedor @ 2003-09-09  3:58 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Elena Zannoni, David Ayers, gdb-patches

On Mon, 2003-09-08 at 12:58, Andrew Cagney wrote:
> > I don't think it would do any harm on gdb-6. So it could go in, if
> > changes are still allowed.
> 
> ok.
> 


Done.  Also ran the testsuite before and after just to be paranoid.


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

end of thread, other threads:[~2003-09-09  3:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 15:05 [RFC]: Better ObjC symbol skipping in decode_line_1 Adam Fedor
2003-07-31 16:32 ` Elena Zannoni
2003-09-08 13:46 ` David Ayers
2003-09-08 18:43   ` Elena Zannoni
2003-09-08 18:58     ` Andrew Cagney
2003-09-09  3:58       ` Adam Fedor

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