On 2018-10-14 8:55 a.m., Jan Vrany wrote: > Whenever a target is connected or disconnected, emit new asynchronous > event =target-connected and =target-disconnected. Events report > both short name and full name of connected or disconnected target. > In addition, =target-connected report a set of target features. > > This allows frontends to keep track of current target and its features > regardless whether target is changed explicitly by MI -target-select > command, CLI target command or implicitly by native target auto-connect. Thanks, I like the idea. A non-RFC version of this would require corresponding tests to be accepted. > @@ -1271,6 +1275,73 @@ mi_user_selected_context_changed (user_selected_what selection) > } > } > > +static void > +mi_target_connected (struct target_ops *target) > +{ > + SWITCH_THRU_ALL_UIS () > + { > + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); > + struct ui_out *mi_uiout; > + > + if (mi == NULL) > + continue; > + > + mi_uiout = top_level_interpreter ()->interp_ui_out (); > + > + target_terminal::scoped_restore_terminal_state term_state; > + target_terminal::ours_for_output (); > + > + fprintf_unfiltered (mi->event_channel,"target-connected"); > + > + mi_uiout->redirect (mi->event_channel); > + > + mi_uiout->field_string ("type", target->shortname()); > + mi_uiout->field_string ("name", target->longname()); > + > + { > + ui_out_emit_list list_emitter (mi_uiout, "features"); > + > + if (mi_async_p ()) > + mi_uiout->field_string (NULL, "async"); > + if (target_can_execute_reverse) > + mi_uiout->field_string (NULL, "reverse"); > + } > + > + mi_uiout->redirect (NULL); > + > + gdb_flush (mi->event_channel); > + } > +} I think there is a (kind of corner-case, but still) bug with using mi_async_p and target_can_execute_reverse. Here are some CLI commands I type in a "gdb -i mi", and the corresponding =target-connected/disconnected event: set mi-async on file test =target-connected,type="exec",name="Local exec file",features=[] start =target-connected,type="native",name="Native process",features=["async"] record =target-connected,type="record-full",name="Process record and replay target",features=["async","reverse"] file =target-disonnected,type="exec",name="Local exec file" file /bin/ls =target-connected,type="exec",name="Local exec file",features=["async","reverse"] That last event says the exec target supports async and reverse, which is wrong. So you would need to write an equivalent of mi_async_p/target_can_execute_reverse to which you can pass a target_ops*, it should not be too hard. Simon &j!z޶םzib֫rnr