aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-parse.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-07-12 16:37:57 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-07-12 16:37:57 +0000
commit1e92afda99a58f4427293937e49ef1ebe6bb3968 (patch)
tree557c242bc33c909ac7246c95349ac9bc82a01274 /gdb/mi/mi-parse.c
parentd56b7306e3b1a0d6eccae32f0f25d4a291c77ef2 (diff)
downloadgdb-1e92afda99a58f4427293937e49ef1ebe6bb3968.zip
gdb-1e92afda99a58f4427293937e49ef1ebe6bb3968.tar.gz
gdb-1e92afda99a58f4427293937e49ef1ebe6bb3968.tar.bz2
Implement --thread and --frame.
* gdbthread.h (find_thread_id): Declare. * thread.c (find_thread_id): Make non-static. * mi/mi-main.c (mi_cmd_execute): Switch to the right thread and frame, if necessary. * mi/mi-parse.c (mi_parse): Handle --thread and --frame. * mi/mi-parse.h (strcut mi_parse): New fields thread and frame.
Diffstat (limited to 'gdb/mi/mi-parse.c')
-rw-r--r--gdb/mi/mi-parse.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index a2dc50d..73e04aa 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -150,6 +150,8 @@ mi_parse (char *cmd)
char *chp;
struct mi_parse *parse = XMALLOC (struct mi_parse);
memset (parse, 0, sizeof (*parse));
+ parse->thread = -1;
+ parse->frame = -1;
/* Before starting, skip leading white space. */
while (isspace (*cmd))
@@ -199,6 +201,40 @@ mi_parse (char *cmd)
while (isspace (*chp))
chp++;
+ /* Parse the --thread and --frame options, if present. At present,
+ some important commands, like '-break-*' are implemented by forwarding
+ to the CLI layer directly. We want to parse --thread and --frame
+ here, so as not to leave those option in the string that will be passed
+ to CLI. */
+ for (;;)
+ {
+ char *start = chp;
+ size_t ts = sizeof ("--thread ") - 1;
+ size_t fs = sizeof ("--frame ") - 1;
+ 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);
+ }
+ else
+ break;
+
+ if (*chp != '\0' && !isspace (*chp))
+ error ("Invalid value for the '%s' option",
+ start[2] == 't' ? "--thread" : "--frame");
+ while (isspace (*chp))
+ chp++;
+ }
+
/* For new argv commands, attempt to return the parsed argument
list. */
if (parse->cmd->argv_func != NULL)