Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@redhat.com>
To: Adam Fedor <fedor@doc.com>
Cc: GDB Patches <gdb-patches@sources.redhat.com>
Subject: Re: [RFA] Add ObjC recognition to linespec.c [5/5]
Date: Mon, 06 Jan 2003 20:32:00 -0000	[thread overview]
Message-ID: <3E19E7CB.F5D1F13B@redhat.com> (raw)
In-Reply-To: <3E164C7B.2070003@doc.com>

Adam Fedor wrote:
> 
> Michael Snyder wrote:
> > Adam Fedor wrote:
> >
> >>I know that linespec has been changing a lot lately, and I'm not sure if
> >>it's finished changing yet. So this is my attempt to insert ObjC
> >>handling into linespec. Actually Klee Dienes really did most of these
> >>changes, and I probably bastardized those as well...
> >>
> >>  -------------------------------------------------------------------------------
> >>2003-01-03  Adam Fedor  <fedor@gnu.org>
> >>
> >>        * linespec.c (decode_objc): New function to decode ObjC calls
> >>        (decode_line_1): Check for ObjC calls (using decode_objc)
> >>
> >>Index: linespec.c
> >>===================================================================
> >>RCS file: /cvs/src/src/gdb/linespec.c,v
> >>retrieving revision 1.32
> >>diff -u -p -r1.32 linespec.c
> >>--- linespec.c  19 Dec 2002 18:56:14 -0000      1.32
> >>+++ linespec.c  3 Jan 2003 22:56:54 -0000
> >>@@ -37,6 +37,11 @@
> >>
> >> extern char *operator_chars (char *, char **);
> >>
> >>+/* From objc-lang.h. Included here to avoid conflict with other prototypes */
> >>+extern char *find_imps (struct symtab *symtab, struct block *block,
> >>+                       char *method, struct symbol **syms, unsigned int *nsym,
> >>+                       unsigned int *ndebug);
> >>+
> >
> >
> > I presume this will go away when you can include objc-lang.h.
> >
> 
> I couldn't include objc-lang.h because linespec.c defines a function
> 'find_methods' which objc-lang also defines. But actually I just
> realized I could just take it out of objc-lang.h, since it's not used
> anywhere else other than objc-lang.c

Good, then I presume your version is static.
Either way, it wouldn't hurt to make its name "objc_find_methods'.

> 
> >
> >> /* Prototypes for local functions */
> >>
> >> static void initialize_defaults (struct symtab **default_symtab,
> >>@@ -48,6 +53,12 @@ static struct symtabs_and_lines decode_i
> >>
> >> static char *locate_first_half (char **argptr, int *is_quote_enclosed);
> >>
> >>+static struct symtabs_and_lines decode_objc (char **argptr,
> >>+                                            int funfirstline,
> >>+                                            struct symtab *file_symtab,
> >>+                                            char ***canonical,
> >>+                                            char *saved_arg);
> >>+
> >
> >
> > I like this -- presumably it keeps a lot of the new code
> > out of poor old decrepit decode_line_1.
> >
> >
> >> static struct symtabs_and_lines decode_compound (char **argptr,
> >>                                                 int funfirstline,
> >>                                                 char ***canonical,
> >>@@ -568,6 +579,7 @@ decode_line_1 (char **argptr, int funfir
> >>   int is_quoted;
> >>   /* Is part of *ARGPTR is enclosed in double quotes?  */
> >>   int is_quote_enclosed;
> >>+  int is_objc_method = 0;
> >>   char *saved_arg = *argptr;
> >>
> >>   init_sal (&val);             /* initialize to zeroes */
> >>@@ -596,6 +608,24 @@ decode_line_1 (char **argptr, int funfir
> >>
> >>   p = locate_first_half (argptr, &is_quote_enclosed);
> >>
> >>+  /* Check if this is an Objective-C method.  */
> >>+  if (*p && (p[0] == ':') && (strchr ("+-", p[1]) != NULL)
> >>+      && (p[2] == '['))
> >>+    {
> >>+      is_objc_method = 1;
> >>+      paren_pointer  = NULL; /* Probably just a category name. Ignore it */
> >>+    }
> >>+
> >>+  /* Is it an Objective-C selector?  */
> >>+
> >>+  {
> >>+    struct symtabs_and_lines values;
> >>+    values = decode_objc (argptr, funfirstline, NULL,
> >>+                         canonical, saved_arg);
> >>+    if (values.sals != NULL)
> >>+      return values;
> >>+  }
> >
> >
> > Was this meant to be an if?  It seems to be a naked block.
> > I'd feel better if there was an if around it, eg. is there
> > a simple way to test for a selector name?  Do I remember
> > that they begin with a unique prefix such as '@'?
> >
> >
> 
> No. Because the user can do things like 'break init' or 'break
> isAnImage', and this will determine that these are really Objective-C
> methods and not regular C functions. It's really just a way to keep the
> variable local to where it is really used.

OK, so if there is a C function init and an objc selector init,
how do we resolve the conflict?  Which one wins?  In other words,
will this un-protected code (not inside an if) ever obscure a
C function when it shouldn't?


> 
> >>+
> >>   /* Does it look like there actually were two parts?  */
> >>
> >>   if ((p[0] == ':' || p[0] == '.') && paren_pointer == NULL)
> >>@@ -669,13 +699,21 @@ decode_line_1 (char **argptr, int funfir
> >>      Find the next token (everything up to end or next whitespace).  */
> >>
> >>   if (**argptr == '$')         /* May be a convenience variable */
> >>-    p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1));       /* One or two $ chars possible */
> >>+    {
> >>+      /* One or two $ chars possible */
> >>+      p = skip_quoted (*argptr + (((*argptr)[1] == '$') ? 2 : 1));
> >>+    }
> >>   else if (is_quoted)
> >>     {
> >>       p = skip_quoted (*argptr);
> >>       if (p[-1] != '\'')
> >>        error ("Unmatched single quote.");
> >>     }
> >>+  else if (is_objc_method)
> >>+    {
> >>+      /* allow word separators in method names for Obj-C */
> >>+      p = skip_quoted_chars (*argptr, NULL, "");
> >>+    }
> >
> >
> > OK, except didn't we decide that "skip_quoted_chars" needs a
> > better name?  One that identifies it with objc?
> >
> 
> We made it more generic. It's now just like skip_quoted, except that you
> can pass the character sets that are to be used (in fact, skip_quoted is
> now defined in terms of skip_quoted_chars).

OK, I guess.


  reply	other threads:[~2003-01-06 20:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03 23:31 Adam Fedor
2003-01-04  1:32 ` Michael Snyder
2003-01-04  2:53   ` Adam Fedor
2003-01-06 20:32     ` Michael Snyder [this message]
2003-01-06 20:23 ` Elena Zannoni
2003-01-11  4:49   ` Adam Fedor
2003-02-19 15:16     ` Elena Zannoni
2003-01-07 13:56 Adam Fedor
2003-01-07 13:59 Adam Fedor

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=3E19E7CB.F5D1F13B@redhat.com \
    --to=msnyder@redhat.com \
    --cc=fedor@doc.com \
    --cc=gdb-patches@sources.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