From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24738 invoked by alias); 13 Jun 2008 22:55:31 -0000 Received: (qmail 24724 invoked by uid 22791); 13 Jun 2008 22:55:29 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 13 Jun 2008 22:55:12 +0000 Received: (qmail 1659 invoked from network); 13 Jun 2008 22:55:10 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 Jun 2008 22:55:10 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFA] win32-nat.c: Add dll names if debugevents is on Date: Sat, 14 Jun 2008 00:16:00 -0000 User-Agent: KMail/1.9.9 Cc: "Pierre Muller" References: <000001c8cd57$c9cf3d30$5d6db790$@u-strasbg.fr> <200806131532.22427.pedro_alves@portugalmail.pt> <000001c8cda0$ec693b40$c53bb1c0$@u-strasbg.fr> In-Reply-To: <000001c8cda0$ec693b40$c53bb1c0$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200806132354.59705.pedro@codesourcery.com> X-IsSubscribed: yes 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: 2008-06/txt/msg00252.txt.bz2 A Friday 13 June 2008 23:00:40, Pierre Muller wrote: > Thanks for the comments > >While you're at it, would it be useful to also include the dll > >load base in the output? > > It=92s a good idea, that I implemented easily, see below. > I choose to use the solib struct to be closer to 'info dll' output. > The only caveat is that it doesn't match the values given by 'info dll' > later > because of the 0x1000 offset added to the start of each Dll, > should I add this 0x1000? I've no strong opinion, handle_unload_dll already erros without ... > It seems like so_original_name is never empty, > because if the dll name is not found, the dll is not recorded at all. > And I finally realized that my code was wrong because > so_original_name and so_name are char array, not pointers... > I nevertheless check both so_name and so_original_name > in that order, without knowing if one can be set and > not the other... See win32_make_so. so_name is always built from so_original_name. > > Here is an updated patch: > This patch surely doesn't work. > @@ -771,6 +774,18 @@ handle_unload_dll (void *dummy) > so->next =3D sodel->next; > if (!so->next) > solib_end =3D so; > + if (sodel->so_name !=3D "\0") > + { > + DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", > + (char *) &(sodel->so_name))); > + } > + else if (sodel->so_original_name !=3D "\0") > + { > + DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", > + (char *) &(sodel->so_original_name))); > + } > + else > + DEBUG_EVENTS (("gdb: Unloading dll.\n")); Beware that DEBUG_EVENTS is not safe to reguarding dangling else's... #define DEBUG_EVENTS(x) if (debug_events) printf_unfiltered x That should be fixed to something like: #define DEBUG_EVENTS(x) \ do { if (debug_events) printf_unfiltered x ; } while (0) Or better, to output to fprintf_unfiltered (gdb_stdlog, ... Otherwise, extra braces are indeed required. > + if (sodel->so_name !=3D "\0") Anyway, these comparision aren't doing what you think they are. You are still comparing addresses. To check for empty string, use something like: if (*sodel->so_name =3D=3D '\0') > + DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", > + (char *) &(sodel->so_name))); And should print a char array like you were doing before: DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", sodel->so_name)); But, if so_name is built from so_original_name, and you're printing just so_name in the load event, why extra that churn in the unload event?= =20=20 Just: + DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", + sodel->so_name)); Would be enough, I guess. --=20 Pedro Alves