From patchwork Fri Mar 6 12:58:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Turney X-Patchwork-Id: 5494 Received: (qmail 57247 invoked by alias); 6 Mar 2015 12:58:48 -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 57233 invoked by uid 89); 6 Mar 2015 12:58:47 -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_NONE autolearn=ham version=3.3.2 X-HELO: rgout0505.bt.lon5.cpcloud.co.uk Received: from rgout0505.bt.lon5.cpcloud.co.uk (HELO rgout0505.bt.lon5.cpcloud.co.uk) (65.20.0.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2015 12:58:46 +0000 X-OWM-Source-IP: 31.51.205.191(GB) X-OWM-Env-Sender: jonturney@btinternet.com X-CTCH-RefID: str=0001.0A090203.54F9A483.018A, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Junkmail-Premium-Raw: score=27/50, refid=2.7.2:2015.3.5.111222:17:27.888, ip=31.51.205.191, rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __ANY_URI, URI_ENDS_IN_HTML, __URI_NO_WWW, __URI_NO_PATH, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, __URI_NS, SXL_IP_DYNAMIC[191.205.51.31.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS X-CTCH-Spam: Unknown Received: from localhost.localdomain (31.51.205.191) by rgout05.bt.lon5.cpcloud.co.uk (8.6.122.06) (authenticated as jonturney@btinternet.com) id 54F8184900302324; Fri, 6 Mar 2015 12:58:41 +0000 From: Jon TURNEY To: gdb-patches@sourceware.org Cc: Jon TURNEY Subject: [PATCH] Don't set breakpoints on import stubs on Windows amd64 Date: Fri, 6 Mar 2015 12:58:29 +0000 Message-Id: <1425646709-5216-1-git-send-email-jon.turney@dronecode.org.uk> On Windows i386, setting a breakpoint on a symbol imported from a shared library (after that library is loaded) sets the breakpoint only in the shared library. On Windows amd64, setting a breakpoint on a symbol imported from a shared library (after that library is loaded) sets the breakpoint on both the import stub, and in the shared library. This appears to be due to the minimal symbol for the import stub not being correctly given the type mst_solib_trampoline on Windows amd64, unlike Windows i386. This looks like an error in commit 303c5. It seems from this email [1] that tests were only run on i386 at the time it was commited. [1] https://sourceware.org/ml/gdb-patches/2013-07/msg00100.html Note that as currently written, this is skipping over the character after the "__imp_" (amd64) or "_imp_" (i386) prefix, assuming that it is '_'. This patch removes that behaviour on amd64, and no characters are skipped over, so the name of the import stub to mark as a trampoline is correctly constructed from the import name (e.g the existence of '__imp_foo' implies that 'foo' in the same object should be marked as a trampoline, rather than the probably non-existent 'oo'). I'm not totally sure that asssumption that there will always be an '_' to skip over on i386 is correct. Perhaps if the imported symbol is not C ABI (i.e. it's an assembly routine), it doesn't have an '_' there? Tested on x86_64-pc-cygwin - FAIL: gdb.base/solib-symbol.exp: foo in libmd + PASS: gdb.base/solib-symbol.exp: foo in libmd Unfortunately, several other tests are also affected. Some which failed because setting a breakpoint on an imported symbol said "(2 locations)" now pass. Some which passed now fail because this issue was masking other problems. No change on i686-pc-cygwin. ChangeLog/gdb: 2015-03-04 Jon TURNEY * coffread.c (coff_symfile_read): Fix construction of the name of an import stub symbol from import symbol for amd64. Signed-off-by: Jon TURNEY --- gdb/coffread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 366d828..21e7a77 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -675,7 +675,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) && (strncmp (name, "__imp_", 6) == 0 || strncmp (name, "_imp_", 5) == 0)) { - const char *name1 = (name[1] == '_' ? &name[7] : &name[6]); + const char *name1 = &name[6]; struct bound_minimal_symbol found; found = lookup_minimal_symbol (name1, NULL, objfile);