From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id T3PKJ6wZe18fBgAAWB0awg (envelope-from ) for ; Mon, 05 Oct 2020 09:03:40 -0400 Received: by simark.ca (Postfix, from userid 112) id 9B3641EE0F; Mon, 5 Oct 2020 09:03:40 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E06D21E58C for ; Mon, 5 Oct 2020 09:03:39 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A31A93943550; Mon, 5 Oct 2020 13:03:39 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id CA7F9393C846 for ; Mon, 5 Oct 2020 13:03:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CA7F9393C846 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 71F351E58C; Mon, 5 Oct 2020 09:03:33 -0400 (EDT) Subject: Re: [PATCH 2/2] Handle Windows drives in auto-load script paths To: Hannes Domani , "gdb-patches@sourceware.org" References: <20200529150800.2013-1-ssbssa@yahoo.de> <20200529150800.2013-2-ssbssa@yahoo.de> <1cfd024c-3ef9-8dd4-a449-c6cba35a10eb@simark.ca> <795027772.3069099.1601896992593@mail.yahoo.com> From: Simon Marchi Message-ID: <21ccefd0-336b-1bef-89a3-dc103d745795@simark.ca> Date: Mon, 5 Oct 2020 09:03:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <795027772.3069099.1601896992593@mail.yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-10-05 7:23 a.m., Hannes Domani wrote: > Am Montag, 5. Oktober 2020, 04:06:31 MESZ hat Simon Marchi Folgendes geschrieben: > >> Hi Hannes, >> >> On 2020-05-29 11:08 a.m., Hannes Domani via Gdb-patches wrote: >>> Fixes this testsuite fail on Windows: >>> FAIL: gdb.base/auto-load.exp: print $script_loaded >>> >>> Converts the debugfile path from c:/dir/file to /c/dir/file, so it can be >>> appended to the auto-load path. >>> >>> gdb/ChangeLog: >>> >>> 2020-05-29  Hannes Domani  >>> >>>      * auto-load.c (auto_load_objfile_script_1): Convert drive part >>>      of debugfile path on Windows. >>> >>> gdb/doc/ChangeLog: >>> >>> 2020-05-29  Hannes Domani  >>> >>>      * gdb.texinfo: Document Windows drive conversion of >>>      'set auto-load scripts-directory'. >>> --- >>> v2: >>> - Document Windows drive conversion of 'set auto-load scripts-directory'. >>> --- >>>   gdb/auto-load.c    | 7 +++++++ >>>   gdb/doc/gdb.texinfo | 4 ++++ >>>   2 files changed, 11 insertions(+) >>> >>> diff --git a/gdb/auto-load.c b/gdb/auto-load.c >>> index 99bd96b971..88221d9f3d 100644 >>> --- a/gdb/auto-load.c >>> +++ b/gdb/auto-load.c >>> @@ -784,6 +784,13 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname, >>>                         "scripts-directory' path \"%s\".\n"), >>>                   auto_load_dir); >>> >>> +      /* Convert Windows debugfile path from c:/dir/file to /c/dir/file.  */ >>> +      if (HAS_DRIVE_SPEC (debugfile)) >>> +    { >>> +      debugfile_holder = STRIP_DRIVE_SPEC (debugfile); >> >> I looked at this patch a bit before realizing it is already merged.  I >> was going to make a comment about the line above, so I made it a patch >> instead, WDYT? > > Eli later noticed this problem as well, in this thread: > https://sourceware.org/pipermail/gdb-patches/2020-July/170204.html > > >> From 602e996b26d592ecda500ed64adafac30e0e9ce7 Mon Sep 17 00:00:00 2001 >> From: Simon Marchi >> Date: Sun, 4 Oct 2020 22:00:17 -0400 >> Subject: [PATCH] gdb: avoid unnecessary string copy in >> auto_load_objfile_script_1 >> >> Assigning the result of STRIP_DRIVE_SPEC to an std::string creates an >> unnecessary copy of the string.  STRIP_DRIVE_SPEC is defined as: >> >>    #define STRIP_DRIVE_SPEC(f) ((f) + 2) >> >> So if it is passed a "const char *", it returns a "const char *".  We >> could use a "const char *" intermediary variable instead of an >> std::string, or (as implemented in this patch) just use it directly in >> the concatenation right after. >> >> gdb/ChangeLog: >> >>      * auto-load.c (auto_load_objfile_script_1): Don't use >>      debugfile_holder as temporary variable when stripping drive >>      letter. >> >> Change-Id: If2ccc7a156b22100754d9cdf6778ac7eeb93da4c >> --- >> gdb/auto-load.c | 6 ++---- >> 1 file changed, 2 insertions(+), 4 deletions(-) >> >> diff --git a/gdb/auto-load.c b/gdb/auto-load.c >> index 9a51d2f3dc6c..43d007ca5b03 100644 >> --- a/gdb/auto-load.c >> +++ b/gdb/auto-load.c >> @@ -777,10 +777,8 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname, >> >>        /* Convert Windows file name from c:/dir/file to /c/dir/file.  */ >>        if (HAS_DRIVE_SPEC (debugfile)) >> -    { >> -      debugfile_holder = STRIP_DRIVE_SPEC (debugfile); >> -      filename = std::string("\\") + debugfile[0] + debugfile_holder; >> -    } >> +    filename = (std::string("\\") + debugfile[0] >> +            + STRIP_DRIVE_SPEC (debugfile)); >> >>        for (const gdb::unique_xmalloc_ptr &dir : vec) >> >>      { >> -- >> 2.28.0 > > Ummm, LGTM. Thanks, I pushed it. Simon