From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17467 invoked by alias); 12 Dec 2013 19:08:22 -0000 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 Received: (qmail 17451 invoked by uid 89); 12 Dec 2013 19:08:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2013 19:08:20 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBCJ8Hdq019555 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Dec 2013 14:08:17 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rBCJ8GjH016042; Thu, 12 Dec 2013 14:08:16 -0500 Message-ID: <52AA099F.4060203@redhat.com> Date: Thu, 12 Dec 2013 19:08:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [RFA] nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing References: <1386070185-8020-1-git-send-email-brobecker@adacore.com> <529E361B.7070807@redhat.com> <20131205105437.GE3175@adacore.com> <52A073CC.3050009@redhat.com> <20131209113333.GC4011@adacore.com> <20131210105624.GA14056@adacore.com> <52A719F1.6060906@redhat.com> <52A71DDC.2080908@redhat.com> <20131212181843.GB3528@adacore.com> In-Reply-To: <20131212181843.GB3528@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-12/txt/msg00510.txt.bz2 On 12/12/2013 06:18 PM, Joel Brobecker wrote: >> Hmm, I had forgotten that. I always though that gdbserver's >> "create inferior" sequence of calling mywait after create_inferior >> to be a little odd, leading to this issue (the FIXME): > [...] >> Changing that would mean changing more than we're willing at >> the moment. We can still work in that direction, and actually >> make gdbserver's win32 initial event handling more similar to >> GDB's. > [...] >> What about this alternative below as preparatory for your >> patch? It makes gdbserver closer to GDB here. >> 2013-12-10 Pedro Alves > [updated patch] >> 2013-12-10 Pedro Alves >> >> * target.c (mywait): Convert TARGET_WAITKIND_LOADED to >> TARGET_WAITKIND_STOPPED. >> * win32-low.c (stopped_at_initial_breakpoint): New global. >> (do_initial_child_stuff): Consume events up to the initial >> breakpoint here. >> (win32_wait): Return the last event if starting up. >> Don't ignore TARGET_WAITKIND_LOADED here. > > I tested the patch on x86-windows, with no regression. > > On top of that patch, I was able to implement the same post-init > trick of looking for ntdll.dll, but not without a couple of surprises: > we don't have FILENAME_CMP nor a "basename" function in gdbserver > at the moment. I worked around the first issue by using strcasecmp, > which is good enough for our purposes. But for the second issue, > I only had a handful of bad options for our current situation: > 1. Import the module from gnulib; but that's never an innocent > change, and also the documentation says that it does not work > for Windows paths; > 2. Import the libiberty module by hand, which itself depends on > their safe-ctype.h module. > 3. Write a quick ad hoc function that implements basename. > > (1) is a non-starter, and I didn't like either of (2) or (3). > In the end, I went for (2) as the quickest option towards testing > the change and sending an RFC patch. Should we go with this approach, > we'll probably want to add the libiberty dependencies through > configure.srv instead of inside OBS. That addition should be > temporary, as the minute we stop looking specifically for ntdll, > and load all mapped dlls through that loop, we'll stop needing > lbasename, and will be able to remove the dependency. > > But the good news is that the patch does fix the problem and adds > the missing ntdll.dll. I've tested the resulting gdbserver through > our testsuite as best as I could, and the results are more than > decent, so I think the change should be relatively good. > > I'll also add comments and documentation, if we decide to move forward. Looks fine to me. Feel free to push my patch, or let me know if you prefer that I push it. It's all the same in a git world. > gdb/gdbserver/ChangeLog: > > * Makefile.in (OBS): Add safe-ctype.o and lbasename.o. > (safe-ctype.o, lbasename.o): New rules. > * win32-low.c (win32_ensure_ntdll_loaded): New function. > (do_initial_child_stuff): Add call to win32_ensure_ntdll_loaded. > > WDYT? It almost makes you want to take the risk of moving forward > with the post-branch proposal now rather than waiting for the branch > ;-). :-) I'd be OK with that. (We can actually leave both methods in place, for Windows versions that don't have psapi.dll. E.g., leave most things as is, and if ntdll.dll is not detected (or generically/alternatively, if any dll was seen without a dll name), and psapi works, discard the dll list, and refetch it after the initial breakpoint is hit. We'd need to make gdb's windows-nat.c not use wait_for_inferior, like I mentioned before.) -- Pedro Alves