Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] [gdb/remote] Reimplement escape_buffer
Date: Mon, 23 Mar 2026 18:20:23 +0100	[thread overview]
Message-ID: <9b8e8980-581f-4e89-a843-b52b0bfaf3b7@suse.de> (raw)
In-Reply-To: <87o6ke8wie.fsf@tromey.com>

On 3/23/26 3:12 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> Reimplement function escape_buffer in gdb/remote.c, to print c_isprint chars
> Tom> like the actual chars, and others like octal escape sequences, getting us
> Tom> instead:
> 
> Tom> -  stb.putstrn (buf, n, '\\');
> 
> Supposedly putstrn does this quoting already.
> Why doesn't that work?  See ui_file::printchar.
> 

Aha, I read the header comment of putstr/putstrn and concluded from it 
that it wouldn't quote such chars.

Anyway, the way to make this work using putstrn is:
...
@@ -10515,6 +10515,7 @@ static std::string
  escape_buffer (const char *buf, int n)
  {
    string_file stb;
+  scoped_restore reset = make_scoped_restore (&sevenbit_strings, true);

    stb.putstrn (buf, n, '\\');
    return stb.release ();
...

> Tom> +      /* Append 3-wide leading zero octal \ooo.  */
> Tom> +      string_appendf (str, "\\%03hho", c);
> 
> I wonder if %hh actually works properly with the gdb format code.
> I don't recall ever seeing this before.
> 

The %hh is supported since c++11, so I suppose this is supported by the 
underlying vsprintf.

Thanks,
- Tom

> Tom


  reply	other threads:[~2026-03-23 17:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21  9:44 Tom de Vries
2026-03-23 14:12 ` Tom Tromey
2026-03-23 17:20   ` Tom de Vries [this message]
2026-03-23 18:28     ` Tom Tromey
2026-03-24 15:34       ` Tom de Vries

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=9b8e8980-581f-4e89-a843-b52b0bfaf3b7@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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