From 1e92afda99a58f4427293937e49ef1ebe6bb3968 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 12 Jul 2008 16:37:57 +0000 Subject: 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. --- gdb/mi/mi-parse.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gdb/mi/mi-parse.c') 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) -- cgit v1.1