From: Hannes Domani <ssbssa@yahoo.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH 2/2] Handle Windows drives in auto-load script paths
Date: Mon, 5 Oct 2020 11:23:12 +0000 (UTC) [thread overview]
Message-ID: <795027772.3069099.1601896992593@mail.yahoo.com> (raw)
In-Reply-To: <1cfd024c-3ef9-8dd4-a449-c6cba35a10eb@simark.ca>
Am Montag, 5. Oktober 2020, 04:06:31 MESZ hat Simon Marchi <simark@simark.ca> 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 <ssbssa@yahoo.de>
> >
> > * auto-load.c (auto_load_objfile_script_1): Convert drive part
> > of debugfile path on Windows.
> >
> > gdb/doc/ChangeLog:
> >
> > 2020-05-29 Hannes Domani <ssbssa@yahoo.de>
> >
> > * 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 <simon.marchi@polymtl.ca>
> 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<char> &dir : vec)
>
> {
> --
> 2.28.0
Ummm, LGTM.
Hannes
next prev parent reply other threads:[~2020-10-05 11:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200529150800.2013-1-ssbssa.ref@yahoo.de>
2020-05-29 15:07 ` [PATCH v2 1/2] Fix function argument and return value locations Hannes Domani
2020-05-29 15:08 ` [PATCH 2/2] Handle Windows drives in auto-load script paths Hannes Domani
2020-05-29 15:15 ` Eli Zaretskii
2020-10-05 2:06 ` Simon Marchi
2020-10-05 11:23 ` Hannes Domani [this message]
2020-10-05 13:03 ` Simon Marchi
2020-07-08 17:23 ` [PATCH v2 1/2] Fix function argument and return value locations Hannes Domani
2020-10-05 1:50 ` Simon Marchi
2020-10-05 12:32 ` Hannes Domani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=795027772.3069099.1601896992593@mail.yahoo.com \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).