From patchwork Thu Mar 21 19:03:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87470 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 38AD63858293 for ; Thu, 21 Mar 2024 19:04:27 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by sourceware.org (Postfix) with ESMTPS id 222713858D38 for ; Thu, 21 Mar 2024 19:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 222713858D38 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 222713858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047815; cv=none; b=IRWlJqsFZPEQED9g1SaxnfKd1KihRxKmRTv2qDglVew3l1xKZOqypfv4VP1R/oc2ZlPGQ/BbyMWoIKujjvQ+EqExoVKln3dIuew4lHp+ZclPlEq78t5zGcx7a+KIudrdn+qJd6fdL2ftfsFIxPirEbUAH96qjyBqWDl8qlLcMZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047815; c=relaxed/simple; bh=C+pOPiPH4LSDlzHSGZPZnWEmwON1V1ZPO5FVS69zHlk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=HV7fYMBK2ug/0wxrJmQxA+egdYD4EIbXGk1Wj09MR+2KkJflZLLyMFl/KT7Xb+DiuliK6Gxq1zTqucrSNRb6c2rjzc/pxzEjA62i01SxyoJLkjDhX2pcqjRtm486JrTlFxs4GdEjPREGPLLam+RXJOtXXhqewDfhKSuNNfAnybU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7cde3cbf03aso63080839f.1 for ; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047810; x=1711652610; darn=sourceware.org; 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=3CTCBagNV/Tp5M++ByH2+Oo1U1YhHC0h8SM0ssu3QN4=; b=cUaY+fZ48L+fi0ICR/bcQFsZx/G2qco24tOZxHpu59KTNuG6+nBn3RVWjdkPgHbl8O uF+He7bEEpqvL3ZrnIV+skPGu4F7xO0/Wo2uUL287D1T5o0vU3xkXXTd+KVzC/+6iIiD DHQN2RNJI5TQH+RpzpgUZd9rPvYvDZUGoBy4ExkxxjZdr5eoJ5zlUvd2V9wisnBMUupf u1Bmkbf7plRVmh56lAam5qNWG3SjpYsZrqiDB7f9g0Xty3yZSSI8nBOvjUSacgcih9Al 2uWwCP8ZHSitgPolCCfCpJJAtnn5QPuqTa5Ksa+DcVENjPvrxnCZ4CtECQgoLaZRg3Dk +RkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047810; x=1711652610; 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=3CTCBagNV/Tp5M++ByH2+Oo1U1YhHC0h8SM0ssu3QN4=; b=NLtv7eAiwGSUHgIip6+o+L8u9wDzfeOBcCWNuwjE9kh6Rhgvbpqul8XLbX9IF2gZvY z8VuRmp9ASQ1WTjoJIwEZWwqWtvu3oXyGEeL7Bm6aXPnHHF4joPswG75WGNQkEm4uLYE vBGmtuS0riMZSc+uizLQe2zXrC2BOdSxPPkFfmvfQy/rQdQPTaPWIZqWxuNvXqO37pLp KHFQn0ZlJwP7lchzF1MHVj9t8we3UMhlGf5UufRgV9WduztOhoGQJyvz/kp/qybJe/mj tN0cB4tWrKBGwM2qUUf39Vh0ZFpBHgAAwQ7Dt4/rmKPIY/4sU39S229c6xzxoIqatKnY s6sQ== X-Gm-Message-State: AOJu0YyXhj+MOapY6U/h0aE3LwHvVKcJh+31vQw2Dm7U+mK4dBjxmrDZ u09lFUhlvIu04C7d/XxIDtayrn1hjRGfoIqE9uioBrRRCLYBd8rQPVU79+17Y3HXTgrMBUqLERM = X-Google-Smtp-Source: AGHT+IHHP7h0TdbpdYgRVgf7tjK8xag3p3r3jDjMt+liDAI8Ng5Tz/lK6KD8JEfCv2rRMf0yRCMd9Q== X-Received: by 2002:a6b:e719:0:b0:7cc:b3:889e with SMTP id b25-20020a6be719000000b007cc00b3889emr417206ioh.11.1711047810220; Thu, 21 Mar 2024 12:03:30 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:30 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:29 -0600 Subject: [PATCH 01/12] Introduce and use aggregate_assigner type MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-1-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch is a refactoring to add a new aggregate_assigner type. This type is passed to Ada aggregate assignment operations in place of passing a number of separate arguments. This new approach makes it simpler to change some aspects of aggregate assignment behavior. --- gdb/ada-exp.h | 88 +++++++++++++++++---------------- gdb/ada-lang.c | 153 +++++++++++++++++++++++++-------------------------------- 2 files changed, 114 insertions(+), 127 deletions(-) diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 69d4e90e410..6122502dcdc 100644 --- a/gdb/ada-exp.h +++ b/gdb/ada-exp.h @@ -588,20 +588,48 @@ class ada_target_operation : public operation ada_assign_operation *m_lhs; }; +/* When constructing an aggregate, an object of this type is created + to track the needed state. */ + +struct aggregate_assigner +{ + /* An lvalue containing LHS (possibly LHS itself). */ + value *container; + + /* An lvalue of record or array type; this is the object being + assigned to. */ + value *lhs; + + /* The expression being evaluated. */ + expression *exp; + + /* The bounds of LHS. This is used by the 'others' component. */ + LONGEST low; + LONGEST high; + + /* This indicates which sub-components have already been assigned + to. */ + std::vector indices; + + /* Assign the result of evaluating ARG to the INDEXth component of + LHS (a simple array or a record). Does not modify the inferior's + memory, nor does it modify LHS (unless LHS == CONTAINER). */ + void assign (LONGEST index, operation_up &arg); + + /* Add the interval [FROM .. TO] to the sorted set of intervals + [ INDICES[0] .. INDICES[1] ],... The resulting intervals do not + overlap. */ + void add_interval (LONGEST low, LONGEST high); +}; + /* This abstract class represents a single component in an Ada aggregate assignment. */ class ada_component { public: - /* Assign to LHS, which is part of CONTAINER. EXP is the expression - being evaluated. INDICES, LOW, and HIGH indicate which - sub-components have already been assigned; INDICES should be - updated by this call. */ - virtual void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) = 0; + /* Assign to ASSIGNER. */ + virtual void assign (aggregate_assigner &assigner) = 0; /* Same as operation::uses_objfile. */ virtual bool uses_objfile (struct objfile *objfile) = 0; @@ -664,10 +692,7 @@ class ada_aggregate_component : public ada_component ada_aggregate_component (operation_up &&base, std::vector &&components); - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) override; + void assign (aggregate_assigner &assigner) override; bool uses_objfile (struct objfile *objfile) override; @@ -694,10 +719,7 @@ class ada_positional_component : public ada_component { } - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) override; + void assign (aggregate_assigner &assigner) override; bool uses_objfile (struct objfile *objfile) override; @@ -719,10 +741,7 @@ class ada_others_component : public ada_component { } - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) override; + void assign (aggregate_assigner &assigner) override; bool uses_objfile (struct objfile *objfile) override; @@ -740,14 +759,10 @@ class ada_association public: /* Like ada_component::assign, but takes an operation as a - parameter. The operation is evaluated and then assigned into LHS - according to the rules of the concrete implementation. */ - virtual void assign (struct value *container, - struct value *lhs, - struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high, - operation_up &op) = 0; + parameter. The operation is evaluated and then assigned into + ASSIGNER according to the rules of the concrete + implementation. */ + virtual void assign (aggregate_assigner &assigner, operation_up &op) = 0; /* Same as operation::uses_objfile. */ virtual bool uses_objfile (struct objfile *objfile) = 0; @@ -785,10 +800,7 @@ class ada_choices_component : public ada_component m_assocs = std::move (assoc); } - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) override; + void assign (aggregate_assigner &assigner) override; bool uses_objfile (struct objfile *objfile) override; @@ -811,11 +823,7 @@ class ada_discrete_range_association : public ada_association { } - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high, - operation_up &op) override; + void assign (aggregate_assigner &assigner, operation_up &op) override; bool uses_objfile (struct objfile *objfile) override; @@ -839,11 +847,7 @@ class ada_name_association : public ada_association { } - void assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high, - operation_up &op) override; + void assign (aggregate_assigner &assigner, operation_up &op) override; bool uses_objfile (struct objfile *objfile) override; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 493ef3b6c7d..c9cbeca40bc 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -191,9 +191,6 @@ static int ada_is_direct_array_type (struct type *); static struct value *ada_index_struct_field (int, struct value *, int, struct type *); -static void add_component_interval (LONGEST, LONGEST, std::vector &); - - static struct type *ada_find_any_type (const char *name); static symbol_name_matcher_ftype *ada_get_symbol_name_matcher @@ -9323,13 +9320,10 @@ check_objfile (const std::unique_ptr &comp, return comp->uses_objfile (objfile); } -/* Assign the result of evaluating ARG to the INDEXth component of LHS - (a simple array or a record). Does not modify the inferior's - memory, nor does it modify LHS (unless LHS == CONTAINER). */ +/* See ada-exp.h. */ -static void -assign_component (struct value *container, struct value *lhs, LONGEST index, - struct expression *exp, operation_up &arg) +void +aggregate_assigner::assign (LONGEST index, operation_up &arg) { scoped_value_mark mark; @@ -9384,23 +9378,21 @@ ada_aggregate_component::dump (ui_file *stream, int depth) } void -ada_aggregate_component::assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) +ada_aggregate_component::assign (aggregate_assigner &assigner) { if (m_base != nullptr) { - value *base = m_base->evaluate (nullptr, exp, EVAL_NORMAL); + value *base = m_base->evaluate (nullptr, assigner.exp, EVAL_NORMAL); if (ada_is_direct_array_type (base->type ())) base = ada_coerce_to_simple_array (base); - if (!types_deeply_equal (container->type (), base->type ())) + if (!types_deeply_equal (assigner.container->type (), base->type ())) error (_("Type mismatch in delta aggregate")); - value_assign_to_component (container, container, base); + value_assign_to_component (assigner.container, assigner.container, + base); } for (auto &item : m_components) - item->assign (container, lhs, exp, indices, low, high); + item->assign (assigner); } /* See ada-exp.h. */ @@ -9429,7 +9421,7 @@ ada_aggregate_operation::assign_aggregate (struct value *container, struct expression *exp) { struct type *lhs_type; - LONGEST low_index, high_index; + aggregate_assigner assigner; container = ada_coerce_ref (container); if (ada_is_direct_array_type (container->type ())) @@ -9443,23 +9435,27 @@ ada_aggregate_operation::assign_aggregate (struct value *container, { lhs = ada_coerce_to_simple_array (lhs); lhs_type = check_typedef (lhs->type ()); - low_index = lhs_type->bounds ()->low.const_val (); - high_index = lhs_type->bounds ()->high.const_val (); + assigner.low = lhs_type->bounds ()->low.const_val (); + assigner.high = lhs_type->bounds ()->high.const_val (); } else if (lhs_type->code () == TYPE_CODE_STRUCT) { - low_index = 0; - high_index = num_visible_fields (lhs_type) - 1; + assigner.low = 0; + assigner.high = num_visible_fields (lhs_type) - 1; } else error (_("Left-hand side must be array or record.")); - std::vector indices (4); - indices[0] = indices[1] = low_index - 1; - indices[2] = indices[3] = high_index + 1; + assigner.indices.push_back (assigner.low - 1); + assigner.indices.push_back (assigner.low - 1); + assigner.indices.push_back (assigner.high + 1); + assigner.indices.push_back (assigner.high + 1); + + assigner.container = container; + assigner.lhs = lhs; + assigner.exp = exp; - std::get<0> (m_storage)->assign (container, lhs, exp, indices, - low_index, high_index); + std::get<0> (m_storage)->assign (assigner); return container; } @@ -9483,19 +9479,16 @@ ada_positional_component::dump (ui_file *stream, int depth) LOW, where HIGH is the upper bound. Record the position in INDICES. CONTAINER is as for assign_aggregate. */ void -ada_positional_component::assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) +ada_positional_component::assign (aggregate_assigner &assigner) { - LONGEST ind = m_index + low; + LONGEST ind = m_index + assigner.low; - if (ind - 1 == high) + if (ind - 1 == assigner.high) warning (_("Extra components in aggregate ignored.")); - if (ind <= high) + if (ind <= assigner.high) { - add_component_interval (ind, ind, indices); - assign_component (container, lhs, ind, exp, m_op); + assigner.add_interval (ind, ind); + assigner.assign (ind, m_op); } } @@ -9514,23 +9507,21 @@ ada_discrete_range_association::dump (ui_file *stream, int depth) } void -ada_discrete_range_association::assign (struct value *container, - struct value *lhs, - struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high, +ada_discrete_range_association::assign (aggregate_assigner &assigner, operation_up &op) { - LONGEST lower = value_as_long (m_low->evaluate (nullptr, exp, EVAL_NORMAL)); - LONGEST upper = value_as_long (m_high->evaluate (nullptr, exp, EVAL_NORMAL)); + LONGEST lower = value_as_long (m_low->evaluate (nullptr, assigner.exp, + EVAL_NORMAL)); + LONGEST upper = value_as_long (m_high->evaluate (nullptr, assigner.exp, + EVAL_NORMAL)); - if (lower <= upper && (lower < low || upper > high)) + if (lower <= upper && (lower < assigner.low || upper > assigner.high)) error (_("Index in component association out of bounds.")); - add_component_interval (lower, upper, indices); + assigner.add_interval (lower, upper); while (lower <= upper) { - assign_component (container, lhs, lower, exp, op); + assigner.assign (lower, op); lower += 1; } } @@ -9549,18 +9540,16 @@ ada_name_association::dump (ui_file *stream, int depth) } void -ada_name_association::assign (struct value *container, - struct value *lhs, - struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high, +ada_name_association::assign (aggregate_assigner &assigner, operation_up &op) { int index; - if (ada_is_direct_array_type (lhs->type ())) - index = longest_to_int (value_as_long (m_val->evaluate (nullptr, exp, - EVAL_NORMAL))); + if (ada_is_direct_array_type (assigner.lhs->type ())) + { + value *tem = m_val->evaluate (nullptr, assigner.exp, EVAL_NORMAL); + index = longest_to_int (value_as_long (tem)); + } else { ada_string_operation *strop @@ -9586,13 +9575,13 @@ ada_name_association::assign (struct value *container, } index = 0; - if (! find_struct_field (name, lhs->type (), 0, + if (! find_struct_field (name, assigner.lhs->type (), 0, NULL, NULL, NULL, NULL, &index)) error (_("Unknown component name: %s."), name); } - add_component_interval (index, index, indices); - assign_component (container, lhs, index, exp, op); + assigner.add_interval (index, index); + assigner.assign (index, op); } bool @@ -9620,13 +9609,10 @@ ada_choices_component::dump (ui_file *stream, int depth) the allowable indices are LOW..HIGH. Record the indices assigned to in INDICES. CONTAINER is as for assign_aggregate. */ void -ada_choices_component::assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) +ada_choices_component::assign (aggregate_assigner &assigner) { for (auto &item : m_assocs) - item->assign (container, lhs, exp, indices, low, high, m_op); + item->assign (assigner, m_op); } bool @@ -9647,16 +9633,15 @@ ada_others_component::dump (ui_file *stream, int depth) have not been previously assigned. The index intervals already assigned are in INDICES. CONTAINER is as for assign_aggregate. */ void -ada_others_component::assign (struct value *container, - struct value *lhs, struct expression *exp, - std::vector &indices, - LONGEST low, LONGEST high) +ada_others_component::assign (aggregate_assigner &assigner) { - int num_indices = indices.size (); + int num_indices = assigner.indices.size (); for (int i = 0; i < num_indices - 2; i += 2) { - for (LONGEST ind = indices[i + 1] + 1; ind < indices[i + 2]; ind += 1) - assign_component (container, lhs, ind, exp, m_op); + for (LONGEST ind = assigner.indices[i + 1] + 1; + ind < assigner.indices[i + 2]; + ind += 1) + assigner.assign (ind, m_op); } } @@ -9697,46 +9682,44 @@ ada_assign_operation::evaluate (struct type *expect_type, return ada_value_assign (arg1, arg2); } -} /* namespace expr */ +/* See ada-exp.h. */ -/* Add the interval [LOW .. HIGH] to the sorted set of intervals - [ INDICES[0] .. INDICES[1] ],... The resulting intervals do not - overlap. */ -static void -add_component_interval (LONGEST low, LONGEST high, - std::vector &indices) +void +aggregate_assigner::add_interval (LONGEST from, LONGEST to) { int i, j; int size = indices.size (); for (i = 0; i < size; i += 2) { - if (high >= indices[i] && low <= indices[i + 1]) + if (to >= indices[i] && from <= indices[i + 1]) { int kh; for (kh = i + 2; kh < size; kh += 2) - if (high < indices[kh]) + if (to < indices[kh]) break; - if (low < indices[i]) - indices[i] = low; + if (from < indices[i]) + indices[i] = from; indices[i + 1] = indices[kh - 1]; - if (high > indices[i + 1]) - indices[i + 1] = high; + if (to > indices[i + 1]) + indices[i + 1] = to; memcpy (indices.data () + i + 2, indices.data () + kh, size - kh); indices.resize (kh - i - 2); return; } - else if (high < indices[i]) + else if (to < indices[i]) break; } indices.resize (indices.size () + 2); for (j = indices.size () - 1; j >= i + 2; j -= 1) indices[j] = indices[j - 2]; - indices[i] = low; - indices[i + 1] = high; + indices[i] = from; + indices[i + 1] = to; } +} /* namespace expr */ + /* Perform and Ada cast of ARG2 to type TYPE if the type of ARG2 is different. */ From patchwork Thu Mar 21 19:03:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87471 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B54838582A8 for ; Thu, 21 Mar 2024 19:04:59 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 973C13858C98 for ; Thu, 21 Mar 2024 19:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 973C13858C98 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 973C13858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047815; cv=none; b=mcOpTpMGSVLKZ2kjKz5jvkCQzuvhYwmLSIadalHVypQIg4/1VXvPyK+UJA+iBsKNIHvSp29uSX7Cen6qH7MlJSWvnQnaH7hW0DAFWvZDcENP7hfqfqaqszfMgwK4LXdvKB9UC8azERFg89gidsWaePOFFWb9eTHjUNVvfbpgHe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047815; c=relaxed/simple; bh=qRP5tx3O2HRdIaDfrSBvwCwcRim2hs08pimdlw88qCI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jsArCiQOmGv2nePXaDd8qxmWgCF61sEbF3piUGw1kEC1XB0UoC5T7qRQu82EnAwBMfBa/pdm9EWHXNezV0NaKtEIB9pJKE/CIZ7qFWe1VbAlMg1XmVSn/wsVqMwkuhWTk5KyTCANGX/31OFJF3grvevlvxXz9rkBdS28plKkh4k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7c8bb44622eso38369839f.0 for ; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047811; x=1711652611; darn=sourceware.org; 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=vlQ+VEDelG91pKGFzrDX4XGQi3DKFINdb7ElVDZR2o0=; b=VSZHWg1ls4maqUOnae4zHznPyPU8YBPV55eDchdddXzau2hiWNB4wVzZrK3xxDyTnA ZafAD1r6+24enL3dna/MNsHOgmNgCGUh9Zd1Iym0Z2z1A6azHKMG4fVr8LJUKBAGPYQ3 nsUPVdhRBbfEWx2bS2o32Cyiam9e6V62YIr86PcMpvsdLjKmQmFSs1EyWrsuzekhd/0X KUxRQDHOJ7+QOmBwEaPY9tJwvR+eQmV//R1ahLXuzHu6UOSAwngmPLrg2ObA/hme/LB/ whlPwkZ/OLfjhK3+zlksFlNM73f8gLFoB5TBCQShMs6d0MNYABHUTDc7PjUfyp5Fvlrc YxGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047811; x=1711652611; 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=vlQ+VEDelG91pKGFzrDX4XGQi3DKFINdb7ElVDZR2o0=; b=VvOeKzrJ4GEy+2tIux+DNzihzv58VwoqRNmT3ycjNoJXtX2c4BPUjh4XYGNubOoqz6 dgzDJOy4Ytiqw0zZGGB9XVwQ+fSMsaZdqN9ZwiBxs35WaSU3RLjIU69+l2Skz7gKywWp kZHx7D+VT3ec6Wf157g/hG26xn7epxkDp+HMmVs7MeKaq4CV+4ne7A9dCMRhUyz+TVuj 3qX8fswNh8QnBscjc55pt5zsle7nDVDNCH8/t6SlOL0+kMseZsYreTKs5bveCUxoyT7Y 9K55gzmPH9T29YYY//hURSGPlgGnHOCromvS7G9YHdTg9yL5XpzCXYAOpVkYNoQ1kiNc ZTlg== X-Gm-Message-State: AOJu0Yy6hesYkR8aRWJU0rwgydtmnA+A1XOaGGlj+TljMHt+MtQ+lRkN eL2vP/EMXnuL5Szk2AWEfEQ20/5rD748snzQ4YQLy9PCQMU7LbtTzwXMU3hhTtHk2IWDSpU1uDo = X-Google-Smtp-Source: AGHT+IGJRDCksRAIknBnzIFdqK2doTWzzfzx/er4kIBBMGvQDTrErEBcjSItzHlNmS/lK8pSC+czBA== X-Received: by 2002:a05:6602:2981:b0:7d0:2b22:7221 with SMTP id o1-20020a056602298100b007d02b227221mr330040ior.20.1711047810670; Thu, 21 Mar 2024 12:03:30 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:30 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:30 -0600 Subject: [PATCH 02/12] Implement Ada 2022 iterated assignment MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-2-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Ada 2022 includes iterated assignment for array initialization. This patch implements a subset of this for gdb. In particular, only arrays with integer index types really work -- currently there's no decent way to get the index type in EVAL_AVOID_SIDE_EFFECTS mode during parsing. Fixing this probably requires the Ada parser to take a somewhat more sophisticated approach to type resolution; and while this would help fix another bug in this area, this patch is already useful without it. --- gdb/ada-exp.h | 77 ++++++++++++++++++++++++++ gdb/ada-exp.y | 52 +++++++++++++++-- gdb/ada-lang.c | 49 +++++++++++++++- gdb/ada-lex.l | 1 + gdb/testsuite/gdb.ada/iterated-assign.exp | 37 +++++++++++++ gdb/testsuite/gdb.ada/iterated-assign/main.adb | 24 ++++++++ gdb/testsuite/gdb.ada/iterated-assign/pck.adb | 23 ++++++++ gdb/testsuite/gdb.ada/iterated-assign/pck.ads | 26 +++++++++ 8 files changed, 284 insertions(+), 5 deletions(-) diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 6122502dcdc..94e4ea0f47e 100644 --- a/gdb/ada-exp.h +++ b/gdb/ada-exp.h @@ -611,6 +611,15 @@ struct aggregate_assigner to. */ std::vector indices; +private: + + /* The current index value. This is only valid during the 'assign' + operation and is part of the implementation of iterated component + association. */ + LONGEST m_current_index = 0; + +public: + /* Assign the result of evaluating ARG to the INDEXth component of LHS (a simple array or a record). Does not modify the inferior's memory, nor does it modify LHS (unless LHS == CONTAINER). */ @@ -620,6 +629,10 @@ struct aggregate_assigner [ INDICES[0] .. INDICES[1] ],... The resulting intervals do not overlap. */ void add_interval (LONGEST low, LONGEST high); + + /* Return the current index as a value, using the index type of + LHS. */ + value *current_value () const; }; /* This abstract class represents a single component in an Ada @@ -800,16 +813,80 @@ class ada_choices_component : public ada_component m_assocs = std::move (assoc); } + /* Set the underlying operation */ + void set_operation (operation_up op) + { m_op = std::move (op); } + + /* Set the index variable name for an iterated association. */ + void set_name (std::string &&name) + { m_name = std::move (name); } + + /* The name of this choice component. This is empty unless this is + an iterated association. */ + const std::string &name () const + { return m_name; } + void assign (aggregate_assigner &assigner) override; bool uses_objfile (struct objfile *objfile) override; void dump (ui_file *stream, int depth) override; + /* Return the current value of the index variable. This may only be + called underneath a call to 'assign'. */ + value *current_value () const + { return m_assigner->current_value (); } + private: std::vector m_assocs; operation_up m_op; + + /* Name of the variable used for iteration. This isn't needed for + evaluation, only for debug dumping. This is the empty string for + ordinary (non-iterated) choices. */ + std::string m_name; + + /* A pointer to the current assignment operation; only valid when in + a call to the 'assign' method. This is used to find the index + variable value during the evaluation of the RHS of the =>, via + ada_index_var_operation. */ + const aggregate_assigner *m_assigner = nullptr; +}; + +/* Implement the index variable for iterated component + association. */ +class ada_index_var_operation : public operation +{ +public: + + ada_index_var_operation () + { } + + /* Link this variable to the choices object. May only be called + once. */ + void set_choices (ada_choices_component *var) + { + gdb_assert (m_var == nullptr && var != nullptr); + m_var = var; + } + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override; + + enum exp_opcode opcode () const override + { + /* It doesn't really matter. */ + return OP_VAR_VALUE; + } + + void dump (struct ui_file *stream, int depth) const override; + +private: + + /* The choices component that introduced the index variable. */ + ada_choices_component *m_var = nullptr; }; /* An association that uses a discrete range. */ diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 2b205714d7a..c0a5b0534a6 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -422,6 +422,10 @@ typedef std::unique_ptr ada_assign_up; to implement '@', the target name symbol. */ static std::vector assignments; +/* Track currently active iterated assignment names. */ +static std::unordered_map> + iterated_associations; + %} %union @@ -488,7 +492,7 @@ static std::vector assignments; forces a.b.c, e.g., to be LEFT-associated. */ %right '.' '(' '[' DOT_ID DOT_COMPLETE -%token NEW OTHERS +%token NEW OTHERS FOR %% @@ -1098,6 +1102,33 @@ component_group : ada_choices_component *choices = choice_component (); choices->set_associations (pop_associations ($1)); } + | FOR NAME IN + { + std::string name = copy_name ($2); + + auto iter = iterated_associations.find (name); + if (iter != iterated_associations.end ()) + error (_("Nested use of index parameter '%s'"), + name.c_str ()); + + iterated_associations[name] = {}; + } + component_associations + { + std::string name = copy_name ($2); + + ada_choices_component *choices = choice_component (); + choices->set_associations (pop_associations ($5)); + + auto iter = iterated_associations.find (name); + gdb_assert (iter != iterated_associations.end ()); + for (ada_index_var_operation *var : iter->second) + var->set_choices (choices); + + iterated_associations.erase (name); + + choices->set_name (std::move (name)); + } ; /* We use this somewhat obscure definition in order to handle NAME => and @@ -1207,6 +1238,7 @@ ada_parse (struct parser_state *par_state) associations.clear (); int_storage.clear (); assignments.clear (); + iterated_associations.clear (); int result = yyparse (); if (!result) @@ -1652,10 +1684,22 @@ write_var_or_type (struct parser_state *par_state, char *encoded_name; int name_len; - if (block == NULL) - block = par_state->expression_context_block; - std::string name_storage = ada_encode (name0.ptr); + + if (block == nullptr) + { + auto iter = iterated_associations.find (name_storage); + if (iter != iterated_associations.end ()) + { + auto op = std::make_unique (); + iter->second.push_back (op.get ()); + par_state->push (std::move (op)); + return nullptr; + } + + block = par_state->expression_context_block; + } + name_len = name_storage.size (); encoded_name = obstack_strndup (&temp_parse_space, name_storage.c_str (), name_len); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c9cbeca40bc..d65ac70f251 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -9343,6 +9343,8 @@ aggregate_assigner::assign (LONGEST index, operation_up &arg) elt = ada_to_fixed_value (elt); } + scoped_restore save_index = make_scoped_restore (&m_current_index, index); + ada_aggregate_operation *ag_op = dynamic_cast (arg.get ()); if (ag_op != nullptr) @@ -9353,6 +9355,18 @@ aggregate_assigner::assign (LONGEST index, operation_up &arg) EVAL_NORMAL)); } +/* See ada-exp.h. */ + +value * +aggregate_assigner::current_value () const +{ + /* Note that using an integer type here is incorrect -- the type + should be the array's index type. Unfortunately, though, this + isn't currently available during parsing and type resolution. */ + struct type *index_type = builtin_type (exp->gdbarch)->builtin_int; + return value_from_longest (index_type, m_current_index); +} + bool ada_aggregate_component::uses_objfile (struct objfile *objfile) { @@ -9598,8 +9612,15 @@ ada_choices_component::uses_objfile (struct objfile *objfile) void ada_choices_component::dump (ui_file *stream, int depth) { - gdb_printf (stream, _("%*sChoices:\n"), depth, ""); + if (m_name.empty ()) + gdb_printf (stream, _("%*sChoices:\n"), depth, ""); + else + { + gdb_printf (stream, _("%*sIterated choices:\n"), depth, ""); + gdb_printf (stream, _("%*sName: %s\n"), depth + 1, "", m_name.c_str ()); + } m_op->dump (stream, depth + 1); + for (const auto &item : m_assocs) item->dump (stream, depth + 1); } @@ -9611,10 +9632,36 @@ ada_choices_component::dump (ui_file *stream, int depth) void ada_choices_component::assign (aggregate_assigner &assigner) { + scoped_restore save_index = make_scoped_restore (&m_assigner, &assigner); for (auto &item : m_assocs) item->assign (assigner, m_op); } +void +ada_index_var_operation::dump (struct ui_file *stream, int depth) const +{ + gdb_printf (stream, _("%*sIndex variable: %s\n"), depth, "", + m_var->name ().c_str ()); +} + +value * +ada_index_var_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) +{ + if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + /* Note that using an integer type here is incorrect -- the type + should be the array's index type. Unfortunately, though, + this isn't currently available during parsing and type + resolution. */ + struct type *index_type = builtin_type (exp->gdbarch)->builtin_int; + return value::zero (index_type, not_lval); + } + + return m_var->current_value (); +} + bool ada_others_component::uses_objfile (struct objfile *objfile) { diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index c54cd5e452a..e1abf9adc25 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -227,6 +227,7 @@ abs { return ABS; } and { return _AND_; } delta { return DELTA; } else { return ELSE; } +for { return FOR; } in { return IN; } mod { return MOD; } new { return NEW; } diff --git a/gdb/testsuite/gdb.ada/iterated-assign.exp b/gdb/testsuite/gdb.ada/iterated-assign.exp new file mode 100644 index 00000000000..76b038fb45c --- /dev/null +++ b/gdb/testsuite/gdb.ada/iterated-assign.exp @@ -0,0 +1,37 @@ +# Copyright 2024 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile main + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/main.adb] +runto "main.adb:$bp_location" + +gdb_test "print a1 := (for i in 1..4 => 2 * i + 1)" \ + " = \\(3, 5, 7, 9\\)" \ + "simple iterated assignment" + +gdb_test "print a2 := (for i in 1..2 => (for j in 1..2 => 3 * i + j))" \ + " = \\(\\(4, 5\\), \\(7, 8\\)\\)" \ + "nested iterated assignment" diff --git a/gdb/testsuite/gdb.ada/iterated-assign/main.adb b/gdb/testsuite/gdb.ada/iterated-assign/main.adb new file mode 100644 index 00000000000..239c22cd8a8 --- /dev/null +++ b/gdb/testsuite/gdb.ada/iterated-assign/main.adb @@ -0,0 +1,24 @@ +-- Copyright 2024 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with pck; use pck; + +procedure Main is + A1 : Other_Array_Type := (2, 4, 6, 8); + A2 : MD_Array_Type := ((1, 2), (3, 4)); +begin + Do_Nothing (A1'Address); -- STOP + Do_Nothing (A2'Address); +end Main; diff --git a/gdb/testsuite/gdb.ada/iterated-assign/pck.adb b/gdb/testsuite/gdb.ada/iterated-assign/pck.adb new file mode 100644 index 00000000000..14580e66be1 --- /dev/null +++ b/gdb/testsuite/gdb.ada/iterated-assign/pck.adb @@ -0,0 +1,23 @@ +-- Copyright 2024 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package body Pck is + + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; + +end Pck; diff --git a/gdb/testsuite/gdb.ada/iterated-assign/pck.ads b/gdb/testsuite/gdb.ada/iterated-assign/pck.ads new file mode 100644 index 00000000000..b77af7264c4 --- /dev/null +++ b/gdb/testsuite/gdb.ada/iterated-assign/pck.ads @@ -0,0 +1,26 @@ +-- Copyright 2024 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with System; + +package Pck is + + type Other_Array_Type is array (1 .. 4) of Integer; + + type MD_Array_Type is array (1 .. 2, 1 .. 2) of Integer; + + procedure Do_Nothing (A : System.Address); + +end Pck; From patchwork Thu Mar 21 19:03:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87469 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87F9B38582AE for ; Thu, 21 Mar 2024 19:04:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id E48C93858C55 for ; Thu, 21 Mar 2024 19:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E48C93858C55 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E48C93858C55 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047813; cv=none; b=lxazvJV6gQkYUXIcVv6farEAPNcLY2U+MJXl6MgT7KVThIE6E1OY+255iq3L3tuEziYa7223sWBSFncCqAYfqKWozRLgXdrtt316MJ8NGx0dqXjESBcNKqz6e9YuqsvZO2E6GNxGGq74SUEMp+YtO6LyuqmsfFD00NVAPQ30sgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047813; c=relaxed/simple; bh=0YrwjcOlAFKQlqEk0Nvb2x7fjog5fjYH2dwUKWY3UJY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=h8U05a/O4BfOSI0+NCdiat5ASawy7r8oD3ooohlRpTzQX6a8naKdHHUAzN/qh6PC0HilBIQ8e2moOTlti3WBDcs03WTGODKRhtwdLyJW92cpYe9mYt6cMbSiYKEvBwskWXlALyJ0nwqtU3vsbJecpIkLpU0V8vYbvqQHbTUBPNI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-368506aa460so5442415ab.0 for ; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047811; x=1711652611; darn=sourceware.org; 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=GZmogxvUvyfhknqMx9NGd5AhIRSTJ16rNxx2aGK1pVQ=; b=gPIo/SstGBxGJcP+Y35aZH89xks7j842PJmMarAhw6yPhcpB2OGbY2shTEsN4+Ku80 Rcw3vWQbA2nMRCshRSMHE2nlRHL0Op3KEOvj3wm+I+oeBn8RvJOEwlG7wW/055ierANX TEhCzRMCeKMwinyi2KnU9S5R3pOmiF79QGGl7ue3tEyyLMBtMcicYYnIVag8uQw66R1U SaJhnYGDFXPRzaujHPYQP5wpAgv7yPXAJmkmZgaol2TSl+basXbGtZ2LN5lk9jZgvbpR SNXmWdFRM9M4oBntITgRT3mT03hyCU+L0JrdL1MLHfZp0RVkhMSSFktqwUJm1wpK+Rk1 HpwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047811; x=1711652611; 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=GZmogxvUvyfhknqMx9NGd5AhIRSTJ16rNxx2aGK1pVQ=; b=DKZvtGMA4AKrY86ZPUOvM6+IGHJTac2kxyNtMSOlFurucbYdMUyp/fiTtqXeTNObo+ oFB1hqTfiYXyir67bX5sn1Wy0a6TAXTIeDMKosYHigIIHrxDdUW3O/2DWZFmbPHp2KP5 1jSP59iwRPPEPzhrFAm7auQy/INDrvW937GWWXJB2rvhfiP/rgbajuSY4uTQF1L4/cC/ G0Ee9reSVZmuh9yUUvUIkXoXNcnTcl9wrOYPPRZCvRDB+yl0SuBPEvuzMSQQ/n3oXZyu 4nNdhExxYUSgBhBGE14WW3cd6gigmzp7PR4VyIHBc3afG71/7gtxNUV33CMEOG3+BOj4 0zPQ== X-Gm-Message-State: AOJu0YxZP9W5vLCzDxeWY4KqAUncKQzkRU9v2hHGmW77oSR3aSzSghhV bbkTTjhSH9o9jLgBf1G1r+G12Ua5ybLWDCFcjfOzQ58hrigI/aA3Z0nMlYcYUzFM4wNaYooU0Ms = X-Google-Smtp-Source: AGHT+IFdtIUiIZ3Ke66vW+V34grwNp8iteU2771KQJiZjLhIBNORVlW3s7MY0Dp0DPzMlw9qR85APw== X-Received: by 2002:a05:6e02:1c2b:b0:366:a4f3:7916 with SMTP id m11-20020a056e021c2b00b00366a4f37916mr649329ilh.0.1711047811024; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:30 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:31 -0600 Subject: [PATCH 03/12] Introduce ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-3-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch introduces the ada_parse_state class and the ada_parser global. It also changes find_completion_bounds to be a method of this new type. Note that find_completion_bounds never used its parameter; and because it is generally fine to use the 'pstate' global throughout the parser, this patch removes the parameter entirely. --- gdb/ada-exp.y | 51 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index c0a5b0534a6..9452e63ab60 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -65,8 +65,26 @@ struct name_info { static struct parser_state *pstate = NULL; -/* The original expression string. */ -static const char *original_expr; +/* Data that must be held for the duration of a parse. */ + +struct ada_parse_state +{ + explicit ada_parse_state (const char *expr) + : m_original_expr (expr) + { + } + + std::string find_completion_bounds (); + +private: + + /* The original expression string. */ + const char *m_original_expr; +}; + +/* The current Ada parser object. */ + +static ada_parse_state *ada_parser; /* We don't have a good way to manage non-POD data in Yacc, so store values here. The storage here is only valid for the duration of @@ -102,8 +120,6 @@ static struct type *type_for_char (struct parser_state *, ULONGEST); static struct type *type_system_address (struct parser_state *); -static std::string find_completion_bounds (struct parser_state *); - using namespace expr; /* Handle Ada type resolution for OP. DEPROCEDURE_P and CONTEXT_TYPE @@ -549,7 +565,7 @@ primary : primary DOT_COMPLETE ada_structop_operation *str_op = (new ada_structop_operation (std::move (arg), copy_name ($2))); - str_op->set_prefix (find_completion_bounds (pstate)); + str_op->set_prefix (ada_parser->find_completion_bounds ()); pstate->push (operation_up (str_op)); pstate->mark_struct_expression (str_op); } @@ -1223,10 +1239,11 @@ int ada_parse (struct parser_state *par_state) { /* Setting up the parser state. */ - scoped_restore pstate_restore = make_scoped_restore (&pstate); + scoped_restore pstate_restore = make_scoped_restore (&pstate, par_state); gdb_assert (par_state != NULL); - pstate = par_state; - original_expr = par_state->lexptr; + + ada_parse_state parser (par_state->lexptr); + scoped_restore parser_restore = make_scoped_restore (&ada_parser, &parser); scoped_restore restore_yydebug = make_scoped_restore (&yydebug, par_state->debug); @@ -1849,13 +1866,13 @@ write_var_or_type (struct parser_state *par_state, Without this, an attempt like "complete print abc.d" will give a result like "print def" rather than "print abc.def". */ -static std::string -find_completion_bounds (struct parser_state *par_state) +std::string +ada_parse_state::find_completion_bounds () { const char *end = pstate->lexptr; /* First the end of the prefix. Here we stop at the token start or at '.' or space. */ - for (; end > original_expr && end[-1] != '.' && !isspace (end[-1]); --end) + for (; end > m_original_expr && end[-1] != '.' && !isspace (end[-1]); --end) { /* Nothing. */ } @@ -1863,11 +1880,11 @@ find_completion_bounds (struct parser_state *par_state) const char *ptr = end; /* Here we allow '.'. */ for (; - ptr > original_expr && (ptr[-1] == '.' - || ptr[-1] == '_' - || (ptr[-1] >= 'a' && ptr[-1] <= 'z') - || (ptr[-1] >= 'A' && ptr[-1] <= 'Z') - || (ptr[-1] & 0xff) >= 0x80); + ptr > m_original_expr && (ptr[-1] == '.' + || ptr[-1] == '_' + || (ptr[-1] >= 'a' && ptr[-1] <= 'z') + || (ptr[-1] >= 'A' && ptr[-1] <= 'Z') + || (ptr[-1] & 0xff) >= 0x80); --ptr) { /* Nothing. */ @@ -1903,7 +1920,7 @@ write_var_or_type_completion (struct parser_state *par_state, ada_structop_operation *op = write_selectors (par_state, name0.ptr + tail_index); - op->set_prefix (find_completion_bounds (par_state)); + op->set_prefix (ada_parser->find_completion_bounds ()); par_state->mark_struct_expression (op); return nullptr; } From patchwork Thu Mar 21 19:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87468 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3029338582AA for ; Thu, 21 Mar 2024 19:04:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id 3AE013858C5E for ; Thu, 21 Mar 2024 19:03:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AE013858C5E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3AE013858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047813; cv=none; b=nC/0tHlLDGoFD3+RW8jhvSFoD7wZsKLH7dK46b0i0a336Pv/40ecgOeJEZcNIMw5jUFDjJN/leFuIYl06oyZ11UVXRTx84RFbDWIojI3w9m5DYY7djXxm+jg5Q0EqFUVTdlGEYkTX+ENocCUeQR30kAkgmHP0rBUhwmNAML7lww= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047813; c=relaxed/simple; bh=8HP0pY5ndQAibJwMmruueldC16AKiuXouSvwecO7iXM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=MvDSS3Xv27LO8kI9F0v5muTV/X+ot/hXahdzGYcYZDn33SY+Q+FVt4oalg8rdA4f41Lj8Mu+kq6TxXEi5L1qjk+PBEXPse6PKwiN+AIjICJOOHekHGTf+hrIjViXwY/GG/EywZej/+IWuGZU+foczcXEi4/C8R+OKZkgJ7kl3mY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7d02a82018eso15599339f.3 for ; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047811; x=1711652611; darn=sourceware.org; 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=fX0l3NR+gjC1debaZ7CjVpa4vdctBfxVrsXkxo3PO8o=; b=g38/p8pMMCRR6lSECUPLu42zKJOpCR/+97FT023hbZGCJfdBu2w9J0+Djz3FTEhsWf XehJFad5eq4U63+OX2YjPVo3l0uPNjm98LywB1jltoS/v0NbDV9yXNvYJiYD519TkzSn iufdDMtnVv+tNGnlM/wr//Cw6VoJYB9gN81V3nVV4CRZnQQH1YarezUFOgSWDWP3Opq+ qLJAjGGwJK///iu5XxSS9YT1XlzrqMni1ZZAmPtywkLmG3SMJzmiG6PlDysfwssBrOkB l+EKncgMhZ7ep/2KnGkQVh7DBppnVf53REhgJX3KUn8tLr8/9JGTczW00HKZeSPBVeV0 SD4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047811; x=1711652611; 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=fX0l3NR+gjC1debaZ7CjVpa4vdctBfxVrsXkxo3PO8o=; b=E6bsJj8mmhL3u2dwO7qR7v+mt+ShUtQrNTykz4kAq0vtpuqmDQ/yd3qw0DuW8UIpTE dp/t6Q+I/KlcTrEia4Oxz6IOyV9xxNL1rsK6Wx/Wy7d37z48mSuLNqPP//mAcFjCA/D1 vmuqo8I0YUSV98wuVSAakWE4/FY8JQ5KVudVreCV36oy2wDOz8zMp/zHWQ5gocLisJPd zPN33SIG6oeEqzAxAYEj2TyDznJFqq/FF4FQ2Ck+651hhJ7OqBPB7i970F2a4x6OT5ur IzuwUZ0oqawMSzKtOuVinXZHXP9saGMbTvqHzilxQqdLvEyjmf45bXkaEbT5QW8Zl3J+ lADQ== X-Gm-Message-State: AOJu0YzEGNYOkD+cGOff6GMFM1usXLjqs3DJCgmX7KCmBThllK5xd/lQ HbJ+TH6A1QUUDuBIFvsbJFeyLrC5QKtQ23I7OM88t6zBT2CVlHg1ckNg3VM18DfhHLw0mFHuCtQ = X-Google-Smtp-Source: AGHT+IHQGCc3pywwcMkQB41f72Af9NkAe/4StHcteHjI8A+jkNKNJyxq0JZTdqcXrZVBEcurQQusZg== X-Received: by 2002:a6b:e211:0:b0:7c8:b7ac:23b with SMTP id z17-20020a6be211000000b007c8b7ac023bmr394398ioc.4.1711047811396; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:31 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:32 -0600 Subject: [PATCH 04/12] Move "int_storage" global into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-4-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch moves the "int_storage" global into ada_parse_state. --- gdb/ada-exp.y | 17 +++++++++++------ gdb/ada-lex.l | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 9452e63ab60..a8066414468 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -76,8 +76,19 @@ struct ada_parse_state std::string find_completion_bounds (); + const gdb_mpz *push_integer (gdb_mpz &&val) + { + auto &result = m_int_storage.emplace_back (new gdb_mpz (std::move (val))); + return result.get (); + } + private: + /* We don't have a good way to manage non-POD data in Yacc, so store + values here. The storage here is only valid for the duration of + the parse. */ + std::vector> m_int_storage; + /* The original expression string. */ const char *m_original_expr; }; @@ -86,11 +97,6 @@ private: static ada_parse_state *ada_parser; -/* We don't have a good way to manage non-POD data in Yacc, so store - values here. The storage here is only valid for the duration of - the parse. */ -static std::vector> int_storage; - int yyparse (void); static int yylex (void); @@ -1253,7 +1259,6 @@ ada_parse (struct parser_state *par_state) obstack_init (&temp_parse_space); components.clear (); associations.clear (); - int_storage.clear (); assignments.clear (); iterated_associations.clear (); diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index e1abf9adc25..109b95ccc35 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -465,8 +465,7 @@ processInt (struct parser_state *par_state, const char *base0, return FLOAT; } - const gdb_mpz *value - = int_storage.emplace_back (new gdb_mpz (std::move (result))).get (); + const gdb_mpz *value = ada_parser->push_integer (std::move (result)); int int_bits = gdbarch_int_bit (par_state->gdbarch ()); int long_bits = gdbarch_long_bit (par_state->gdbarch ()); From patchwork Thu Mar 21 19:03:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87475 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09D233858422 for ; Thu, 21 Mar 2024 19:05:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 91D133858C24 for ; Thu, 21 Mar 2024 19:03:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91D133858C24 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 91D133858C24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; cv=none; b=jdAb8Cf0wdNl9EiZKy492oYbVV1ctNDoVNcCUfQbhi1IL+ZcTsZih8MqHTr6NvNW7a5wFz7UtM4X5C/luyl5D81ckguAwm7vsyDj4Ntt4A+L0Mz7wknjNwuDkg4ha9ufahlhlNfjeoe9BbuDAk31/AlFbP3ZfI9emxBa7I361Ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; c=relaxed/simple; bh=XqDI63ct79j3ZlcmyzkEnUGfhRnDIVf8nv04a/DqvwE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ejOcLHzZHSWDQ5RkQ3Ixp3uwy1NQ0R5CULiIqR4XULrXjJ7pwKOh52Kt2H5iVNUSkCNE3+9dEOxDe3O/y4LERvyeWQbDfw2ZudznKkPZawibO5XvuyXVrm/dauJF/OId6P4ahE2ulKLrORWNrEm9qbQ5vHQ12qAUBzkHy96Ik20= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7c8713acecfso36163739f.0 for ; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047812; x=1711652612; darn=sourceware.org; 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=PJyUt0tS67tCdvtMPYZHpwtTyARkRMp277BRGQmdKRk=; b=GbN7UVzUoenK6cA8UfY5KSYeD9K/TpzPEVMZUomMUAjS8U+UQzrwPhYaUD5TxglHhd YqVJJRnRMG1ZnLks6SU0dHWMzOWbAATkI5sqbc3yVI/U5ftkv62DcvGxkqMZuMPSkJeL Kirc2cYXFP9UP53/v4FKSu22Ob60p8J192fvHb1gn4eGJA8wK6mCss6YaZb9rTIlQKFR jQ11qynGm69DO1BNQzPYqrPYRA28emjZ/Enati7zeK7l5j3b2LJZ4Faf5gY3qk7auTm5 IrdkW65jC/EmxIBwjMN7zKdfLGMJwBrIccgQzSwE7KqhY+FAh3IBxh9OZ+2GVFr7pxO/ jH0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047812; x=1711652612; 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=PJyUt0tS67tCdvtMPYZHpwtTyARkRMp277BRGQmdKRk=; b=YSYFXmsB5KlRqEiaIIe4p2ya7NH+SQT8N3/ccWhSU2GrDq38zLSkVA3ROeysvWIVeO 3jBgEfjhTnMhb3r6bbrq0o8fy0DEQqsK+RT4F5ZbC5MEOWH9ciDKRhvk/2iVwMGUybZ2 zeW4+l5m/jyQbleUg5otCv7hZ4zIY1CmrlxV/pZekdFxQ3d3jLW0kvzkBNPPCLbKoGsX XrlgQiTnvL3b5INqXHOvzNT6Lun6aSPrA+m7Z8jEPeTpsT+ojG65M9Yge9Ua0p3WJnDF VXX3wZNChz1yb4P43lTUy/gCTIuQA9KaNXwKrwQpDRXW615caWdA/NcJva+02xtBsS5M fK9A== X-Gm-Message-State: AOJu0Yw2ZUBjeSBgUtSay6ZDt5rA7aDNpoEBmAZgoNVXFjJCOxM+Gmw1 xnmvzbqoKEJWz6yVUDFKBH/r1EgWDBG68gZa0gzKoJHWN6+1JCN8yxrJ0jkYKVle/9HJfRCB+cA = X-Google-Smtp-Source: AGHT+IG5d6TCceb4Ha+3UgUf6k0FhVBZFLexmuc4XceivTMmOIuiXawogGwj8le5XjJJnmYkzzSNjA== X-Received: by 2002:a5e:c907:0:b0:7c8:ae00:1e71 with SMTP id z7-20020a5ec907000000b007c8ae001e71mr387893iol.5.1711047811739; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:31 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:33 -0600 Subject: [PATCH 05/12] Move "components" and "associations" into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-5-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch moves the "components" and "associations" globals into ada_parse_state. --- gdb/ada-exp.y | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index a8066414468..25809b6aa24 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -65,6 +65,8 @@ struct name_info { static struct parser_state *pstate = NULL; +using namespace expr; + /* Data that must be held for the duration of a parse. */ struct ada_parse_state @@ -82,6 +84,12 @@ struct ada_parse_state return result.get (); } + /* The components being constructed during this parse. */ + std::vector components; + + /* The associations being constructed during this parse. */ + std::vector associations; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -126,8 +134,6 @@ static struct type *type_for_char (struct parser_state *, ULONGEST); static struct type *type_system_address (struct parser_state *); -using namespace expr; - /* Handle Ada type resolution for OP. DEPROCEDURE_P and CONTEXT_TYPE are passed to the resolve method, if called. */ static operation_up @@ -336,16 +342,13 @@ ada_funcall (int nargs) pstate->push (std::move (funcall)); } -/* The components being constructed during this parse. */ -static std::vector components; - /* Create a new ada_component_up of the indicated type and arguments, and push it on the global 'components' vector. */ template void push_component (Arg... args) { - components.emplace_back (new T (std::forward (args)...)); + ada_parser->components.emplace_back (new T (std::forward (args)...)); } /* Examine the final element of the 'components' vector, and return it @@ -355,7 +358,7 @@ push_component (Arg... args) static ada_choices_component * choice_component () { - ada_component *last = components.back ().get (); + ada_component *last = ada_parser->components.back ().get (); return gdb::checked_static_cast (last); } @@ -364,8 +367,8 @@ choice_component () static ada_component_up pop_component () { - ada_component_up result = std::move (components.back ()); - components.pop_back (); + ada_component_up result = std::move (ada_parser->components.back ()); + ada_parser->components.pop_back (); return result; } @@ -380,16 +383,13 @@ pop_components (int n) return result; } -/* The associations being constructed during this parse. */ -static std::vector associations; - /* Create a new ada_association_up of the indicated type and arguments, and push it on the global 'associations' vector. */ template void push_association (Arg... args) { - associations.emplace_back (new T (std::forward (args)...)); + ada_parser->associations.emplace_back (new T (std::forward (args)...)); } /* Pop the most recent association from the global stack, and return @@ -397,8 +397,8 @@ push_association (Arg... args) static ada_association_up pop_association () { - ada_association_up result = std::move (associations.back ()); - associations.pop_back (); + ada_association_up result = std::move (ada_parser->associations.back ()); + ada_parser->associations.pop_back (); return result; } @@ -1257,8 +1257,6 @@ ada_parse (struct parser_state *par_state) lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); obstack_init (&temp_parse_space); - components.clear (); - associations.clear (); assignments.clear (); iterated_associations.clear (); From patchwork Thu Mar 21 19:03:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87478 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41C133858287 for ; Thu, 21 Mar 2024 19:06:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 0740E3858C31 for ; Thu, 21 Mar 2024 19:03:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0740E3858C31 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0740E3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; cv=none; b=omnaIAo5sxu7NLNvYBtKnO1SMQ+hdo3wItsMb0Ygi70NhWgRgIqiHpPNUON3axqTtdy/tLuLbdcQC+9wWdkc50IEZSlIKgvEr2U6RCjcqFJ1X32py/MSSNxETpXd1yzfpKWAtvvoP7APKETEFxml2fq8a09ij/5Cwfv3Y9yaV9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; c=relaxed/simple; bh=2/N9RF6ZdojHSJrfA/7+ZOQ0MUIQgcPitpH9w8NNjUk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=VY7iE4/Zxoq8YK74SldAd6nQkzNmls15Gi7NhfXU1lCtj4Iisi4KPPX48pl9Ga0ac4w4ULCDa8prdLyfLyzvdtx08QbtLYsu3728m6qGPt85qQmhMb+ruySqBp/foM2SBtZaYnqKReOuAlsKCHDWMauQrrP0mOmirlPtsbFBSCA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7c7476a11e0so63716439f.3 for ; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047812; x=1711652612; darn=sourceware.org; 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=ZhWRbzlIP46epc8EGTupLrldHq0Y0Ovu3HxyE70xmSg=; b=ULikgyR6wsRh9a41B0AnhtZ2LXv2jbbW+oMho+a4f9SRO9WEO0BmT9gwHVHRZR5ox9 DNm+sGVm3Op+WxKHp/OOsmNRxPr5mYv+LYqfcl1pUKDCCwdMrXJzoNumO44AliaPfwWK 8wB2bnDhkKofTdZVMOhFo27tLZCj0pa2X5aKG7UcFKmd32AbUhYgj5sSoSkxZuVnRRgE m5dDyMYb8OeLHinPiIG8OvCQt3UvjKV/D4/WBogKuYiStz8hyA7qYTgmU7vda6a4+9y+ IrV9aG5UW+AW4XFuF1pWvAqVelW3oNlQJjVPaMTabQz/dzUh+izhpixuCHNBbn9/KKXX Snlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047812; x=1711652612; 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=ZhWRbzlIP46epc8EGTupLrldHq0Y0Ovu3HxyE70xmSg=; b=Z740H1bfDer42rDw/CRoBSaZqSRp4kG2yBnOVcfxkrS7hH43Uc9zODU3zB4mjNSMC3 XA4TuuLPZ9OJ/+V91zRJugpMqVrSJSP0U6lCQ1TVcaz95Es433CSUzc8a58iwqZU2aF6 tDPldkN0EwXDcEcwYxLkBUNGCFCYwx//dLTWU7QW4sOgR/lIyh3GwjTYd1RizJNCr9N3 K/+zzkE42fk7jQQh2S/M7uksLI6q4iJ/Wct78JPKN1kr2GoxsgvYGulieu5Sz17LWoSv a25u90T3tE5KquJABtMTs1ZHS43vLVrrDTe8TGwddQQCf1MuNARcTHp4HrtiuXKjt4Vg TOEA== X-Gm-Message-State: AOJu0YxSS4QHmh8lT0hQ+yK8Qj+MOFWYwDZHzhYz8/vvGmB00SBGiTgw sHlpftTwrTBGQ8Jqvg0Tj8at7i0ZGlW1bX79XXX3DoYupfdzqhov1jAZNeGvgKcx4pG+OOngSA0 = X-Google-Smtp-Source: AGHT+IE0Gqsm1yHr6g9QIAwL5tgyKfVpoiR5JZrQdIQDFzKFVk4FEcMZsMQ/wmEpkPROD7Y9B5eCHQ== X-Received: by 2002:a6b:f416:0:b0:7d0:2834:a3c5 with SMTP id i22-20020a6bf416000000b007d02834a3c5mr353752iog.18.1711047812153; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:31 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:34 -0600 Subject: [PATCH 06/12] Move "assignments" global into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-6-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch moves the "assignments" global into ada_parse_state. --- gdb/ada-exp.y | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 25809b6aa24..1c5ffff3290 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -67,6 +67,9 @@ static struct parser_state *pstate = NULL; using namespace expr; +/* A convenience typedef. */ +typedef std::unique_ptr ada_assign_up; + /* Data that must be held for the duration of a parse. */ struct ada_parse_state @@ -90,6 +93,10 @@ struct ada_parse_state /* The associations being constructed during this parse. */ std::vector associations; + /* The stack of currently active assignment expressions. This is used + to implement '@', the target name symbol. */ + std::vector assignments; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -437,13 +444,6 @@ make_tick_completer (struct stoken tok) (new ada_tick_completer (std::string (tok.ptr, tok.length)))); } -/* A convenience typedef. */ -typedef std::unique_ptr ada_assign_up; - -/* The stack of currently active assignment expressions. This is used - to implement '@', the target name symbol. */ -static std::vector assignments; - /* Track currently active iterated assignment names. */ static std::unordered_map> iterated_associations; @@ -528,14 +528,14 @@ exp1 : exp { ada_wrap2 (BINOP_COMMA); } | primary ASSIGN { - assignments.emplace_back + ada_parser->assignments.emplace_back (new ada_assign_operation (ada_pop (), nullptr)); } exp /* Extension for convenience */ { ada_assign_up assign - = std::move (assignments.back ()); - assignments.pop_back (); + = std::move (ada_parser->assignments.back ()); + ada_parser->assignments.pop_back (); value *lhs_val = (assign->eval_for_resolution (pstate->expout.get ())); @@ -646,11 +646,11 @@ primary : aggregate primary : '@' { - if (assignments.empty ()) + if (ada_parser->assignments.empty ()) error (_("the target name symbol ('@') may only " "appear in an assignment context")); ada_assign_operation *current - = assignments.back ().get (); + = ada_parser->assignments.back ().get (); pstate->push_new (current); } ; @@ -1257,7 +1257,6 @@ ada_parse (struct parser_state *par_state) lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); obstack_init (&temp_parse_space); - assignments.clear (); iterated_associations.clear (); int result = yyparse (); From patchwork Thu Mar 21 19:03:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87473 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90A1F385841C for ; Thu, 21 Mar 2024 19:05:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 4282E3858C32 for ; Thu, 21 Mar 2024 19:03:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4282E3858C32 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4282E3858C32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; cv=none; b=w/A4fjoZO3twqydqqejbrxEbRZ0jYxf+C2RgkrzCxUXB6CDf1KSM5el4+ok6G4LOo/fOdtOYWOy/i4dUALbeJQgYWl05r2Y5ZzCjXe9jaPeoND2gyDNvelqQR25AzXUxUk/db4+q2BmP/RYCaky7sq2070f1eTqAPtBuWx7trTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; c=relaxed/simple; bh=Vs+0pl04h9yPge7XMYphniBgoRTNk2bW9PBbPj2PSo0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Cnu0MDsPz3or9ICGnf+kE+7g9owc1YAmGrfYfWZqbP3oo5VWxgshjGFsri7eZCwsm5dWQ1qlV380hdbHSID+iIoqTfJCc6raLeVgwUC+6/31zvCI+Vm8+qMSGWn0SCy13htrLtAK37I11XvixBYWXzTHQLQOKl/nf4ZUoPfl0II= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7cde3cbf03aso63082739f.1 for ; Thu, 21 Mar 2024 12:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047812; x=1711652612; darn=sourceware.org; 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=m+qaCVzs6MnJVY4UpyOlLPG+RwpJOP59MJp+5IeBNiQ=; b=b+OYxBKoVFqJKDLXXdisKPZcWy3F1/eVRJcHzboV6CaF9dLxkUDnKrQlY1qelIFD/H apCrY5O/m0SCv5PlkjH5NiXs/mlHgS9az/Uw1xslqdmYPKwjVgHKMN5rB61dsB4mhDBy Rr7wCNd3IS0QILfvL4MS0N4Eap/5dLG4fk0plDurnvZ7paLqpvyVLYXx2Kk/Z5LhCN5x YDWJTdmLNWjqaoRzsl/qt1HME55jpNbfWHaPAj8rAhZpH7KACYUY5QnHcxU8W10GleEV oNKYKMxpVu0OOOEY1RfL+CLB4EO1pEiX9+4sy5H6IU+OafWRtrJku4Xn+tcnNfSEX9Xh G9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047812; x=1711652612; 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=m+qaCVzs6MnJVY4UpyOlLPG+RwpJOP59MJp+5IeBNiQ=; b=qJwadFUYMuIk7y2OSGBAis9HjDku7NSIh1S1fqg1BT8NrVrG48zroEp3EvIsqRpJms 981j1SpGFV7Z0WPakRjFt0gFxSZpYqgv4b1nxbBqsmHg0LTYuQraxv0NRsmrP5EK1Hae bMaeMEfp2kjcGFDguzdAdUkHwJnvcG6fn8w4bJS90yzrLWWIP+/prFrKqT4zDSe3fzbY E4+TWjZLXvh7FPdDz6mnjW50e8BVbxSvArsB1gbvvnoWfKyhwDGFRYZF3udM9Kj0nXhz oyDeZhO5mqRE9lBoHcc9F4Qxt32Vm7ksEpFOF408MBBuntQJArBPW6j42pLilt9j35t8 1gXA== X-Gm-Message-State: AOJu0YyUPOI9AWWeW5CizOaa7A9jYrbcaDvfOASI1yGmjxqnImpkJiML J+tJo38B01WTK565RUm7fAP/dhZ920ou2McsRpnvljGZyZuzfzoIo2s5HwDnqAFYGQFrMciy6dc = X-Google-Smtp-Source: AGHT+IEmXt32rxY7scNZwCHZfJOPvnNO4cTgPv4Gxg8rZ/wRX5Gn31wopHDGEmek9mc1cm1ibaRtYA== X-Received: by 2002:a6b:ed01:0:b0:7cc:32f:7f6e with SMTP id n1-20020a6bed01000000b007cc032f7f6emr354325iog.5.1711047812519; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:32 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:35 -0600 Subject: [PATCH 07/12] Move "iterated_associations" into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-7-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch moves the "iterated_associations" global into ada_parse_state. --- gdb/ada-exp.y | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 1c5ffff3290..615b74d14d8 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -97,6 +97,10 @@ struct ada_parse_state to implement '@', the target name symbol. */ std::vector assignments; + /* Track currently active iterated assignment names. */ + std::unordered_map> + iterated_associations; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -444,10 +448,6 @@ make_tick_completer (struct stoken tok) (new ada_tick_completer (std::string (tok.ptr, tok.length)))); } -/* Track currently active iterated assignment names. */ -static std::unordered_map> - iterated_associations; - %} %union @@ -1128,12 +1128,12 @@ component_group : { std::string name = copy_name ($2); - auto iter = iterated_associations.find (name); - if (iter != iterated_associations.end ()) + auto iter = ada_parser->iterated_associations.find (name); + if (iter != ada_parser->iterated_associations.end ()) error (_("Nested use of index parameter '%s'"), name.c_str ()); - iterated_associations[name] = {}; + ada_parser->iterated_associations[name] = {}; } component_associations { @@ -1142,12 +1142,12 @@ component_group : ada_choices_component *choices = choice_component (); choices->set_associations (pop_associations ($5)); - auto iter = iterated_associations.find (name); - gdb_assert (iter != iterated_associations.end ()); + auto iter = ada_parser->iterated_associations.find (name); + gdb_assert (iter != ada_parser->iterated_associations.end ()); for (ada_index_var_operation *var : iter->second) var->set_choices (choices); - iterated_associations.erase (name); + ada_parser->iterated_associations.erase (name); choices->set_name (std::move (name)); } @@ -1257,7 +1257,6 @@ ada_parse (struct parser_state *par_state) lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); obstack_init (&temp_parse_space); - iterated_associations.clear (); int result = yyparse (); if (!result) @@ -1707,8 +1706,8 @@ write_var_or_type (struct parser_state *par_state, if (block == nullptr) { - auto iter = iterated_associations.find (name_storage); - if (iter != iterated_associations.end ()) + auto iter = ada_parser->iterated_associations.find (name_storage); + if (iter != ada_parser->iterated_associations.end ()) { auto op = std::make_unique (); iter->second.push_back (op.get ()); From patchwork Thu Mar 21 19:03:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87472 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CA353858417 for ; Thu, 21 Mar 2024 19:05:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id DB8883858C35 for ; Thu, 21 Mar 2024 19:03:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB8883858C35 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DB8883858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047817; cv=none; b=E2Vu1uMB5K0NIuC6UhmeGiteQjcFunp6RBfiEVq9xEj1vM5MvYy1JGK+IyNjfPIDunBN8Oc/vZjiYbZCPxVRY/Uo6PwaupMGHs291D0f2oSuhUzBtUCx1hKesr0uqYojHgWvasTG8RRpjLGLHRUoxUwzt62tOctu4Acq3gDN7ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047817; c=relaxed/simple; bh=20W2CFnlnQzJPpmwfBiOJ13jmM3Ax4u4HOE+4Rj/j00=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=aJmxiErFBl8Hzbz5Jykc0oWnHCjgi6Lvk9rMJba3FjjxK3MU0x+RluteGDvdWq27QQeuftkgN9Dom1URFfSyhkaxoBJ+rWuuHMxnES47mqYRf9yr2ZTV40+zkdv32dzN4UtrXcfwHEdmFTfJKLybTQs4NmD1PcBvyyniGloJQU4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7c8dd755793so35562639f.0 for ; Thu, 21 Mar 2024 12:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047813; x=1711652613; darn=sourceware.org; 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=s858rJiDoxBmkCNaQjfP09kTRxIas8tyMzMyvwM8JTM=; b=gi62vqrKwaUTEka8JARbss7cOV0SohFQScRK2YGkB0aGqgl+FbyIPZ2CgpyExlI2B8 /FTb7C8jcnyqf6sfPgKIBMjRE88GnBq2Rt/mLSg/v4+m847iT0mYyb88xm19yd2HNKdR 791io52Ba6tzTXnjrtsPm5oEafsSfthy/eCBmh2m4Bo1QEFYN4ePFOmhGYdhvbC1VUcp squJ/xvD06Y/k2Uhz3fYoNUDktb1AEHap/bOJezwtThb5CxJ1FAw7QpY29gsUhqQaqg5 dHRoZxGGZkIcOBb++9vxMwi2xp9KxQEKWYCxamr15kn2m9Uh17DBQLSiM5gBtVFrjeDM dvQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047813; x=1711652613; 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=s858rJiDoxBmkCNaQjfP09kTRxIas8tyMzMyvwM8JTM=; b=jL2pFUczfDdIBVxecWw8eolPjVTaIQRnuK10RSuUpDiwC5Jy9g0GhBLyph6Qd+AQgi hJ/mOh2YCVvlKPSjwlRciOvzw49u8guFgays1tJ7I8pGIVewVwJteAXJZ3JRVrxU/GtY tQJOckBQRnCWe6OZSC+3zOuwDBceHDHTYLAjuoBr6w+BtT/7eKH97hbSD0XqrEbFlTS4 G0uXu6OzehRNGgM2uYBKT36SFKqgwHL6CV1C7OMiueuxUPBMM98klw1v5Tpkra9Wx8DX JfmOSqhpyCIWxBY/E0HpB+ISkC/LDHpC2M2wg1mOZ8xkq8iQUf2MyaC7x+G39b2K5/qt e+6A== X-Gm-Message-State: AOJu0YxtO5iau0pSP9LBgU58oBb6amKRs+xmx9OyS2UWWqCbSSpiB5Xd t8t9ZqPmHnvIvVEfAcE/4ayX0SW5GziWGSdo/OVX6DevTi0lUlg67IUmwO3QkJk18ledrsJY3m0 = X-Google-Smtp-Source: AGHT+IExNVmFT/weovnX8ZUHU5aCW/XI8yjiFh5tfm4ptaywo9lbK7tZ6W+Yfd0R7OoXr0QGlM7C5Q== X-Received: by 2002:a6b:ea08:0:b0:7cb:6050:805f with SMTP id m8-20020a6bea08000000b007cb6050805fmr391766ioc.1.1711047812899; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:32 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:36 -0600 Subject: [PATCH 08/12] Move "temp_parse_space" into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-8-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch moves the "temp_parse_space" global into ada_parse_state. It is also renamed to remove the redundant "parse". Finally, it is changed to an auto_obstack to avoid the need for any manual management. --- gdb/ada-exp.y | 28 +++++++++++----------------- gdb/ada-lex.l | 7 ++++--- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 615b74d14d8..73178a58a0c 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -101,6 +101,8 @@ struct ada_parse_state std::unordered_map> iterated_associations; + auto_obstack temp_space; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -1234,8 +1236,6 @@ primary : '*' primary %prec '.' #define yyrestart ada_yyrestart #define yytext ada_yytext -static struct obstack temp_parse_space; - /* The following kludge was found necessary to prevent conflicts between */ /* defs.h and non-standard stdlib.h files. */ #define qsort __qsort__dummy @@ -1255,8 +1255,6 @@ ada_parse (struct parser_state *par_state) par_state->debug); lexer_init (yyin); /* (Re-)initialize lexer. */ - obstack_free (&temp_parse_space, NULL); - obstack_init (&temp_parse_space); int result = yyparse (); if (!result) @@ -1323,7 +1321,7 @@ write_object_renaming (struct parser_state *par_state, if (orig_left_context == NULL) orig_left_context = get_selected_block (NULL); - name = obstack_strndup (&temp_parse_space, renamed_entity, + name = obstack_strndup (&ada_parser->temp_space, renamed_entity, renamed_entity_len); ada_lookup_encoded_symbol (name, orig_left_context, SEARCH_VFT, &sym_info); if (sym_info.symbol == NULL) @@ -1389,7 +1387,8 @@ write_object_renaming (struct parser_state *par_state, if (end == NULL) end = renaming_expr + strlen (renaming_expr); - index_name = obstack_strndup (&temp_parse_space, renaming_expr, + index_name = obstack_strndup (&ada_parser->temp_space, + renaming_expr, end - renaming_expr); renaming_expr = end; @@ -1608,10 +1607,10 @@ static void write_ambiguous_var (struct parser_state *par_state, const struct block *block, const char *name, int len) { - struct symbol *sym = new (&temp_parse_space) symbol (); + struct symbol *sym = new (&ada_parser->temp_space) symbol (); sym->set_domain (UNDEF_DOMAIN); - sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len)); + sym->set_linkage_name (obstack_strndup (&ada_parser->temp_space, name, len)); sym->set_language (language_ada, nullptr); block_symbol bsym { sym, block }; @@ -1719,7 +1718,8 @@ write_var_or_type (struct parser_state *par_state, } name_len = name_storage.size (); - encoded_name = obstack_strndup (&temp_parse_space, name_storage.c_str (), + encoded_name = obstack_strndup (&ada_parser->temp_space, + name_storage.c_str (), name_len); for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1) { @@ -1765,7 +1765,8 @@ write_var_or_type (struct parser_state *par_state, { int alloc_len = renaming_len + name_len - tail_index + 1; char *new_name - = (char *) obstack_alloc (&temp_parse_space, alloc_len); + = (char *) obstack_alloc (&ada_parser->temp_space, + alloc_len); strncpy (new_name, renaming, renaming_len); strcpy (new_name + renaming_len, encoded_name + tail_index); encoded_name = new_name; @@ -1987,10 +1988,3 @@ type_system_address (struct parser_state *par_state) "system__address"); return type != NULL ? type : parse_type (par_state)->builtin_data_ptr; } - -void _initialize_ada_exp (); -void -_initialize_ada_exp () -{ - obstack_init (&temp_parse_space); -} diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 109b95ccc35..90cb5ba1b8a 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -531,7 +531,7 @@ processReal (struct parser_state *par_state, const char *num0) static struct stoken processId (const char *name0, int len) { - char *name = (char *) obstack_alloc (&temp_parse_space, len + 11); + char *name = (char *) obstack_alloc (&ada_parser->temp_space, len + 11); int i0, i; struct stoken result; @@ -593,7 +593,7 @@ processString (const char *text, int len) const char *lim = text + len; struct stoken result; - q = (char *) obstack_alloc (&temp_parse_space, len); + q = (char *) obstack_alloc (&ada_parser->temp_space, len); result.ptr = q; p = text; while (p < lim) @@ -706,7 +706,8 @@ processAttribute (const char *str) { /* This is enforced by YY_INPUT. */ gdb_assert (pstate->parse_completion); - yylval.sval.ptr = obstack_strndup (&temp_parse_space, str, len - 1); + yylval.sval.ptr = obstack_strndup (&ada_parser->temp_space, + str, len - 1); yylval.sval.length = len - 1; return TICK_COMPLETE; } From patchwork Thu Mar 21 19:03:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87474 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B57C73858283 for ; Thu, 21 Mar 2024 19:05:12 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id 1105C3858403 for ; Thu, 21 Mar 2024 19:03:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1105C3858403 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1105C3858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; cv=none; b=dNvXBlNvd+ucvQU+9tklGZNgNJaC0dfq+hS5KwkNOmXDo0GJvzzm658mjp94k9930hhuHs38h4su3WcwKjfj0lkgVEVAdygz5+yNKtr6lCGpKsx1wgqgTcCvHTzBvf1YU9BduAGnmd88eT+Czpr4e92+MUXCsZiEvuGJ815B1YU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; c=relaxed/simple; bh=/dNOqWWEHMfdnA40+h8eDe/Uzlxj0EjFe5gD+kk8WFg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=MiBmLYJcwvxDhl0u1gtgffWUzDalmDGh7R1HJayWeSu0SpKEfxNeeFxqtMG8+7rKKAf7fu+Zw822vt2BDmuOuzTTyBhVdRblrtC0uQWPmevZzJah3Gl7D4Qr6wPo/MUvonezJNqrDJ16xEln6ejVSk4gtx9FGIU+qxs2j3m/M7w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7cc01644f51so58749639f.2 for ; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047813; x=1711652613; darn=sourceware.org; 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=IWz4Nbe8giB4SVPTDGY3CGEyja3OG4YrsR/IEcb66yk=; b=HQyKBUBP8JPwzsDf9rXZZmI167RSU8lroyeGIUvmCw1ZjbRP897U0IeyDOYk+KvxQt dT4mZ1IY1DvaEHo2yq+TAnGd7ZjLDm4W71Se6W+R6Wo3GiHbq74TkF9HKgUkJkQao/OE fjtYyAFem8Vq9ehfwzAew/q2vh282hfjK+i+XWjm6m8+vFj2+D3b5pDO4wsLmg+mufdt wFSByi1SC1KLtCRE0hrl5moLBKmnMXPjO6UR9Wc1CWMTB9OqU8P2wX8UG5evRS9z1Z6g fYNyP8Z2rxz+hyyi2Y0BJwOZHJ+sBJX4GFCu9hs73r/RzHkE9vfF7fnr4QvsnmDJGGhM pj1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047813; x=1711652613; 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=IWz4Nbe8giB4SVPTDGY3CGEyja3OG4YrsR/IEcb66yk=; b=jML+7tFEJD7GBZgrvBiQQgChjDJ2POTyJHwoJkBBK0exI8Ay9mj3qYRUxZQcv3fpxh HxPmX+uPOjrXcBodeiXG3zBPz700N4oQUm0OQmSIb6OvOfK4jDjqmW3ExeL4Un944ivx /6MdCvfqq1FR5oj4qIfW6joIvOMGNDtiHrGzJUyxv/xUS5QRECUoixntwHzDvWFAH3xG NIG6ppcjtFTH5QNrfOZmihRZFXpT8TGBv0gByshU34ei+qtmmL9ZElezcFWIuswJMDPg Y6Og2soEYsNLBPIfG8j9rUQAXukD488IK07+BnFYE5AA1hZPAcMw2E7DspPsd3kVdkw5 7Gwg== X-Gm-Message-State: AOJu0YwolcArXF7CPCWgTRRO/fdk8UvsTjQTpGH8d8LPTAbL5rHquaGC ztJQZAYqrqyfn1kAT/TTLeUOSMkpx8hBeMXaTZbiXVaqP0AjZYZLhDymhVZ0BBlSrZaLEuxr/6c = X-Google-Smtp-Source: AGHT+IG2SWk5rKPY57/XcYURnpqMCP6rjjygZYZZpDcS7LEJBYrumY1lVzyaDeu0qhJlzS0OBvtzFg== X-Received: by 2002:a5d:8d8f:0:b0:7cf:261e:3941 with SMTP id b15-20020a5d8d8f000000b007cf261e3941mr416939ioj.10.1711047813258; Thu, 21 Mar 2024 12:03:33 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:33 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:37 -0600 Subject: [PATCH 09/12] Move "paren_depth" into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-9-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This moves the "paren_depth" global into ada_parse_state. --- gdb/ada-exp.y | 3 +++ gdb/ada-lex.l | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 73178a58a0c..2b058571492 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -103,6 +103,9 @@ struct ada_parse_state auto_obstack temp_space; + /* Depth of parentheses, used by the lexer. */ + int paren_depth = 0; + private: /* We don't have a good way to manage non-POD data in Yacc, so store diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 90cb5ba1b8a..9161c4377c0 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -108,9 +108,6 @@ static bool returned_complete = false; pstate->lexptr += 1; \ } -/* Depth of parentheses. */ -static int paren_depth; - %} %option case-insensitive interactive nodefault noyywrap @@ -268,7 +265,7 @@ false { return FALSEKEYWORD; } [-&*+{}@/:<>=|;\[\]] { return yytext[0]; } -"," { if (paren_depth == 0 && pstate->comma_terminates) +"," { if (ada_parser->paren_depth == 0 && pstate->comma_terminates) { rewind_to_char (','); return 0; @@ -277,15 +274,15 @@ false { return FALSEKEYWORD; } return ','; } -"(" { paren_depth += 1; return '('; } -")" { if (paren_depth == 0) +"(" { ada_parser->paren_depth += 1; return '('; } +")" { if (ada_parser->paren_depth == 0) { rewind_to_char (')'); return 0; } else { - paren_depth -= 1; + ada_parser->paren_depth -= 1; return ')'; } } @@ -349,7 +346,6 @@ static void lexer_init (FILE *inp) { BEGIN INITIAL; - paren_depth = 0; returned_complete = false; yyrestart (inp); } From patchwork Thu Mar 21 19:03:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87477 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22F783858295 for ; Thu, 21 Mar 2024 19:05:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id 99E7F3858407 for ; Thu, 21 Mar 2024 19:03:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99E7F3858407 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 99E7F3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; cv=none; b=jQm4SoSnZZPq7qcp2wdX9/2z7wpygiKRwmKt/lGQIsMqFMup0w5vPYL/1tFb83WvPxBJjLDA/f64cXAUb9Y7DINWgnyU/nv3odELYK//rGTsitvX4nhBfoONB/iiukLwlzBGUqkCV5QjObUxJPkSTmijYhn7CbpXAy+Hc0Sx2o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; c=relaxed/simple; bh=lx6KOCaFbOKyHlooUlP8KrNsSu+VWnIwyGlT5OWI6mM=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=L2tkAK1CVXVCCy68HZMWI6C2rUaQPWRFUHq1qYDnZWdktrSZ70axZefc39Tj/gmb8PKW5wPNWsu6T2CIXi/zKlhy1+mOge6PPA6x3yP2iY4aUP3Xds7eSRi9fKPrdsdjdcO6dEYUAj2jbDgftj6DCANNmZt8HT0AczlGOl0bF3Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7cc692af9ebso57209839f.0 for ; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047813; x=1711652613; darn=sourceware.org; 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=Z3AX/XxwtV0930oziZ13YJ+faSfR0HHPV4xJ2Zftx8I=; b=HDhs8TvK/brlx4Rshl3JdRWgNnwB7ZIFe2NC60fhxt2rmioaYtBswLh+NvWAqpdCla Yy1I1PnfBFFwdaRncU813eNg5RwzZRlfbTAgcs7YCZmTRRstrglolvrurtj0NSI9EuyP 2PWa8rXCebn7AcjHjbYNvuMxlR/403SVTOZJbf7pHk6V6r1ioiulVfJmAoU3/eaXnKHg SPOroiiLMUSiHuMCUaGh44laPu7K87oRY6w/NwPU+Qf5J+c5q5FQUVDdJ+Y3SrOvovYA WQQ2D3AqJ4yFp606FiE20uf3wfVvfS4IMGHycTds2T4BRz7l9MrrNS2pPIziqD0Ttp3r Xxug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047813; x=1711652613; 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=Z3AX/XxwtV0930oziZ13YJ+faSfR0HHPV4xJ2Zftx8I=; b=AHE9ZFsLGgRZeM/4lWni4nmOGEfRTxViTmaQtAO5CwkogwxP4fHd4n3FY4+OP9jLam UJn+ri4n0kc0sj0J7pq5M4EjzY6/6bRDvpBITtQiQOZF9Rxd9DiDPybCiE8v1m6pjJfM UZEOETYidNpBxxZ5PEtK/6FJL78QxW4XZX/TEBpTva3A+CuJA5ELP2Xza3xmpL3KosZP 8WK3wCVah7hRl6b9jWig+gkGUvRXmCBeL74Pq8m11fgiRlsU3wos3O7vHsrikuXx+tTZ rxcsljFooGk9fFqY5Zv7iBgK1IsQzxARzyImcx7+mwHYSZ+pYLYCbxHys9PjustkkT06 O+dw== X-Gm-Message-State: AOJu0YwUAk+ONsN1k17ROiR76gjMONKQlR1H3vuGmM5DRO4eBtlB5yLB EBf+ItuZQPZKcl2B7ymoOh9bIrQmRdrnWjk2Hr5Wpvn9fcfzBVJ1K7uV/oO7rhZRLM/I2JPd75Y = X-Google-Smtp-Source: AGHT+IENcvFLHfhRY7SWVOPuzAS4Fpj/5BKjYTOAjHI7+GwGYtvTQA9tI+IEanuXmRw8rCoZelcVyA== X-Received: by 2002:a5d:9642:0:b0:7c8:41c7:6ac5 with SMTP id d2-20020a5d9642000000b007c841c76ac5mr365761ios.6.1711047813691; Thu, 21 Mar 2024 12:03:33 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:33 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:38 -0600 Subject: [PATCH 10/12] Move "returned_complete" into ada_parse_state MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-10-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This moves the "returned_complete" global into ada_parse_state. --- gdb/ada-exp.y | 7 +++++++ gdb/ada-lex.l | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 2b058571492..12f676b75de 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -106,6 +106,13 @@ struct ada_parse_state /* Depth of parentheses, used by the lexer. */ int paren_depth = 0; + /* When completing, we'll return a special character at the end of the + input, to signal the completion position to the lexer. This is + done because flex does not have a generally useful way to detect + EOF in a pattern. This variable records whether the special + character has been emitted. */ + bool returned_complete = false; + private: /* We don't have a good way to manage non-POD data in Yacc, so store diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 9161c4377c0..11221723eb3 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -78,13 +78,6 @@ static void rewind_to_char (int); Defining YY_NO_INPUT comments it out. */ #define YY_NO_INPUT -/* When completing, we'll return a special character at the end of the - input, to signal the completion position to the lexer. This is - done because flex does not have a generally useful way to detect - EOF in a pattern. This variable records whether the special - character has been emitted. */ -static bool returned_complete = false; - /* The character we use to represent the completion point. */ #define COMPLETE_CHAR '\001' @@ -92,9 +85,9 @@ static bool returned_complete = false; #define YY_INPUT(BUF, RESULT, MAX_SIZE) \ if ( *pstate->lexptr == '\000' ) \ { \ - if (pstate->parse_completion && !returned_complete) \ + if (pstate->parse_completion && !ada_parser->returned_complete) \ { \ - returned_complete = true; \ + ada_parser->returned_complete = true; \ *(BUF) = COMPLETE_CHAR; \ (RESULT) = 1; \ } \ @@ -346,7 +339,6 @@ static void lexer_init (FILE *inp) { BEGIN INITIAL; - returned_complete = false; yyrestart (inp); } From patchwork Thu Mar 21 19:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87479 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D84A3858288 for ; Thu, 21 Mar 2024 19:06:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id F2106385840E for ; Thu, 21 Mar 2024 19:03:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2106385840E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F2106385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047823; cv=none; b=o9uvq5cKghvefWdU/3WPXPUOxhnFwOtP/WvA6gl4KICN8pSKqQUcuRNObznEzFtEFIjefEjBLR0ysU++qeQE+lIUmuIwwFjmCsk5RA9+zP3rxC3+ju1K3uYNesvjQkktgtz6r+NEemya0tPKz7cER00dMNV19HhfFW8kPpK8U9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047823; c=relaxed/simple; bh=gOK9VweWXYLp5fIk6+wphyrkdkc1YcTJjSRICLNnIkg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Gtn88pucI46hSVYnhnbLWYaD9ArcvE17ksAxMQiPeC3/tSUE98aK39/0w6E9ep15ee/JYV0KWtmJcYfDnu8q79fjPS4SOgn62A5PnAZkAZF8e/VLHAu0OiLf462TxBo5SHZVCh/7rbMZ+fc/8fPq7gKxDGTuXIouPJJmDVleHU4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7cf1a21ab1dso56540539f.2 for ; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047814; x=1711652614; darn=sourceware.org; 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=FN+Nt2/qeHzIPkN4QQwlcRp28h+5NoIDxevkp8Udk1M=; b=FX6f7QHdDAlhvXgSMmt92/KfCTxsoU5XBsLtvVu8EJIwJEJGS3kBRci3AxLWMeeqhf yEn7/8AH9lvR3WGlrA9awIQMnTf4g1e/kZd9MPUZN16ffdfbOJP7lpwYcoFqUvO15Y5T 480hn4QXksjENfqnn7exVA5VzPTe59fqU3wSvZxv4DwsO1yGiXWU56nElP/eyDdNjqz+ LHOABg/OwRrQEQ+dK4fdXX7yGJl686GtIOpg6qhBBGCgjpEtDgG5mf24N/jfFbPdH+Rt eeMJpsnqzup09062Ev3K3NwEnnOAoGiqM3vgpvRM8GDWLpre6ztt5ln8xRW9BRLlOJ2H dIFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047814; x=1711652614; 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=FN+Nt2/qeHzIPkN4QQwlcRp28h+5NoIDxevkp8Udk1M=; b=ZES+KI/Ot+se43IFTZodrkwreXrNY6TyhYinOCljGJkYBI8x75QuI2uPuCRc5F581a 6RckXd93O961nBPJKi6YxxgfAOvWOcr5zwdJA/Kio3wCFpxIEvpapGHqHg64IVOY2JlV rbvDtoJgYOO3M5y2b4uY8MpMXXWCfT24TSm0lALU2AqqLSI7rAffLdLWylqUcU6snRXa jxoKioeBrBLTb10dxfS+EVHpDFzoza6yUIoyEcAfk/5WffGWJhwbXZmSqUPx4p2763Ln +6vzN9ACthbjdsg0tQyvFytHkDQ1rZYpdkWqyE+dH1ciUioHTdAwmqw/MEAYLX3AA82d uh0w== X-Gm-Message-State: AOJu0YzrPJOqNbL6nTvU6Ck1UzQ8T7UMZDeWmVtwDmIBUQ53fPsWxEV+ e1oaPALA1FnpglW89e7l0X8PcOcy6h33DWMf7QjEITTDn4iTpfg6YfhMwYSAXogRZvBpq6sRZn0 = X-Google-Smtp-Source: AGHT+IECV6zFtutHFvmFTdfiwtAWQLhb1doa6eZ0gfByO3UU1X44PNBpywcne5YJJZaBM0KNFfKZwA== X-Received: by 2002:a6b:db11:0:b0:7cc:75fd:cd37 with SMTP id t17-20020a6bdb11000000b007cc75fdcd37mr378827ioc.19.1711047814089; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:33 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:39 -0600 Subject: [PATCH 11/12] Remove "numbuf" global MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-11-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The lexer has a "numbuf" global that is only used for temporary storage. This patch removes the global and redeclares it at the points of use. --- gdb/ada-lex.l | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 11221723eb3..4e99eaab036 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -59,9 +59,7 @@ DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER #define NUMERAL_WIDTH 256 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1)) -/* Temporary staging for numeric literals. */ -static char numbuf[NUMERAL_WIDTH]; - static void canonicalizeNumeral (char *s1, const char *); +static void canonicalizeNumeral (char *s1, const char *); static struct stoken processString (const char*, int); static int processInt (struct parser_state *, const char *, const char *, const char *); @@ -114,6 +112,7 @@ static void rewind_to_char (int); "--".* { yyterminate(); } {NUM10}{POSEXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); char *e_ptr = strrchr (numbuf, 'e'); *e_ptr = '\0'; @@ -121,11 +120,13 @@ static void rewind_to_char (int); } {NUM10} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processInt (pstate, NULL, numbuf, NULL); } {NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); char *e_ptr = strrchr (numbuf, 'e'); *e_ptr = '\0'; @@ -139,23 +140,27 @@ static void rewind_to_char (int); floating-point number is formed by reinterpreting the bytes, allowing direct control over the bits. */ {NUM10}(l{0,2}f)?"#"{HEXDIG}({HEXDIG}|_)*"#" { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processInt (pstate, numbuf, strchr (numbuf, '#') + 1, NULL); } "0x"{HEXDIG}+ { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext+2); return processInt (pstate, "16#", numbuf, NULL); } {NUM10}"."{NUM10}{EXP} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processReal (pstate, numbuf); } {NUM10}"."{NUM10} { + char numbuf[NUMERAL_WIDTH]; canonicalizeNumeral (numbuf, yytext); return processReal (pstate, numbuf); } From patchwork Thu Mar 21 19:03:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87476 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F64C385828F for ; Thu, 21 Mar 2024 19:05:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id 315153858412 for ; Thu, 21 Mar 2024 19:03:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 315153858412 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 315153858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; cv=none; b=BNxsmm9WmzayzzA+3QRzlZOCrYjlrQZUXAryCzPR+JsdlOxQYOSJ2NHD8yvyqeZwct4sNAlHLKmZ6oNEFXBzpd4FxDpMxhRFo5qUdRGMGzJDAWgLBEvy8/gVKH6iZvKLe9Z6ze1NVz42seMPoplHkuroS68SpQmmSZat8bQLei8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047821; c=relaxed/simple; bh=zGr799s7Zv4e9N8p/kkTpoqugNcUe4McVsFCAxubs5k=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=MGf5ddcujPq5XweLbcQNRug8RYbvNWAGuSvjxGT5J5XFQ1lawL9zi7BDD57qAoUs/Xr8+WnbRRJm9MXpbtw/cCl+uZ8hkTuD7a2zCU5UlkHprzCce7Tb7BKKAFlR5y9Znla76EQKZHJFmVAOSaTSwNP7mDxuYKy4kWziX+1V/oQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7cc5fdb0148so52282439f.3 for ; Thu, 21 Mar 2024 12:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047814; x=1711652614; darn=sourceware.org; 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=MxVDv2SCyjsyjAQZY1eqXD45Ns2k7ZA8eFlW0okARLs=; b=dlyo1ToEQzQxOTiQAVV1P7Ojpt9C73bTOWV8wZGdL32frq0zqvzlNNgChhNFA3NBWF C8PLMTVtA9LsEIjtW4pnZRXZrbQoAvtwdQKVs5sBL2Amgku64/gdoW5Fxh17FZWzhs5a Dlt9T5sqm4zraROU7sUQzSQtMyeTIjAaRUI+7q0+bhdUmjfu24T9ZctA1sfWR35R23d8 w4dxIqmsBGRA9WHS2JKlSeyoEgVSc+q2HtWjNuj+Y6WJUKeYURwgWCRkPU2S6iN8VN8P t8NmqTwxICHe7fjrjQWZLXSIH7fi49btD8XFrsP2luYe8XtubzB0a1jzBZcDDpt/bG+U vl7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047814; x=1711652614; 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=MxVDv2SCyjsyjAQZY1eqXD45Ns2k7ZA8eFlW0okARLs=; b=uv0vTsrQ6T70M0Tmj6gvh/HM3l5+1mecmR6EV3e6qvQ3KdCarKqaWFKtAp6YY4aVjl NxoDKNXWItsGUBYIZqPFzqKuBPUpi/tsa+1kPkQenFd9uzGy0zju8gu1YivngxdOjd14 B9H8EsLg0IHWZXnpC8TYVdbkryBVp5kbUhTw+C444JOY5k72JTGkPoYf0ovK+THlPQtq 09ESQYs2ru+QPO+PTJ3pAkHl3EnblGiKDTE3xsnXoBS896QMz/XGi9M5Wjx33ZexcJuE ssDSIsg9zQthqLXffgrw9GYW8h4nJpMRx0qy4i9vnrMiA4GZh1kBMGi/zr06pGF/76M7 AXGg== X-Gm-Message-State: AOJu0Ywpxny48PRkIMdq5iu0Yx2sNGB/p7KkdTgUD49bj1I//CBizdP3 we8ooeKKbnvRBqSiFX8FJ8BEY6M3S3yEHtlxDH/hT+2gmqhjoCPwvqgU0bV5TWZwPYu45sGlnXI = X-Google-Smtp-Source: AGHT+IErH2wL0RK0IvtMzPAXd/fMqBmto+HT72MreWOGpdtRNyG4iP1k+BGiTsG+MMVIANyxQwx6Yg== X-Received: by 2002:a5e:d60b:0:b0:7c8:4c27:810e with SMTP id w11-20020a5ed60b000000b007c84c27810emr303698iom.18.1711047814426; Thu, 21 Mar 2024 12:03:34 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:34 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:40 -0600 Subject: [PATCH 12/12] Constify ada-lex.l:attributes MIME-Version: 1.0 Message-Id: <20240321-ada-iterated-assign-v1-12-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org While examining the Ada parser globals with 'nm', I noticed that the lexer's "attributes" array should be const. This change moves it into read-only storage. --- gdb/ada-lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 4e99eaab036..1b1aaf89005 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -662,7 +662,7 @@ subseqMatch (const char *subseq, const char *str) } -static struct { const char *name; int code; } +static const struct { const char *name; int code; } attributes[] = { { "address", TICK_ADDRESS }, { "unchecked_access", TICK_ACCESS },