Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Klee Dienes <klee@apple.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: Jim Blandy <jimb@redhat.com>,
	Fernando Nasser <fnasser@redhat.com>,
	Elena Zannoni <ezannoni@redhat.com>,
	gdb-patches@sources.redhat.com
Subject: Re: [rfa] linespec.c, part 3
Date: Mon, 11 Nov 2002 17:15:00 -0000	[thread overview]
Message-ID: <35E8C110-F5C5-11D6-AA35-00039396EEB8@apple.com> (raw)
In-Reply-To: <ro17kfj3hxd.fsf@jackfruit.Stanford.EDU>

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

I'm not sure if you want to deal with this now, or if you'd rather I 
wait until you're done with merging your changes, but I figured I'd 
mention it now while you were looking at set_flags stuff:

The linespec.c changes you posted looked so cool, we couldn't resist 
using them.  So rather than try to deal with the merge conflicts from 
the upcoming stream of linespec.c patches, we decided to re-add our 
Objective-C support to the linespec.c from your branch and use that as 
our linespec.c.

One issue that came up was that the part of our code that decodes an 
Objective-C function needs to have the if-clause removed from the 
breakpoint expression (since Objective-C functions can contain spaces). 
We did this by extending set_flags to pass back a pointer to the 
if-clause, if there was one, and by splitting decode_line_1 into two 
functions, one of which sets the defaults, calls set_flags, strips off 
the if-clause and calls decode_line_2, which does the actual parsing.

The downside to this is that there's yet one more function to be called 
in the parsing process; the upside is that the actual parsing code 
doesn't have to worry about the presence of the if-clause, and that 
decode_line_1 gets even shorter.


[-- Attachment #2: linespec.txt --]
[-- Type: text/plain, Size: 4146 bytes --]

--- /Volumes/Storage/Users/kdienes/source/cygnus.cygnus/src/gdb/linespec.c	Mon Nov 11 16:47:45 2002
+++ linespec.c	Mon Nov 11 17:00:39 2002
@@ -39,7 +39,8 @@
 static void initialize_defaults (struct symtab **default_symtab,
 				 int *default_line);
 
-static void set_flags (char *arg, int *is_quoted, char **paren_pointer);
+static void set_flags (char *arg, int *is_quoted, char **paren_pointer,
+		       char **if_pointer);
 
 static struct symtabs_and_lines decode_indirect (char **argptr);
 
@@ -203,38 +204,33 @@
    from char ** to const char **.  */
 
 struct symtabs_and_lines
-decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
-	       int default_line, char ***canonical)
+decode_line_2 (char **argptr, int funfirstline, struct symtab *default_symtab,
+	       int default_line, char ***canonical,
+	       int is_quoted, char *paren_pointer)
 {
-  /* This is NULL if there are no parens in *ARGPTR, or a pointer to
-     the closing parenthesis if there are parens.  */
-  char *paren_pointer;
-  /* This says whether or not something in *ARGPTR is quoted with
-     completer_quotes (i.e. with single quotes).  */
-  int is_quoted;
   /* If a file name is specified, this is its symtab.  */
   struct symtab *file_symtab = NULL;
   /* This function advances *ARGPTR, but, for error messages, we want
      to remember what it pointed to initially.  */
   char *saved_arg = *argptr;
 
-  /* Defaults have defaults.  */
-
-  initialize_defaults (&default_symtab, &default_line);
-  
-  /* Set various flags.
-   * 'paren_pointer' is important for overload checking, where
-   * we allow things like: 
-   *     (gdb) break c::f(int)
-   */
-
-  set_flags (*argptr, &is_quoted, &paren_pointer);
-
   /* See if arg is *PC.  */
 
   if (**argptr == '*')
     return decode_indirect (argptr);
 
+  /* Is it an Objective-C selector? */
+
+#if 0
+  {
+    struct symtabs_and_lines values;
+    values = decode_objc (argptr, funfirstline, file_symtab,
+			  canonical, saved_arg);
+    if (values.sals != NULL)
+      return values;
+  }
+#endif
+
   /* Check to see if it's a multipart linespec (with colons or
      periods).  */
   {
@@ -289,6 +285,48 @@
 			  paren_pointer, file_symtab);
 }
 
+struct symtabs_and_lines
+decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
+	       int default_line, char ***canonical)
+{
+  /* This says whether or not something in *ARGPTR is quoted with
+     completer_quotes (i.e. with single quotes).  */
+  int is_quoted;
+
+  /* This is NULL if there are no parens in *ARGPTR, or a pointer to
+     the closing parenthesis if there are parens.  */
+  char *paren_pointer;
+
+  /* This is NULL if there is no if-clause at the end of *ARGPTR, or a
+     pointer to the whitespace before the 'if' if there is. */
+  char *if_pointer;
+
+  struct symtabs_and_lines values;
+
+  /* Defaults have defaults.  */
+
+  initialize_defaults (&default_symtab, &default_line);
+  
+  /* Set various flags.
+   * 'paren_pointer' is important for overload checking, where
+   * we allow things like: 
+   *     (gdb) break c::f(int)
+   */
+  
+  set_flags (*argptr, &is_quoted, &paren_pointer, &if_pointer);
+
+  if (if_pointer != NULL)
+    *if_pointer = '\0';
+
+  values = decode_line_2 (argptr, funfirstline, default_symtab, default_line,
+			  canonical, is_quoted, paren_pointer);
+
+  if (if_pointer != NULL)
+    *if_pointer = ' ';
+
+  return values;
+}
+
 \f
 
 /* Now, the helper functions.  */
@@ -326,7 +364,7 @@
 }
 
 static void
-set_flags (char *arg, int *is_quoted, char **paren_pointer)
+set_flags (char *arg, int *is_quoted, char **paren_pointer, char **if_pointer)
 {
   char *if_index;
   char *paren_start;
@@ -372,7 +410,12 @@
   /* Now that we're safely past the has_parens check, put back " if
      (condition)" so outer layers can see it.  */
   if (has_if)
-    *if_index = ' ';
+    {
+      *if_pointer = if_index;
+      *if_index = ' ';
+    }
+  else
+    *if_pointer = NULL;
 }
 
 \f

  reply	other threads:[~2002-11-11 22:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-11 17:15 David Carlton
2002-11-11 17:15 ` Klee Dienes [this message]
2002-11-11 17:15   ` Daniel Jacobowitz
2002-11-11 17:15     ` Klee Dienes
2002-11-11 17:15   ` David Carlton
2002-11-11 17:15 ` Elena Zannoni
2002-11-11 17:15   ` David Carlton
2002-11-11 17:15     ` Elena Zannoni
  -- strict thread matches above, loose matches on Subject: below --
2002-11-11 17:15 David Carlton

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=35E8C110-F5C5-11D6-AA35-00039396EEB8@apple.com \
    --to=klee@apple.com \
    --cc=carlton@math.stanford.edu \
    --cc=ezannoni@redhat.com \
    --cc=fnasser@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@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