From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87966 invoked by alias); 18 Apr 2019 13:49:25 -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 87918 invoked by uid 89); 18 Apr 2019 13:49:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=debugfile, snippet, HX-Languages-Length:1875, letter X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Apr 2019 13:49:23 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hH7Pm-0004IT-3Q for gdb-patches@sourceware.org; Thu, 18 Apr 2019 09:49:22 -0400 Received: from [176.228.60.248] (port=4160 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hH7Pl-0006oJ-H1 for gdb-patches@sourceware.org; Thu, 18 Apr 2019 09:49:21 -0400 Date: Thu, 18 Apr 2019 13:49:00 -0000 Message-Id: <83ef5ze84y.fsf@gnu.org> From: Eli Zaretskii To: gdb-patches@sourceware.org Subject: Fix lookup of separate debug file on MS-Windows X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00318.txt.bz2 If you put the separate debug file in a global debug directory, GDB on MS-Windows will currently fail to find it. This happens because we obtain the directory to look up the debug file by concatenating the debug directory name with the leading directories of the executable, and the latter includes the drive letter on MS-Windows. So we get an invalid file name like d:/usr/lib/debug/d:/usr/bin/foo.debug The patch below fixes that: --- gdb/symfile.c~0 2019-03-27 00:52:05.000000000 +0200 +++ gdb/symfile.c 2019-04-18 13:19:05.231697600 +0300 @@ -1443,6 +1443,18 @@ find_separate_debug_file (const char *di = dirnames_to_char_ptr_vec (debug_file_directory); gdb::unique_xmalloc_ptr canon_sysroot = gdb_realpath (gdb_sysroot); + /* MS-Windows/MS-DOS don't allow colons in file names; we must strip + the drive letter, so that the file name resulting from splicing + below will be valid. */ + if (HAS_DRIVE_SPEC (dir_notarget)) + { + dir_notarget = STRIP_DRIVE_SPEC (dir_notarget); + /* We will append a slash to debugdir, so remove the leading + slash as well. */ + if (IS_DIR_SEPARATOR (dir_notarget[0])) + dir_notarget++; + } + for (const gdb::unique_xmalloc_ptr &debugdir : debugdir_vec) { debugfile = target_prefix ? "target:" : ""; OK to commit to both branches (with the necessary ChangeLog entries)? Btw, the removal of the leading slash of dir_notarget could potentially benefit Posix systems as well. Or maybe we should not append the literal slash in this snippet from find_separate_debug_file: debugfile = target_prefix ? "target:" : ""; debugfile += debugdir.get (); debugfile += "/"; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< debugfile += dir_notarget; debugfile += debuglink; since AFAICT dir_notarget will always begin with a slash (I added a test for that because I wasn't sure that is indeed so).