Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 06/13] gdb: check exact results in the canonicalize selftest
Date: Wed, 21 Oct 2026 11:48:26 -0400	[thread overview]
Message-ID: <de9c3bc9-f804-4984-b338-5fc2f2b711d5@simark.ca> (raw)
In-Reply-To: <87wlrbyt86.fsf@tromey.com>

On 10/21/26 11:21 AM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
> 
> Simon> The canonicalize selftest uses should_be_the_same, which canonicalizes
> Simon> two names and checks that the results are equal.  This doesn't check
> Simon> what the canonical form actually is: both names going through the same
> Simon> wrong conversion would still pass.
> 
> I think the idea here is that gdb shouldn't actually care which form is
> the canonical one.  So I'm wondering if there's some reason you think it
> should?

I think it's nice to see how the function actually transforms its
inputs, it helps understand what it does.  And in a sense documents what
the canonical form actually is, which could be useful.

It also makes the test a bit more robust.   If we have:

  should_be_the_same ("something<void ()>", "something<  void()  >");

And I introduce a bug that makes the function "forget" to print "void",
then both sides will canonicalize to:

  something<()>

The test will still pass, when it could have caught the problem.

> Maybe some kind of comment explaining that the rest of gdb ought not
> care would be sufficient.  As in, if some future developer needs to
> change the canonicalizer to return something else for some reason,
> they'd be free to.

I think that the rest of GDB cares to some extent what the canonical
for is.  The functions that work with canonicalized names as inputs need
to know what they could possibly encounter.

With my patch, if a developer needs to change what the canonical form
is, they will need to update the tests accordingly.  But I think that
it's a good thing, because it will make it clear how the behavior
actually changes.

Simon

  reply	other threads:[~2026-10-21 15:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 16:17 [PATCH 00/13] Make the C++ name parser recognize more char literal forms Simon Marchi
2026-10-20 16:17 ` [PATCH 01/13] gdb: make demangle_parse_info own the memory its tree points into Simon Marchi
2026-10-20 16:17 ` [PATCH 02/13] gdb: remove p_allocated_size parameter of gdb_cplus_demangle_print Simon Marchi
2026-10-20 16:17 ` [PATCH 03/13] gdb: modernize mangled_name_to_comp and cp_class_name_from_physname Simon Marchi
2026-10-20 16:17 ` [PATCH 04/13] gdb: fix crash in "maint canonicalize" without argument Simon Marchi
2026-10-20 16:17 ` [PATCH 05/13] gdb: move C++ name parser parsing selftest to its own test Simon Marchi
2026-10-20 16:17 ` [PATCH 06/13] gdb: check exact results in the canonicalize selftest Simon Marchi
2026-10-21 15:21   ` Tom Tromey
2026-10-21 15:48     ` Simon Marchi [this message]
2026-10-21 16:56       ` Tom Tromey
2026-10-21 17:01         ` Simon Marchi
2026-10-21 17:48           ` Tom Tromey
2026-10-22 16:28             ` Simon Marchi
2026-10-20 16:17 ` [PATCH 07/13] gdb: extract lex_char_literal from cpname_yylex Simon Marchi
2026-10-21 15:22   ` Tom Tromey
2026-10-20 16:17 ` [PATCH 08/13] gdb: remove \^ escape sequence support from C++ name parser Simon Marchi
2026-10-20 16:17 ` [PATCH 09/13] gdb: remove backslash-newline handling from cp_parse_escape Simon Marchi
2026-10-20 16:17 ` [PATCH 10/13] gdb: fix out-of-bounds reads in lex_char_literal Simon Marchi
2026-10-20 16:17 ` [PATCH 11/13] gdb: handle hexadecimal escapes in C++ name parser Simon Marchi
2026-10-20 16:17 ` [PATCH 12/13] gdb: handle character literal encoding prefixes " Simon Marchi
2026-10-20 16:17 ` [PATCH 13/13] gdb: handle universal character names " Simon Marchi

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=de9c3bc9-f804-4984-b338-5fc2f2b711d5@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --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