Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 08/13] gdb: remove \^ escape sequence support from C++ name parser
Date: Tue, 20 Oct 2026 12:17:30 -0400	[thread overview]
Message-ID: <20261020162054.2140671-9-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261020162054.2140671-1-simon.marchi@efficios.com>

cp_parse_escape, used by the C++ name parser to parse escape sequences
in character literals, accepts "\^" followed by a character.  This
denotes a control character, as in caret notation: "\^A" is 1, "\^?" is
0177 (DEL).

This is not valid C or C++, no known compiler (gcc or clang) nor the
demangler produce it in symbol names, so I don't think that the C++ name
parser needs to accept it.

This support is a leftover from GDB's old generic parse_escape function,
in utils.c, which already supported "\^" since basically forever.  When
the C++ name parser was introduced, in commit fb4c6eba439c (2005-03-11),
it got a copy of parse_escape, including the "\^" support.  That copy
was renamed to cp_parse_escape in commit 5256a53bb3fb (2008-10-27).
parse_escape itself lost the "\^" support in commit 6c7a06a3facf
(2009-03-20), but the copy was not updated.

Remove it.  A "\^" sequence is now handled like other unknown escape
sequences.

Change-Id: I866d04281d16dc2f82ea391ffa84370450682951
---
 gdb/cp-name-parser.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c
index d7ecb534b718..4c5f18c9851f 100644
--- a/gdb/cp-name-parser.c
+++ b/gdb/cp-name-parser.c
@@ -494,24 +494,6 @@ cp_parse_escape (const char **string_ptr)
       case 0:
 	(*string_ptr)--;
 	return 0;
-      case '^':
-	{
-	  c = *(*string_ptr)++;
-
-	  if (c == '?')
-	    return 0177;
-	  else if (c == '\\')
-	    target_char = cp_parse_escape (string_ptr);
-	  else
-	    target_char = c;
-
-	  /* Now target_char is something like `c', and we want to find
-	     its control-character equivalent.  */
-	  target_char = target_char & 037;
-
-	  return target_char;
-	}
-
       case '0':
       case '1':
       case '2':
-- 
2.56.0


  parent reply	other threads:[~2026-10-20 16:23 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
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 ` Simon Marchi [this message]
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=20261020162054.2140671-9-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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