diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-17 16:43:34 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-17 16:43:34 +0000 |
commit | 66bb093b5faddd76e3e307ce59024ac703e8b892 (patch) | |
tree | 4bcb5c077f25e10f7998756e24d2c2ff74891dd8 /gdb/mi/mi-main.c | |
parent | 8dd4f202ecf146ae7746e10277ddebedc43f42d4 (diff) | |
download | gdb-66bb093b5faddd76e3e307ce59024ac703e8b892.zip gdb-66bb093b5faddd76e3e307ce59024ac703e8b892.tar.gz gdb-66bb093b5faddd76e3e307ce59024ac703e8b892.tar.bz2 |
Implement =thread-selected notification.
* mi/mi-common.h (struct mi_interp): New, moved from ...
* mi/mi-interp.c: ...here.
* mi/mi-main.c (mi_execute_command): If the thread changed
as result of command, report that.
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r-- | gdb/mi/mi-main.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 6e5511f..7f5ec2f 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -44,6 +44,7 @@ #include "gdb.h" #include "frame.h" #include "mi-main.h" +#include "mi-common.h" #include "language.h" #include "valprint.h" #include "inferior.h" @@ -1203,6 +1204,7 @@ mi_execute_command (char *cmd, int from_tty) if (command != NULL) { struct gdb_exception result; + ptid_t previous_ptid = inferior_ptid; if (do_timings) { @@ -1227,6 +1229,41 @@ mi_execute_command (char *cmd, int from_tty) mi_out_rewind (uiout); } + if (/* The notifications are only output when the top-level + interpreter (specified on the command line) is MI. */ + ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())) + /* Don't try report anything if there are no threads -- + the program is dead. */ + && thread_count () != 0 + /* -thread-select explicitly changes thread. If frontend uses that + internally, we don't want to emit =thread-selected, since + =thread-selected is supposed to indicate user's intentions. */ + && strcmp (command->command, "thread-select") != 0) + { + struct mi_interp *mi = top_level_interpreter_data (); + struct thread_info *ti = inferior_thread (); + int report_change; + + if (command->thread == -1) + { + report_change = !ptid_equal (previous_ptid, null_ptid) + && !ptid_equal (inferior_ptid, previous_ptid); + } + else + { + report_change = (ti->num != command->thread); + } + + if (report_change) + { + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, + "thread-selected,id=\"%d\"", + ti->num); + gdb_flush (mi->event_channel); + } + } + mi_parse_free (command); } |