From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by sourceware.org (Postfix) with ESMTPS id 30BB93857353 for ; Thu, 4 May 2023 14:21:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30BB93857353 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-763c34315c1so35311839f.3 for ; Thu, 04 May 2023 07:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1683210088; x=1685802088; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wPMmjoVsakfZPSKXROno3tAKp5D9eN4+9/xYlKQejak=; b=BPLZpBuBYdFVYzqZX1wAu6jd+HgvvNStQd49BRBFaNUW/YJfRrDbPdNSJuA38hsYO5 qPgCvQN9kza6L13mDUbLB5kLMKBuL1s2cKU6tAVf4aqQR8uj7gsPhG4u8LII62F11PSR dzUau5A7qO4L2phWuXbhsD3psYftjr0Gl79XYv+IwB+LHOt0uw8xLs8N8GtnoNStIS8n A56z0zUERzjOmJ8T1AuaPU5zWSK2Lb5oqm5JXbxTYP5VOH4/ZDZcrpfBpOfGCYDjMPYE ao5nKKrhiM64fv/MTgzBykCH+FFYQ9oIWxNLeJdZ+iqZnOzLCzIaBaIho4+IX9+tPQLU SvXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683210088; x=1685802088; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wPMmjoVsakfZPSKXROno3tAKp5D9eN4+9/xYlKQejak=; b=O5zGJgK2bO1fFetnUBsuUuedlJhCtvTMYzGpbyg7fgWpK0AW9XhgFF+9O/zK8W+owa +UIWc5yLKTAcvhMScxs5miuue6I9das9zhSB9+L90UF1mpRo3JGzQRqQkvoIMvEjRf+5 dVZCHWpKAGaBTOOOOkTt6FTqIIe+GVRVQ+DYw2Gt+y/VXQM8k8f+qnUBdZo8oF+XRxJS KQ3BoNxhTLlDoJVkTBsFbwSFKC7DuaNulI0WeG3+PYre7YHZ9jWuEblNwhDw6uZ+BwUn lDVzdvcV7lZd+BDIcqfvYmkWftzBSlvZaiDzD/YIXZFZWWhvVUQo+lHTW91WAAH9hX7W hOzA== X-Gm-Message-State: AC+VfDwGz5Yi8l/DU1LmnSeHyxt5SdNIampGl/xi/5n/NXqleUupW18o ppNG/JwcyCFGnwy+XiUI2hSh7ULpAmsclva2qxLJjg== X-Google-Smtp-Source: ACHHUZ6AL+3Tn7zfV3SbGHBdLYjMFZkfDSe+SJa2TGzNll+WZssrMEkVIPlkvhgx4snnxhRkyw9z6A== X-Received: by 2002:a5d:8753:0:b0:763:5523:e89d with SMTP id k19-20020a5d8753000000b007635523e89dmr17440956iol.18.1683210088352; Thu, 04 May 2023 07:21:28 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id r16-20020a6b4410000000b00760a07e4e09sm9983384ioa.5.2023.05.04.07.21.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 07:21:28 -0700 (PDT) From: Tom Tromey Date: Thu, 04 May 2023 08:21:28 -0600 Subject: [PATCH 07/11] Add PARSER_DEBUG flag MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230504-frameless-v1-7-4191201740b0@adacore.com> References: <20230504-frameless-v1-0-4191201740b0@adacore.com> In-Reply-To: <20230504-frameless-v1-0-4191201740b0@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This adds a new PARSER_DEBUG constant and changes the parser code to use it. This lets us make the 'parser_debug' global 'static'. --- gdb/ada-exp.y | 2 +- gdb/c-exp.y | 2 +- gdb/d-exp.y | 2 +- gdb/expression.h | 5 +++++ gdb/f-exp.y | 2 +- gdb/go-exp.y | 2 +- gdb/parse.c | 2 +- gdb/parser-defs.h | 8 +++++--- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 3e31d275046..23aebf0e236 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1150,7 +1150,7 @@ ada_parse (struct parser_state *par_state) original_expr = par_state->lexptr; scoped_restore restore_yydebug = make_scoped_restore (&yydebug, - parser_debug); + par_state->debug); lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9ee4115560a..a8c78414253 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -3403,7 +3403,7 @@ c_parse (struct parser_state *par_state) = make_scoped_restore (&expression_macro_scope, macro_scope.get ()); scoped_restore restore_yydebug = make_scoped_restore (&yydebug, - parser_debug); + par_state->debug); /* Initialize some state used by the lexer. */ last_was_structop = false; diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 3a4e7ee0434..b0f2c0d1c10 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -1607,7 +1607,7 @@ d_parse (struct parser_state *par_state) pstate = par_state; scoped_restore restore_yydebug = make_scoped_restore (&yydebug, - parser_debug); + par_state->debug); struct type_stack stack; scoped_restore restore_type_stack = make_scoped_restore (&type_stack, diff --git a/gdb/expression.h b/gdb/expression.h index 2e2d2a090f9..c485b159ef8 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -296,6 +296,11 @@ enum parser_flag /* This flag is set if a top-level comma terminates the expression. */ PARSER_COMMA_TERMINATES = (1 << 1), + + /* This flag is set if the parser should print debugging output as + it parses. For yacc-based parsers, this translates to setting + yydebug. */ + PARSER_DEBUG = (1 << 2), }; DEF_ENUM_FLAGS_TYPE (enum parser_flag, parser_flags); diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 7fb1a9054e3..c0afebc0589 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1697,7 +1697,7 @@ f_language::parser (struct parser_state *par_state) const /* Setting up the parser state. */ scoped_restore pstate_restore = make_scoped_restore (&pstate); scoped_restore restore_yydebug = make_scoped_restore (&yydebug, - parser_debug); + par_state->debug); gdb_assert (par_state != NULL); pstate = par_state; last_was_structop = false; diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 542a06d06d6..5c213f138f0 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1525,7 +1525,7 @@ go_language::parser (struct parser_state *par_state) const pstate = par_state; scoped_restore restore_yydebug = make_scoped_restore (&yydebug, - parser_debug); + par_state->debug); /* Initialize some state used by the lexer. */ last_was_structop = 0; diff --git a/gdb/parse.c b/gdb/parse.c index 2f014dd2172..bbe5cf12d37 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -62,7 +62,7 @@ show_expressiondebug (struct ui_file *file, int from_tty, /* True if an expression parser should set yydebug. */ -bool parser_debug; +static bool parser_debug; static void show_parserdebug (struct ui_file *file, int from_tty, diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 39046d04c8d..93ebdf5c061 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -32,8 +32,6 @@ struct language_defn; struct internalvar; class innermost_block_tracker; -extern bool parser_debug; - /* A class that can be used to build a "struct expression". */ struct expr_builder @@ -157,7 +155,8 @@ struct parser_state : public expr_builder block_tracker (tracker), comma_terminates ((flags & PARSER_COMMA_TERMINATES) != 0), parse_completion (completion), - void_context_p ((flags & PARSER_VOID_CONTEXT) != 0) + void_context_p ((flags & PARSER_VOID_CONTEXT) != 0), + debug ((flags & PARSER_DEBUG) != 0) { } @@ -303,6 +302,9 @@ struct parser_state : public expr_builder /* True if no value is expected from the expression. */ bool void_context_p; + /* True if parser debugging should be enabled. */ + bool debug; + private: /* Data structure for saving values of arglist_len for function calls whose -- 2.39.1