diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2010-02-24 07:51:46 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2010-02-24 07:51:46 +0000 |
commit | a79b8f6ea8c26650ad9b6f29e3df46f86f4f3530 (patch) | |
tree | d5b62817438cabc5c97eed521f7366b4b52a0aab /gdb/mi/mi-interp.c | |
parent | 115d30f9b6746bc41746961a4f4bab5183c6eb80 (diff) | |
download | gdb-a79b8f6ea8c26650ad9b6f29e3df46f86f4f3530.zip gdb-a79b8f6ea8c26650ad9b6f29e3df46f86f4f3530.tar.gz gdb-a79b8f6ea8c26650ad9b6f29e3df46f86f4f3530.tar.bz2 |
Multiexec MI
* breakpoint.c (clear_syscall_counts): Take struct inferior*.
* inferior.c (add_inferior_silent): Notify inferior_added
observer.
(delete_inferior_1): Notify inferior_removed observer.
(exit_inferior_1): Pass inferior, not pid, to observer.
(inferior_appeared): Likewise.
(add_inferior_with_spaces): New.
(add_inferior_command): Use the above.
* inferior.h (delete_inferior_1, add_inferior_with_spaces):
Declare.
* inflow.c (inflow_inferior_exit): Likewise.
* jit.c (jit_inferior_exit_hook): Likewise.
* mi/mi-cmds.c (mi_cmds): Register add-inferior and
remove-inferior.
* mi/mi-cmds.h (mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
* mi/mi-interp.c (mi_inferior_added, mi_inferior_removed): New.
(report_initial_inferior): New.
(mi_inferior_removed): Register the above. Make sure
inferior_added observer is called on the first inferior.
(mi_new_thread, mi_thread_exit): Thread group is now identified by
inferior number, not pid.
(mi_solib_loaded, mi_solib_unloaded): Report which inferiors are
affected.
* mi/mi-main.c (current_context): New.
(proceed_thread_callback): Use typed closure.
Proceed everything if pid is 0. Most implementation split into
(proceed_thread): ... this.
(run_one_inferior): New.
(mi_cmd_exec_continue, mi_cmd_exec_interrupt, mi_cmd_exec_run):
Adjust for multiexec behaviour.
(mi_cmd_add_inferior, mi_cmd_remove_inferior): New.
(mi_cmd_execute): Handle the 'thread-group' option here.
Do some extra checks.
* mi-parse.c (mi_parse): Handle the --all and --thread-group
options.
* mi-parse.h (struct mi_parse): New fields all and thread_group.
Diffstat (limited to 'gdb/mi/mi-interp.c')
-rw-r--r-- | gdb/mi/mi-interp.c | 117 |
1 files changed, 96 insertions, 21 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 41388bb..af225e7 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -56,13 +56,17 @@ static void mi_on_normal_stop (struct bpstats *bs, int print_frame); static void mi_new_thread (struct thread_info *t); static void mi_thread_exit (struct thread_info *t, int silent); -static void mi_inferior_appeared (int pid); -static void mi_inferior_exit (int pid); +static void mi_inferior_added (struct inferior *inf); +static void mi_inferior_appeared (struct inferior *inf); +static void mi_inferior_exit (struct inferior *inf); +static void mi_inferior_removed (struct inferior *inf); static void mi_on_resume (ptid_t ptid); static void mi_solib_loaded (struct so_list *solib); static void mi_solib_unloaded (struct so_list *solib); static void mi_about_to_proceed (void); +static int report_initial_inferior (struct inferior *inf, void *closure); + static void * mi_interpreter_init (int top_level) { @@ -86,13 +90,20 @@ mi_interpreter_init (int top_level) { observer_attach_new_thread (mi_new_thread); observer_attach_thread_exit (mi_thread_exit); + observer_attach_inferior_added (mi_inferior_added); observer_attach_inferior_appeared (mi_inferior_appeared); observer_attach_inferior_exit (mi_inferior_exit); + observer_attach_inferior_removed (mi_inferior_removed); observer_attach_normal_stop (mi_on_normal_stop); observer_attach_target_resumed (mi_on_resume); observer_attach_solib_loaded (mi_solib_loaded); observer_attach_solib_unloaded (mi_solib_unloaded); observer_attach_about_to_proceed (mi_about_to_proceed); + + /* The initial inferior is created before this function is called, so we + need to report it explicitly. Use iteration in case future version + of GDB creates more than one inferior up-front. */ + iterate_over_inferiors (report_initial_inferior, mi); } return mi; @@ -285,10 +296,13 @@ static void mi_new_thread (struct thread_info *t) { struct mi_interp *mi = top_level_interpreter_data (); + struct inferior *inf = find_inferior_pid (ptid_get_pid (t->ptid)); + + gdb_assert (inf); fprintf_unfiltered (mi->event_channel, - "thread-created,id=\"%d\",group-id=\"%d\"", - t->num, t->ptid.pid); + "thread-created,id=\"%d\",group-id=\"i%d\"", + t->num, inf->num); gdb_flush (mi->event_channel); } @@ -296,39 +310,65 @@ static void mi_thread_exit (struct thread_info *t, int silent) { struct mi_interp *mi; + struct inferior *inf; if (silent) return; + inf = find_inferior_pid (ptid_get_pid (t->ptid)); + mi = top_level_interpreter_data (); target_terminal_ours (); fprintf_unfiltered (mi->event_channel, - "thread-exited,id=\"%d\",group-id=\"%d\"", - t->num,t->ptid.pid); + "thread-exited,id=\"%d\",group-id=\"i%d\"", + t->num, inf->num); gdb_flush (mi->event_channel); } -void -mi_inferior_appeared (int pid) +static void +mi_inferior_added (struct inferior *inf) +{ + struct mi_interp *mi = top_level_interpreter_data (); + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, + "thread-group-added,id=\"i%d\"", + inf->num); + gdb_flush (mi->event_channel); +} + +static void +mi_inferior_appeared (struct inferior *inf) { struct mi_interp *mi = top_level_interpreter_data (); target_terminal_ours (); - fprintf_unfiltered (mi->event_channel, "thread-group-created,id=\"%d\"", - pid); + fprintf_unfiltered (mi->event_channel, + "thread-group-started,id=\"i%d\",pid=\"%d\"", + inf->num, inf->pid); gdb_flush (mi->event_channel); } static void -mi_inferior_exit (int pid) +mi_inferior_exit (struct inferior *inf) { struct mi_interp *mi = top_level_interpreter_data (); target_terminal_ours (); - fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"%d\"", - pid); + fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"", + inf->num); gdb_flush (mi->event_channel); } static void +mi_inferior_removed (struct inferior *inf) +{ + struct mi_interp *mi = top_level_interpreter_data (); + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, + "thread-group-removed,id=\"i%d\"", + inf->num); + gdb_flush (mi->event_channel); +} + +static void mi_on_normal_stop (struct bpstats *bs, int print_frame) { /* Since this can be called when CLI command is executing, @@ -489,10 +529,21 @@ mi_solib_loaded (struct so_list *solib) { struct mi_interp *mi = top_level_interpreter_data (); target_terminal_ours (); - fprintf_unfiltered (mi->event_channel, - "library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"%d\"", - solib->so_original_name, solib->so_original_name, - solib->so_name, solib->symbols_loaded); + if (gdbarch_has_global_solist (target_gdbarch)) + fprintf_unfiltered (mi->event_channel, + "library-loaded,id=\"%s\",target-name=\"%s\"," + "host-name=\"%s\",symbols-loaded=\"%d\"", + solib->so_original_name, solib->so_original_name, + solib->so_name, solib->symbols_loaded); + else + fprintf_unfiltered (mi->event_channel, + "library-loaded,id=\"%s\",target-name=\"%s\"," + "host-name=\"%s\",symbols-loaded=\"%d\"," + "thread-group=\"i%d\"", + solib->so_original_name, solib->so_original_name, + solib->so_name, solib->symbols_loaded, + current_inferior ()->num); + gdb_flush (mi->event_channel); } @@ -501,13 +552,37 @@ mi_solib_unloaded (struct so_list *solib) { struct mi_interp *mi = top_level_interpreter_data (); target_terminal_ours (); - fprintf_unfiltered (mi->event_channel, - "library-unloaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\"", - solib->so_original_name, solib->so_original_name, - solib->so_name); + if (gdbarch_has_global_solist (target_gdbarch)) + fprintf_unfiltered (mi->event_channel, + "library-unloaded,id=\"%s\",target-name=\"%s\"," + "host-name=\"%s\"", + solib->so_original_name, solib->so_original_name, + solib->so_name); + else + fprintf_unfiltered (mi->event_channel, + "library-unloaded,id=\"%s\",target-name=\"%s\"," + "host-name=\"%s\",thread-group=\"i%d\"", + solib->so_original_name, solib->so_original_name, + solib->so_name, current_inferior ()->num); + gdb_flush (mi->event_channel); } +static int +report_initial_inferior (struct inferior *inf, void *closure) +{ + /* This function is called from mi_intepreter_init, and since + mi_inferior_added assumes that inferior is fully initialized + and top_level_interpreter_data is set, we cannot call + it here. */ + struct mi_interp *mi = closure; + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, + "thread-group-added,id=\"i%d\"", + inf->num); + gdb_flush (mi->event_channel); + return 0; +} extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */ |