Summary: | Missing prompt and error result record for invalid thread option | ||
---|---|---|---|
Product: | gdb | Reporter: | Timo Suoranta <timo.suoranta> |
Component: | mi | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gdb-prs, tromey |
Priority: | P2 | ||
Version: | 7.0 | ||
Target Milestone: | 7.3 | ||
Host: | arm-linux-uclibcgnueabi | Target: | arm-linux-uclibcgnueabi |
Build: | i686-pc-linux-gnu | Last reconfirmed: |
Description
Timo Suoranta
2009-10-13 11:06:09 UTC
Subject: New: Missing prompt and error result record for invalid thread option timo dot suoranta at acrodea dot co dot jp writes: > The following incorrectly spelled command does not return gdb prompt nor error > result record when using mi: > > -var-create --thread 1--frame 0 - * red_vec4 > &"Invalid value for the '--thread' option\n" Yes. I think this patch fixes it and other similar problems. -- Nick http://users.snap.net.nz/~nickrob 2009-10-14 Nick Roberts <nickrob@snap.net.nz> * mi/mi-parse.c (error_message): New function. (mi_parse): Report errors using MI syntax. *** mi-parse.c 03 Jan 2009 18:57:57 +1300 1.17 --- mi-parse.c 14 Oct 2009 13:24:48 +1300 *************** mi_parse_free (struct mi_parse *parse) *** 144,149 **** --- 144,157 ---- xfree (parse); } + static void + error_message (struct mi_parse *parse, const char *msg) + { + fprintf_unfiltered (raw_stdout, "%s^error,msg=\"%s\"\n", + parse->token, msg); + mi_parse_free (parse); + + } struct mi_parse * mi_parse (char *cmd) *************** mi_parse (char *cmd) *** 215,228 **** if (strncmp (chp, "--thread ", ts) == 0) { if (parse->thread != -1) ! error ("Duplicate '--thread' option"); chp += ts; parse->thread = strtol (chp, &chp, 10); } else if (strncmp (chp, "--frame ", fs) == 0) { if (parse->frame != -1) ! error ("Duplicate '--frame' option"); chp += fs; parse->frame = strtol (chp, &chp, 10); } --- 223,242 ---- if (strncmp (chp, "--thread ", ts) == 0) { if (parse->thread != -1) ! { ! error_message (parse, "Duplicate '--thread' option"); ! return NULL; ! } chp += ts; parse->thread = strtol (chp, &chp, 10); } else if (strncmp (chp, "--frame ", fs) == 0) { if (parse->frame != -1) ! { ! error_message (parse, "Duplicate '--frame' option"); ! return NULL; ! } chp += fs; parse->frame = strtol (chp, &chp, 10); } *************** mi_parse (char *cmd) *** 230,237 **** break; if (*chp != '\0' && !isspace (*chp)) ! error ("Invalid value for the '%s' option", ! start[2] == 't' ? "--thread" : "--frame"); while (isspace (*chp)) chp++; } --- 244,258 ---- break; if (*chp != '\0' && !isspace (*chp)) ! { ! /* FIXME: This should be a function call. */ ! fprintf_unfiltered ! (raw_stdout, ! "%s^error,msg=\"Invalid value for the '%s' option\"\n", ! parse->token, start[2] == 't' ? "--thread" : "--frame"); ! mi_parse_free (parse); ! return NULL; ! } while (isspace (*chp)) chp++; } I wonder why is exception thrown from MI code not reported as ^error in the first place. I guess it's better to fix *that*, first. This was fixed by: 2010-12-09 Tom Tromey <tromey@redhat.com> * mi/mi-parse.h (mi_parse): Update. * mi/mi-parse.c (mi_parse_cleanup): New function. (mi_parse): Add 'token' argument. Throw exception on error. * mi/mi-main.c (mi_print_exception): New function. (mi_execute_command): Use mi_print_exception. Catch exceptions from mi_parse. The reason the exception was not working was that the call to mi_parse was not surrounded by a TRY_CATCH. |