From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15053 invoked by alias); 17 Feb 2009 19:45:07 -0000 Received: (qmail 14964 invoked by uid 22791); 17 Feb 2009 19:45:04 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_13,J_CHICKENPOX_37,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Feb 2009 19:44:53 +0000 Received: (qmail 31402 invoked from network); 17 Feb 2009 19:44:50 -0000 Received: from unknown (HELO wind.local) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 17 Feb 2009 19:44:50 -0000 From: Vladimir Prus To: Eli Zaretskii Subject: Re: MI solib notification Date: Tue, 17 Feb 2009 19:49:00 -0000 User-Agent: KMail/1.9.10 Cc: drow@false.org, gdb-patches@sources.redhat.com, nickrob@snap.net.nz References: <200901310010.46738.vladimir@codesourcery.com> <200902172208.37427.vladimir@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_wOxmJZrHuTmVdPy" Message-Id: <200902172244.48437.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-02/txt/msg00360.txt.bz2 --Boundary-00=_wOxmJZrHuTmVdPy Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1658 On Tuesday 17 February 2009 22:28:13 Eli Zaretskii wrote: > > From: Vladimir Prus > > Date: Tue, 17 Feb 2009 22:08:37 +0300 > > Cc: Eli Zaretskii , > > gdb-patches@sources.redhat.com, > > nickrob@snap.net.nz > > > > On Sunday 01 February 2009 21:29:18 Daniel Jacobowitz wrote: > > > On Sun, Feb 01, 2009 at 08:22:28PM +0200, Eli Zaretskii wrote: > > > > That'd be okay as well, although I don't really understand why it is > > > > better than my suggestion. > > > > > > It's not a big difference; I find it more natural to have the output > > > all grouped together and looking similar to GDB's expected output. > > > > I'd prefer this approach to, because that's how the rest of MI docs do it. > > Do we have such long @item's elsewhere in the MI docs? I made a quick > scan and didn't find any, but perhaps I missed something. I don't think we do -- most other long examples are inside @smallexample > > But -- who to I force a break inside @item ? > > You can't, AFAIK. Ouch. > Maybe you could use @itemx for all lines but the > first one, but that would be a kludge. Well, worse. texinfo would render both quoted in '', so it will no longer look anyway like MI output. Seems like we can directly list all fields in @item. How about the attached, instead? > P.S. Please in the future show the original code/Texinfo that prompted > the response above: that was 2 and a half weeks ago, and I no longer > remembered what was this about, nor had the original message in my > mailbox. I had to go to the archives to know what we were talking > about. Sorry, will quote texinfo in future. - Volodya --Boundary-00=_wOxmJZrHuTmVdPy Content-Type: text/x-diff; charset="iso 8859-15"; name="solib_notifications.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="solib_notifications.diff" Content-length: 8906 commit c1091d19fe7c4b02bb5ea623761e4caa0d6fe537 Author: Vladimir Prus Date: Fri Jan 30 20:50:50 2009 +0300 Implement MI notification for library loading/unloading gdb/doc/ * gdb.texinfo (GDB/MI Async Records): Document the =library-loaded and =library-unloaded notifications. gdb/ * mi/mi-interp.c (mi_solib_loaded, mi_solib_unloaded): New. (mi_interpreter_init): Register the above. * solib.c (clear_solib): Notify solib unload. * breakpoint.c (disable_breakpoints_in_unloaded_shlib): Do not disable breakpoints on a.out targets. gdb/testsuite/ * gdb.mi/mi-nonstop.exp (notifs): Adjust for library notifications. * gdb.mi/mi-nsintrall.exp (notifs): Likewise. * gdb.mi/mi-nsmoribund.exp (notifs): Likewise. * lib/mi-support.exp (library_loaded_re): New. (mi_run_cmd, mi_send_resuming_command_raw): Adjust. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 0caedec..bc7c29f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4457,6 +4457,14 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) struct bp_location *loc; int disabled_shlib_breaks = 0; + /* SunOS a.out shared libraries are always mapped, so do not + disable breakpoints; they will only be reported as unloaded + through clear_solib when GDB discards its shared library + list. See clear_solib for more information. */ + if (exec_bfd != NULL + && bfd_get_flavour (exec_bfd) != bfd_target_aout_flavour) + return; + ALL_BP_LOCATIONS (loc) { struct breakpoint *b = loc->owner; diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 6aad520..ce959f5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19912,6 +19912,22 @@ We suggest that in response to this notification, front ends highlight the selected thread and cause subsequent commands to apply to that thread. +@item =library-loaded,... +Reports that a new library file was loaded by the program. This +notification has 4 fields---@var{id}, @var{target-name}, +@var{host-name}, and @var{symbols-loaded}. The @var{id} field is an +opaque identifier of the library. For remote debugging case, +@var{target-name} and @var{host-name} fields give the name of the +library file on the target, and on the host respectively. For native +debugging, both those fields have the same value. The +@var{symbols-loaded} field reports if the debug symbols for this +library are loaded. + +@item =library-unloaded,... +Reports that a library was unloaded by the program. This notification +has 3 fields---@var{id}, @var{target-name} and @var{host-name} with +the same meaning as for the @code{=library-loaded} notification + @end table @node GDB/MI Frame Information diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 95dfdf4..d32638c 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -34,6 +34,7 @@ #include "mi-common.h" #include "observer.h" #include "gdbthread.h" +#include "solist.h" /* These are the interpreter setup, etc. functions for the MI interpreter */ static void mi_execute_command_wrapper (char *cmd); @@ -58,6 +59,8 @@ static void mi_thread_exit (struct thread_info *t); static void mi_new_inferior (int pid); static void mi_inferior_exit (int pid); 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_interpreter_init (int top_level) @@ -86,6 +89,8 @@ mi_interpreter_init (int top_level) observer_attach_inferior_exit (mi_inferior_exit); 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); } return mi; @@ -408,6 +413,31 @@ mi_on_resume (ptid_t ptid) gdb_flush (raw_stdout); } +static void 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\",low-address=\"0x%s\",high-address=\"0x%s\",symbols-loaded=\"%d\"", + solib->so_original_name, solib->so_original_name, + solib->so_name, + paddr (solib->addr_low), paddr (solib->addr_high), + solib->symbols_loaded); + gdb_flush (mi->event_channel); +} + +static void 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); + gdb_flush (mi->event_channel); +} + + extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */ void diff --git a/gdb/solib.c b/gdb/solib.c index cce4f7f..5a28292 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -908,6 +908,7 @@ clear_solib (void) { struct so_list *so = so_list_head; so_list_head = so->next; + observer_notify_solib_unloaded (so); if (so->abfd) remove_target_sections (so->abfd); free_so (so); diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp index 2521ae5..08952b0 100644 --- a/gdb/testsuite/gdb.mi/mi-nonstop.exp +++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp @@ -63,7 +63,7 @@ mi_gdb_test "200-break-insert -t main" ".*" set created "=thread-created,id=\"$decimal\"\r\n" set running "\\*running,thread-id=\"$decimal\"\r\n" -set notifs "($created)*($running)*" +set notifs "($created)*($running)*($library_loaded_re)*" # Note: presently, we skip this test on non-native targets, # so 'run' is OK. As soon as we start to run this on remote diff --git a/gdb/testsuite/gdb.mi/mi-nsintrall.exp b/gdb/testsuite/gdb.mi/mi-nsintrall.exp index b0d7b71..d34b08d 100644 --- a/gdb/testsuite/gdb.mi/mi-nsintrall.exp +++ b/gdb/testsuite/gdb.mi/mi-nsintrall.exp @@ -62,7 +62,7 @@ mi_gdb_test "200-break-insert -t main" ".*" set created "=thread-created,id=\"$decimal\"\r\n" set running "\\*running,thread-id=\"$decimal\"\r\n" -set notifs "($created)*($running)*" +set notifs "($created)*($running)*($library_loaded_re)*" # Note: presently, we skip this test on non-native targets, # so 'run' is OK. As soon as we start to run this on remote diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp index b836c5b..505fc84 100644 --- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp +++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp @@ -62,7 +62,7 @@ mi_gdb_test "200-break-insert -t main" ".*" set created "=thread-created,id=\"$decimal\"\r\n" set running "\\*running,thread-id=\"$decimal\"\r\n" -set notifs "($created)*($running)*" +set notifs "($created)*($running)*($library_loaded_re)*" # Note: presently, we skip this test on non-native targets, # so 'run' is OK. As soon as we start to run this on remote diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index a2aa629..f62c240 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -31,6 +31,7 @@ global mi_inferior_tty_name set MIFLAGS "-i=mi" set thread_selected_re "=thread-selected,id=\"\[0-9+\]\"\r\n" +set library_loaded_re "=library-loaded\[^\n\]+\"\r\n" # # mi_gdb_exit -- exit the GDB, killing the target program if necessary @@ -778,6 +779,7 @@ proc mi_run_cmd {args} { } global mi_gdb_prompt global thread_selected_re + global library_loaded_re if [target_info exists gdb_init_command] { send_gdb "[target_info gdb_init_command]\n"; @@ -819,7 +821,7 @@ proc mi_run_cmd {args} { send_gdb "220-exec-run $args\n" gdb_expect { - -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${thread_selected_re})?${mi_gdb_prompt}" { + -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { } timeout { perror "Unable to start target" @@ -1435,10 +1437,11 @@ proc mi_send_resuming_command_raw {command test} { global mi_gdb_prompt global thread_selected_re + global library_loaded_re send_gdb "$command\n" gdb_expect { - -re "\\^running\r\n\\*running,thread-id=\"\[^\"\]+\"\r\n($thread_selected_re)?${mi_gdb_prompt}" { + -re "\\^running\r\n\\*running,thread-id=\"\[^\"\]+\"\r\n($library_loaded_re)*($thread_selected_re)?${mi_gdb_prompt}" { # Note that lack of 'pass' call here -- this works around limitation # in DejaGNU xfail mechanism. mi-until.exp has this: # --Boundary-00=_wOxmJZrHuTmVdPy--