Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [MI] Wrong error message when parsing invalid --thread-group
@ 2010-12-08  1:24 Marc Khouzam
  2010-12-08 16:35 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Khouzam @ 2010-12-08  1:24 UTC (permalink / raw)
  To: gdb-patches

Hi,

with the fix of
http://sourceware.org/ml/gdb-patches/2010-12/msg00049.html
that added a missing else clause, another latent (mini) issue came out.

(gdb) interpreter-exec mi "28-break-insert --thread-group ix"
28^error,msg="Invalid value for the '--thread' option"

The error msg says "thread" instead of "thread-group".

Here is a fix.
Ok for HEAD and 7_2? (this is not so important for 7_2)

Thanks

2010-12-07  Marc Khouzam  <marc.khouzam@ericsson.com>

	* mi/mi-parse.c (mi_parse): Wrong error message.
        
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-parse.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-parse.c,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 mi-parse.c
--- gdb/mi/mi-parse.c   6 Dec 2010 14:23:40 -0000       1.21.2.1
+++ gdb/mi/mi-parse.c   8 Dec 2010 01:09:37 -0000
@@ -338,7 +338,8 @@
 
       if (*chp != '\0' && !isspace (*chp))
        error (_("Invalid value for the '%s' option"),
-              start[2] == 't' ? "--thread" : "--frame");
+              start[2] == 'f' ? "--frame" :
+                start[8] == '-' ? "--thread-group" : "--thread");
       while (isspace (*chp))
        chp++;
     }


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

* Re: [MI] Wrong error message when parsing invalid --thread-group
  2010-12-08  1:24 [MI] Wrong error message when parsing invalid --thread-group Marc Khouzam
@ 2010-12-08 16:35 ` Tom Tromey
  2010-12-08 16:53   ` Marc Khouzam
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2010-12-08 16:35 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb-patches

>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:

Marc> (gdb) interpreter-exec mi "28-break-insert --thread-group ix"
Marc> 28^error,msg="Invalid value for the '--thread' option"
Marc> The error msg says "thread" instead of "thread-group".

Thanks for noticing this :)

Marc>         error (_("Invalid value for the '%s' option"),
Marc> -              start[2] == 't' ? "--thread" : "--frame");
Marc> +              start[2] == 'f' ? "--frame" :
Marc> +                start[8] == '-' ? "--thread-group" : "--thread");

I think it would be better to do something using %*s.
This would mean computing a little extra state in the "if" bodies, but
that doesn't seem like a big deal.
I prefer this because it is less obscure and perhaps more future-proof.

Tom


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

* RE: [MI] Wrong error message when parsing invalid --thread-group
  2010-12-08 16:35 ` Tom Tromey
@ 2010-12-08 16:53   ` Marc Khouzam
  2010-12-09 19:22     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Khouzam @ 2010-12-08 16:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


From: Tom Tromey [tromey@redhat.com]

>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:

Marc> (gdb) interpreter-exec mi "28-break-insert --thread-group ix"
Marc> 28^error,msg="Invalid value for the '--thread' option"
Marc> The error msg says "thread" instead of "thread-group".

> Thanks for noticing this :)

Marc>         error (_("Invalid value for the '%s' option"),
Marc> -              start[2] == 't' ? "--thread" : "--frame");
Marc> +              start[2] == 'f' ? "--frame" :
Marc> +                start[8] == '-' ? "--thread-group" : "--thread");

> I think it would be better to do something using %*s.
> This would mean computing a little extra state in the "if" bodies, but
> that doesn't seem like a big deal.
> I prefer this because it is less obscure and perhaps more future-proof.

I have to agree with you there.  How about this?

Marc

2010-12-07  Marc Khouzam  <marc.khouzam@ericsson.com>

	* mi/mi-parse.c (mi_parse): Wrong error message.

### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-parse.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-parse.c,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 mi-parse.c
--- gdb/mi/mi-parse.c   6 Dec 2010 14:23:40 -0000       1.21.2.1
+++ gdb/mi/mi-parse.c   8 Dec 2010 16:50:21 -0000
@@ -292,7 +292,7 @@
      to CLI.  */
   for (;;)
     {
-      char *start = chp;
+      char *option;
       size_t as = sizeof ("--all ") - 1;
       size_t tgs = sizeof ("--thread-group ") - 1;
       size_t ts = sizeof ("--thread ") - 1;
@@ -311,6 +311,7 @@
         }
       if (strncmp (chp, "--thread-group ", tgs) == 0)
        {
+         option = "--thread-group";
          if (parse->thread_group != -1)
            error (_("Duplicate '--thread-group' option"));
          chp += tgs;
@@ -321,6 +322,7 @@
        }
       else if (strncmp (chp, "--thread ", ts) == 0)
        {
+         option = "--thread";
          if (parse->thread != -1)
            error (_("Duplicate '--thread' option"));
          chp += ts;
@@ -328,6 +330,7 @@
        }
       else if (strncmp (chp, "--frame ", fs) == 0)
        {
+         option = "--frame";
          if (parse->frame != -1)
            error (_("Duplicate '--frame' option"));
          chp += fs;
@@ -337,8 +340,7 @@
        break;
 
       if (*chp != '\0' && !isspace (*chp))
-       error (_("Invalid value for the '%s' option"),
-              start[2] == 't' ? "--thread" : "--frame");
+       error (_("Invalid value for the '%s' option"), option);
       while (isspace (*chp))
        chp++;
     }


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

* Re: [MI] Wrong error message when parsing invalid --thread-group
  2010-12-08 16:53   ` Marc Khouzam
@ 2010-12-09 19:22     ` Tom Tromey
  2010-12-09 20:42       ` Marc Khouzam
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2010-12-09 19:22 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb-patches

>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:

Marc> 2010-12-07  Marc Khouzam  <marc.khouzam@ericsson.com>
Marc> 	* mi/mi-parse.c (mi_parse): Wrong error message.

Marc> -      char *start = chp;
Marc> +      char *option;

Make this "const char *".

Ok with that change.

thanks,
Tom


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

* RE: [MI] Wrong error message when parsing invalid --thread-group
  2010-12-09 19:22     ` Tom Tromey
@ 2010-12-09 20:42       ` Marc Khouzam
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Khouzam @ 2010-12-09 20:42 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

From: Tom Tromey [tromey@redhat.com]

>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:

Marc> 2010-12-07  Marc Khouzam  <marc.khouzam@ericsson.com>
Marc>   * mi/mi-parse.c (mi_parse): Wrong error message.

Marc> -      char *start = chp;
Marc> +      char *option;

> Make this "const char *".
>
> Ok with that change.

Thanks!
Committed with the "const" change to HEAD and 7_2.  Patch below.

Marc

2010-12-09  Marc Khouzam  <marc.khouzam@ericsson.com>

	* mi/mi-parse.c (mi_parse): Wrong error message.


### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-parse.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-parse.c,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 mi-parse.c
--- gdb/mi/mi-parse.c   6 Dec 2010 14:23:40 -0000       1.21.2.1
+++ gdb/mi/mi-parse.c   9 Dec 2010 20:31:31 -0000
@@ -292,7 +292,7 @@
      to CLI.  */
   for (;;)
     {
-      char *start = chp;
+      const char *option;
       size_t as = sizeof ("--all ") - 1;
       size_t tgs = sizeof ("--thread-group ") - 1;
       size_t ts = sizeof ("--thread ") - 1;
@@ -311,6 +311,7 @@
         }
       if (strncmp (chp, "--thread-group ", tgs) == 0)
        {
+         option = "--thread-group";
          if (parse->thread_group != -1)
            error (_("Duplicate '--thread-group' option"));
          chp += tgs;
@@ -321,6 +322,7 @@
        }
       else if (strncmp (chp, "--thread ", ts) == 0)
        {
+         option = "--thread";
          if (parse->thread != -1)
            error (_("Duplicate '--thread' option"));
          chp += ts;
@@ -328,6 +330,7 @@
        }
       else if (strncmp (chp, "--frame ", fs) == 0)
        {
+         option = "--frame";
          if (parse->frame != -1)
            error (_("Duplicate '--frame' option"));
          chp += fs;
@@ -337,8 +340,7 @@
        break;
 
       if (*chp != '\0' && !isspace (*chp))
-       error (_("Invalid value for the '%s' option"),
-              start[2] == 't' ? "--thread" : "--frame");
+       error (_("Invalid value for the '%s' option"), option);
       while (isspace (*chp))
        chp++;
     }


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

end of thread, other threads:[~2010-12-09 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08  1:24 [MI] Wrong error message when parsing invalid --thread-group Marc Khouzam
2010-12-08 16:35 ` Tom Tromey
2010-12-08 16:53   ` Marc Khouzam
2010-12-09 19:22     ` Tom Tromey
2010-12-09 20:42       ` Marc Khouzam

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