From patchwork Mon Dec 21 15:11:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 10093 Received: (qmail 51545 invoked by alias); 21 Dec 2015 15:12:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51524 invoked by uid 89); 21 Dec 2015 15:12:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=dll, win32, UD:kernel32.dll, kernel32.dll X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 21 Dec 2015 15:12:00 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A0393116506; Mon, 21 Dec 2015 10:11:58 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id P+RluuynuPu6; Mon, 21 Dec 2015 10:11:58 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 380A311668D; Mon, 21 Dec 2015 10:11:58 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 27AE246BAD; Mon, 21 Dec 2015 19:11:54 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: RFA/commit: [win32] cannot automatically find executable file [...] warning at GDB startup Date: Mon, 21 Dec 2015 19:11:51 +0400 Message-Id: <1450710711-29217-1-git-send-email-brobecker@adacore.com> Hi Pedro, The following change... commit 43499ea30db2a866412c86952c7e1d7b158d806f Date: Tue Nov 17 15:17:44 2015 +0000 Subject: [C++/mingw] windows-nat.c casts ... causes a small regression in GDB, where we get the following warning at startup: % gdb C:\[...]\gdb.exe: warning: cannot automatically find executable file or library to read symbols. Use "file" or "dll" command to load executable/libraries directly. GNU gdb (GDB) 7.10.50.20151218-cvs (with AdaCore local changes) [...] (gdb) The warning comes from _initialize_loadable which tries to dynamically load some symbols from kernel32.dll and psapi.dll, and in particular: hm = LoadLibrary ("psapi.dll"); if (hm) { GPA (hm, EnumProcessModules); GPA (hm, GetModuleInformation); GPA (hm, GetModuleFileNameEx); } The problem is that the new GPA macro assumes that the name of the variable we use to point to the function, and the name of its associated symbol are the same. This is mostly the case, except for GetModuleFileNameEx, where the name is provided by the GetModuleFileNameEx_name macro (defined differently depending on whether we are on cygwin or not). As a result, the dynamic resolution for GetModuleFileNameEx returns NULL, and we trip the following check which leads to the warning: if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx) { [...] warning(_("[...]")); } This patch fixes the problem by calling GetProcAddress directly, rather than through the GPA macro, but in a way which hopefully avoids the C++ compilation warning that the previous patch was trying to get rid of. gdb/ChangeLog: * windows-nat.c (_initialize_loadable): Fix computing of GetModuleFileNameEx. I think this patch is fairly straightforward, but I'll wait a few days before pushing it, in case you'd like to suggest another way to handle this issue. Thanks! diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index a7132d6..5256037 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2830,7 +2830,8 @@ _initialize_loadable (void) { GPA (hm, EnumProcessModules); GPA (hm, GetModuleInformation); - GPA (hm, GetModuleFileNameEx); + GetModuleFileNameEx = (GetModuleFileNameEx_ftype *) + GetProcAddress (hm, GetModuleFileNameEx_name); } if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx)