From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Fix two bugs in gdbserver thread name handling
Date: Fri, 15 Dec 2023 07:59:28 -0700 [thread overview]
Message-ID: <20231215145928.3396394-1-tromey@adacore.com> (raw)
Simon pointed out that my earlier patch to gdbserver's thread name
code:
commit 07b3255c3bae7126a0d679f957788560351eb236
Author: Tom Tromey <tom@tromey.com>
Date: Thu Jul 13 17:28:48 2023 -0600
Filter invalid encodings from Linux thread names
... introduced a regression. Looking at it, I found another bug as
well. This patch fixes both of them.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31153
---
gdbserver/linux-low.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 4aa011c14ec..8cbc7833e53 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7013,11 +7013,13 @@ current_lwp_ptid (void)
}
/* A helper function that copies NAME to DEST, replacing non-printable
- characters with '?'. Returns DEST as a convenience. */
+ characters with '?'. Returns the original DEST as a
+ convenience. */
static const char *
replace_non_ascii (char *dest, const char *name)
{
+ const char *result = dest;
while (*name != '\0')
{
if (!ISPRINT (*name))
@@ -7026,7 +7028,8 @@ replace_non_ascii (char *dest, const char *name)
*dest++ = *name;
++name;
}
- return dest;
+ *dest = '\0';
+ return result;
}
const char *
@@ -7064,8 +7067,8 @@ linux_process_target::thread_name (ptid_t thread)
else if ((errno == EILSEQ || errno == EINVAL)
&& outbuf < &dest[sizeof (dest) - 2])
*outbuf++ = '?';
- *outbuf = '\0';
}
+ *outbuf = '\0';
iconv_close (handle);
return *dest == '\0' ? nullptr : dest;
--
2.43.0
next reply other threads:[~2023-12-15 14:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 14:59 Tom Tromey [this message]
2023-12-15 15:53 ` Simon Marchi
2023-12-15 16:24 ` Tom Tromey
2024-01-09 14:14 ` Tom Tromey
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=20231215145928.3396394-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/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).