aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-11-17 16:43:34 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-11-17 16:43:34 +0000
commit66bb093b5faddd76e3e307ce59024ac703e8b892 (patch)
tree4bcb5c077f25e10f7998756e24d2c2ff74891dd8 /gdb/mi
parent8dd4f202ecf146ae7746e10277ddebedc43f42d4 (diff)
downloadgdb-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')
-rw-r--r--gdb/mi/mi-common.h15
-rw-r--r--gdb/mi/mi-interp.c16
-rw-r--r--gdb/mi/mi-main.c37
3 files changed, 53 insertions, 15 deletions
diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h
index e47afd1..8778e74 100644
--- a/gdb/mi/mi-common.h
+++ b/gdb/mi/mi-common.h
@@ -41,4 +41,19 @@ enum async_reply_reason
const char *async_reason_lookup (enum async_reply_reason reason);
+struct mi_interp
+{
+ /* MI's output channels */
+ struct ui_file *out;
+ struct ui_file *err;
+ struct ui_file *log;
+ struct ui_file *targ;
+ struct ui_file *event_channel;
+
+ /* This is the interpreter for the mi... */
+ struct interp *mi2_interp;
+ struct interp *mi1_interp;
+ struct interp *mi_interp;
+};
+
#endif
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index e05b1ad..5aa0e6c 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -31,24 +31,10 @@
#include "mi-cmds.h"
#include "mi-out.h"
#include "mi-console.h"
+#include "mi-common.h"
#include "observer.h"
#include "gdbthread.h"
-struct mi_interp
-{
- /* MI's output channels */
- struct ui_file *out;
- struct ui_file *err;
- struct ui_file *log;
- struct ui_file *targ;
- struct ui_file *event_channel;
-
- /* This is the interpreter for the mi... */
- struct interp *mi2_interp;
- struct interp *mi1_interp;
- struct interp *mi_interp;
-};
-
/* These are the interpreter setup, etc. functions for the MI interpreter */
static void mi_execute_command_wrapper (char *cmd);
static void mi_command_loop (int mi_version);
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);
}