From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23740 invoked by alias); 9 Jul 2003 20:38:56 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 23733 invoked from network); 9 Jul 2003 20:38:55 -0000 Received: from unknown (HELO mail-out1.apple.com) (17.254.0.52) by sources.redhat.com with SMTP; 9 Jul 2003 20:38:55 -0000 Received: from mailgate2.apple.com (A17-129-100-225.apple.com [17.129.100.225]) by mail-out1.apple.com (8.12.9/8.12.9) with ESMTP id h69KcpiB002181 for ; Wed, 9 Jul 2003 13:38:51 -0700 (PDT) Received: from scv3.apple.com (scv3.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Wed, 9 Jul 2003 13:38:53 -0700 Received: from apple.com (moleja.apple.com [17.201.22.21]) by scv3.apple.com (8.12.9/8.12.9) with ESMTP id h69Jks0M021260; Wed, 9 Jul 2003 13:38:45 -0700 (PDT) In-Reply-To: <062401c34590$97cd09b0$0202040a@catdog> References: <062401c34590$97cd09b0$0202040a@catdog> Mime-Version: 1.0 (Apple Message framework v578) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <55757AD0-B24D-11D7-9281-000393D457E2@apple.com> Content-Transfer-Encoding: 7bit Cc: "Gdb@Sources.Redhat.Com" From: Jason Molenda Subject: Re: [rfc] Print solib events in mi-mode Date: Wed, 09 Jul 2003 20:38:00 -0000 To: Kris Warkentin X-SW-Source: 2003-07/txt/msg00115.txt.bz2 Hi Kris, On Tuesday, July 8, 2003, at 1:36 PM, Kris Warkentin wrote: > What do you think of something like this? When stop-on-solib-events > is set, > this will print the reason as being a shared-lib-event. For what it's worth, at Apple we do something very similar. This section of code in breakpoint.c reads: case bp_shlib_event: /* Did we stop because the user set the stop_on_solib_events variable? (If so, we report this as a generic, "Stopped due to shlib event" message.) */ if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) ui_out_field_string (uiout, "reason", "shlib-event"); else printf_filtered ("Stopped due to shared library event\n"); return PRINT_NOTHING; break; For the case where stop-on-shlibs-added is not set, we have an MI notification that gets posted each time a shared library is loaded. It looks like this to the UI side: =shlibs-updated =shlibs-added,shlib-info=[num="54",name="SKTDrawDocument.ob",kind="- ",dyld-addr="0x271000",reason="dyld",requested- state="?",state="N",path="/Developer/Examples/AppKit/Sketch/build/ Sketch.build/Sketch (Upgraded).build/Objects-normal/ppc/ SKTDrawDocument.ob",slide="",addr="",prefix=""] ~"Re-enabling shared library breakpoints: 1\n" <- =shlibs-added,shlib-info=[num="55",name="SKTGraphic.ob",kind="-",dyld- addr="0x28a000",reason="dyld",requested-state="?",state="N",path="/ Developer/Examples/AppKit/Sketch/build/Sketch.build/Sketch (Upgraded).build/Objects-normal/ppc/ SKTGraphic.ob",slide="",addr="",prefix=""] In our case, this message is emitted by one of our arch-specific files, macosx/macosx-nat-dyld.c, in a function called macosx_solib_add(). > Our Eclipse team wants to be able to set breakpoints in shared > libraries > that aren't loaded yet. If they get notification of shlib-events, > then they > can re-examine the list of loaded libraries and set any breakpoints > that > have been enabled in the project's libs. We handled this problem by creating a new breakpoint command, "future-break" (short: "fb", done in MI as "-break-insert -f ..."). This pushes the logic down in to gdb. On the one hand, it's expensive to have gdb trying to set this breakpoint for every shared library that comes in (when you have a lot of big shared libraries like we do on MacOS X), but at the same time if the IDE is responsible for setting breakpoints in shared libraries then you'll have to stop on each solib add event to set those breakpoints before anything runs... You can see all of this in the above sample; breakpoint #1 was a file:line breakpoint, which was in SKTGraphic.ob. When SKTGraphic.ob was paged in (this is a project using ZeroLink, so each source file is a separate objfile, pulled in at run-time as needed), the breakpoint was set by gdb. The future-break patches were posted at least once in the past along with the save-breakpoints command; I can find a URL ref if anyone cares. Jason > > cheers, > > Kris > > $ cvs diff -u breakpoint.c > Index: breakpoint.c > =================================================================== > RCS file: /cvs/src/src/gdb/breakpoint.c,v > retrieving revision 1.125 > diff -u -r1.125 breakpoint.c > --- breakpoint.c 2 Jul 2003 16:24:00 -0000 1.125 > +++ breakpoint.c 8 Jul 2003 20:32:50 -0000 > @@ -2039,8 +2039,10 @@ > /* Did we stop because the user set the stop_on_solib_events > variable? (If so, we report this as a generic, "Stopped due > to shlib event" message.) */ > - printf_filtered ("Stopped due to shared library event\n"); > - return PRINT_NOTHING; > + ui_out_text (uiout, "\nShared library event "); > + if (ui_out_is_mi_like_p (uiout)) > + ui_out_field_string (uiout, "reason", "shared-lib-event"); > + return PRINT_SRC_ONLY; > break; > > case bp_thread_event: > >