From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/4] [gdb] Use make_scoped_restore in linespec_lexer_peek_token
Date: Sun, 20 Sep 2026 15:02:53 +0200 [thread overview]
Message-ID: <20260920130254.604592-4-tdevries@suse.de> (raw)
In-Reply-To: <20260920130254.604592-1-tdevries@suse.de>
Use make_scoped_restore in linespec_lexer_peek_token to protect cleanups
against exceptions.
---
gdb/linespec.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b6505ba283d..95ad0b048d2 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1037,20 +1037,16 @@ linespec_lexer_consume_token (linespec_parser *parser)
static linespec_token
linespec_lexer_peek_token (linespec_parser *parser)
{
- linespec_token next;
- const char *saved_stream = parser->lexer.stream;
- linespec_token saved_token = parser->lexer.current;
- int saved_completion_quote_char = parser->completion_quote_char;
- const char *saved_completion_quote_end = parser->completion_quote_end;
- const char *saved_completion_word = parser->completion_word;
-
- next = linespec_lexer_consume_token (parser);
- parser->lexer.stream = saved_stream;
- parser->lexer.current = saved_token;
- parser->completion_quote_char = saved_completion_quote_char;
- parser->completion_quote_end = saved_completion_quote_end;
- parser->completion_word = saved_completion_word;
- return next;
+ scoped_restore stream_restore = make_scoped_restore (&parser->lexer.stream);
+ scoped_restore token_restore = make_scoped_restore (&parser->lexer.current);
+ scoped_restore completion_quote_char_restore
+ = make_scoped_restore (&parser->completion_quote_char);
+ scoped_restore completion_quote_end_restore
+ = make_scoped_restore (&parser->completion_quote_end);
+ scoped_restore completion_word_restore
+ = make_scoped_restore (&parser->completion_word);
+
+ return linespec_lexer_consume_token (parser);
}
/* Helper functions. */
--
2.51.0
next prev parent reply other threads:[~2026-09-20 13:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 13:02 [PATCH 0/4] [gdb] Use c++-style cleanups a bit more Tom de Vries
2026-09-20 13:02 ` [PATCH 1/4] [gdb] Use make_scoped_restore in z80_read_overlay_region_table Tom de Vries
2026-09-20 13:02 ` [PATCH 2/4] [gdb] Use SCOPE_EXIT in tfile_get_traceframe_address Tom de Vries
2026-09-20 13:02 ` Tom de Vries [this message]
2026-09-20 13:02 ` [PATCH 4/4] [gdb] Use make_scoped_restore in captured_main_1 Tom de Vries
2026-09-22 19:37 ` [PATCH 0/4] [gdb] Use c++-style cleanups a bit more 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=20260920130254.604592-4-tdevries@suse.de \
--to=tdevries@suse.de \
--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