From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/6] Remove PARSER_RESULT macro
Date: Thu, 06 Jun 2024 08:45:45 -0600 [thread overview]
Message-ID: <20240606-linespec-no-macros-v1-2-a748ab917e12@adacore.com> (raw)
In-Reply-To: <20240606-linespec-no-macros-v1-0-a748ab917e12@adacore.com>
This removes the PARSER_RESULT macro from linespec.c.
---
gdb/linespec.c | 56 +++++++++++++++++++++++++-------------------------------
1 file changed, 25 insertions(+), 31 deletions(-)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 0d7cb691e05..2ad4b9fe812 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -314,7 +314,6 @@ struct linespec_parser
/* The result of the parse. */
linespec result;
-#define PARSER_RESULT(PPTR) (&(PPTR)->result)
/* What the parser believes the current word point should complete
to. */
@@ -342,7 +341,7 @@ struct linespec_parser
/* A convenience macro for accessing the explicit location spec result
of the parser. */
-#define PARSER_EXPLICIT(PPTR) (&PARSER_RESULT ((PPTR))->explicit_loc)
+#define PARSER_EXPLICIT(PPTR) (&((PPTR)->result).explicit_loc)
/* Prototypes for local functions. */
@@ -1811,14 +1810,14 @@ linespec_parse_basic (linespec_parser *parser)
/* Try looking it up as a function/method. */
find_linespec_symbols (&parser->state,
- PARSER_RESULT (parser)->file_symtabs, name.get (),
+ parser->result.file_symtabs, name.get (),
PARSER_EXPLICIT (parser)->func_name_match_type,
&symbols, &minimal_symbols);
if (!symbols.empty () || !minimal_symbols.empty ())
{
- PARSER_RESULT (parser)->function_symbols = std::move (symbols);
- PARSER_RESULT (parser)->minimal_symbols = std::move (minimal_symbols);
+ parser->result.function_symbols = std::move (symbols);
+ parser->result.minimal_symbols = std::move (minimal_symbols);
PARSER_EXPLICIT (parser)->function_name = std::move (name);
}
else
@@ -1831,9 +1830,8 @@ linespec_parse_basic (linespec_parser *parser)
if (!labels.empty ())
{
- PARSER_RESULT (parser)->labels.label_symbols = std::move (labels);
- PARSER_RESULT (parser)->labels.function_symbols
- = std::move (symbols);
+ parser->result.labels.label_symbols = std::move (labels);
+ parser->result.labels.function_symbols = std::move (symbols);
PARSER_EXPLICIT (parser)->label_name = std::move (name);
}
else if (token.type == LSTOKEN_STRING
@@ -1934,15 +1932,13 @@ linespec_parse_basic (linespec_parser *parser)
name = copy_token_string (token);
std::vector<block_symbol> labels
= find_label_symbols (&parser->state,
- PARSER_RESULT (parser)->function_symbols,
+ parser->result.function_symbols,
&symbols, name.get ());
if (!labels.empty ())
{
- PARSER_RESULT (parser)->labels.label_symbols
- = std::move (labels);
- PARSER_RESULT (parser)->labels.function_symbols
- = std::move (symbols);
+ parser->result.labels.label_symbols = std::move (labels);
+ parser->result.labels.function_symbols = std::move (symbols);
PARSER_EXPLICIT (parser)->label_name = std::move (name);
}
else
@@ -2488,7 +2484,7 @@ parse_linespec (linespec_parser *parser, const char *arg,
if (parser->completion_tracker == NULL)
{
std::vector<symtab_and_line> values
- = decode_objc (&parser->state, PARSER_RESULT (parser), arg);
+ = decode_objc (&parser->state, &parser->result, arg);
if (!values.empty ())
return values;
}
@@ -2512,7 +2508,7 @@ parse_linespec (linespec_parser *parser, const char *arg,
{
/* A NULL entry means to use GLOBAL_DEFAULT_SYMTAB. */
if (parser->completion_tracker == NULL)
- PARSER_RESULT (parser)->file_symtabs.push_back (nullptr);
+ parser->result.file_symtabs.push_back (nullptr);
/* User specified a convenience variable or history value. */
gdb::unique_xmalloc_ptr<char> var = copy_token_string (token);
@@ -2553,7 +2549,7 @@ parse_linespec (linespec_parser *parser, const char *arg,
/* Check if the input is a filename. */
try
{
- PARSER_RESULT (parser)->file_symtabs
+ parser->result.file_symtabs
= symtabs_from_filename (user_filename.get (),
parser->state.search_pspace);
}
@@ -2576,7 +2572,7 @@ parse_linespec (linespec_parser *parser, const char *arg,
else
{
/* A NULL entry means to use GLOBAL_DEFAULT_SYMTAB. */
- PARSER_RESULT (parser)->file_symtabs.push_back (nullptr);
+ parser->result.file_symtabs.push_back (nullptr);
}
}
/* If the next token is not EOI, KEYWORD, or COMMA, issue an error. */
@@ -2592,17 +2588,17 @@ parse_linespec (linespec_parser *parser, const char *arg,
else
{
/* A NULL entry means to use GLOBAL_DEFAULT_SYMTAB. */
- PARSER_RESULT (parser)->file_symtabs.push_back (nullptr);
+ parser->result.file_symtabs.push_back (nullptr);
}
/* Parse the rest of the linespec. */
linespec_parse_basic (parser);
if (parser->completion_tracker == NULL
- && PARSER_RESULT (parser)->function_symbols.empty ()
- && PARSER_RESULT (parser)->labels.label_symbols.empty ()
+ && parser->result.function_symbols.empty ()
+ && parser->result.labels.label_symbols.empty ()
&& PARSER_EXPLICIT (parser)->line_offset.sign == LINE_OFFSET_UNKNOWN
- && PARSER_RESULT (parser)->minimal_symbols.empty ())
+ && parser->result.minimal_symbols.empty ())
{
/* The linespec didn't parse. Re-throw the file exception if
there was one. */
@@ -2632,10 +2628,9 @@ parse_linespec (linespec_parser *parser, const char *arg,
parser->complete_what = linespec_complete_what::EXPRESSION;
}
- /* Convert the data in PARSER_RESULT to SALs. */
+ /* Convert the data in the parser's result to SALs. */
if (parser->completion_tracker == NULL)
- return convert_linespec_to_sals (&parser->state,
- PARSER_RESULT (parser));
+ return convert_linespec_to_sals (&parser->state, &parser->result);
return {};
}
@@ -2826,7 +2821,7 @@ complete_label (completion_tracker &tracker,
std::vector<block_symbol> label_function_symbols;
std::vector<block_symbol> labels
= find_label_symbols (&parser->state,
- PARSER_RESULT (parser)->function_symbols,
+ parser->result.function_symbols,
&label_function_symbols,
label_name, true);
@@ -2854,7 +2849,7 @@ linespec_complete_label (completion_tracker &tracker,
try
{
convert_explicit_location_spec_to_linespec (&parser.state,
- PARSER_RESULT (&parser),
+ &parser.result,
source_filename,
function_name,
func_name_match_type,
@@ -2934,13 +2929,12 @@ linespec_complete (completion_tracker &tracker, const char *text,
std::vector<block_symbol> function_symbols;
std::vector<bound_minimal_symbol> minimal_symbols;
find_linespec_symbols (&parser.state,
- PARSER_RESULT (&parser)->file_symtabs,
+ parser.result.file_symtabs,
func_name, match_type,
&function_symbols, &minimal_symbols);
- PARSER_RESULT (&parser)->function_symbols = std::move (function_symbols);
- PARSER_RESULT (&parser)->minimal_symbols = std::move (minimal_symbols);
-
+ parser.result.function_symbols = std::move (function_symbols);
+ parser.result.minimal_symbols = std::move (minimal_symbols);
complete_label (tracker, &parser, parser.completion_word);
}
else if (parser.complete_what == linespec_complete_what::FUNCTION)
@@ -3106,7 +3100,7 @@ location_spec_to_sals (linespec_parser *parser,
const explicit_location_spec *explicit_locspec
= as_explicit_location_spec (locspec);
result = convert_explicit_location_spec_to_sals (&parser->state,
- PARSER_RESULT (parser),
+ &parser->result,
explicit_locspec);
}
break;
--
2.44.0
next prev parent reply other threads:[~2024-06-06 14:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 14:45 [PATCH 0/6] Remove accessor macros from linespec.c Tom Tromey
2024-06-06 14:45 ` [PATCH 1/6] Remove PARSER_STATE macro Tom Tromey
2024-06-06 14:45 ` Tom Tromey [this message]
2024-06-06 14:45 ` [PATCH 3/6] Remove PARSER_EXPLICIT macro Tom Tromey
2024-06-06 14:45 ` [PATCH 4/6] Remove PARSER_STREAM macro Tom Tromey
2024-06-06 14:45 ` [PATCH 5/6] Remove LS_TOKEN_KEYWORD macro Tom Tromey
2024-06-06 14:45 ` [PATCH 6/6] Remove LS_TOKEN_STOKEN macro Tom Tromey
2024-06-12 16:03 ` [PATCH 0/6] Remove accessor macros from linespec.c Keith Seitz
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=20240606-linespec-no-macros-v1-2-a748ab917e12@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).