aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-main.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-main.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-main.c')
-rw-r--r--gdb/mi/mi-main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index a82d2f0..f829a93 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1052,11 +1052,42 @@ static void
mi_cmd_execute (struct mi_parse *parse)
{
struct cleanup *cleanup;
+ char *thread_str;
+ char *frame_str;
+ int thread;
+ int i;
free_all_values ();
current_token = xstrdup (parse->token);
cleanup = make_cleanup (free_current_contents, &current_token);
+ if (parse->frame != -1 && parse->thread == -1)
+ error (_("Cannot specify --frame without --thread"));
+
+ if (parse->thread != -1)
+ {
+ struct thread_info *tp = find_thread_id (parse->thread);
+ if (!tp)
+ error (_("Invalid thread id: %d"), parse->thread);
+
+ if (non_stop)
+ context_switch_to (tp->ptid);
+ else
+ switch_to_thread (tp->ptid);
+ }
+
+ if (parse->frame != -1)
+ {
+ struct frame_info *fid;
+ int frame = parse->frame;
+ fid = find_relative_frame (get_current_frame (), &frame);
+ if (frame == 0)
+ /* find_relative_frame was successful */
+ select_frame (fid);
+ else
+ error (_("Invalid frame id: %s"), frame_str);
+ }
+
if (parse->cmd->argv_func != NULL)
{
if (target_can_async_p ()
@@ -1093,6 +1124,7 @@ mi_cmd_execute (struct mi_parse *parse)
error_stream (stb);
}
}
+
parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
}
else if (parse->cmd->cli.cmd != 0)