From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 173643858C60 for ; Fri, 28 Apr 2023 16:02:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 173643858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7606d44604aso824937839f.1 for ; Fri, 28 Apr 2023 09:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1682697777; x=1685289777; 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=ozlltezDHlBPOujzmITgxypvbc4RquszrV39qlta8mM=; b=Cw7yw0grRxGFGiJsT67kR95cXER0A/IDNIsIDmKDj8KcmhZS7pr+aEWSntdvHAVm46 BYvV+wFPV4ibw1DA0EbsZHEtA1JMouU/JsLBHC4dqMRfqfdU4KF0mJNxzCcULVkGUN8l +CmrglHcqh+zTO3Hx/38oiyiHOOlr7lybbbLTouopmomsAML6+sP3wukNy/lPJYntcHh WY7XGwXxcFOnRRGFWc0xzaGSItDmG/En25fJlAnYn8nWXxTkPNY3GGwzPArpiAczz4G6 foxMQbUljPWLlwnxQzJ7Zl9KrHMJH42EdWvH9jN/ZcAOQMraSYqMDV0K6uRUJPjSxhXu DWCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682697777; x=1685289777; 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=ozlltezDHlBPOujzmITgxypvbc4RquszrV39qlta8mM=; b=EOQVOpLpbk3zm/opIuuJbdqtcVUjInRh/7uAvZHYUMxCQldlPkMvvixAsA2OupafHr zucaKB26k0qEQKIuqKfXvJj3MaXGiNxOls5oo2Nq/rvYT4qSdxkpwPlQyh4hAvmV2eAt b9eH5fp/6fXu6yHr6w/jexe7Hvu4pCuyJGUD49WOoci2feVneP0ps00fzS/Ypw7EvcFe 84+0Pr7yCpx+P8BOTal9Iy9iLi/I1/9wUtuBES1N5BMHT9KyZYsigcig3FU9f0Bm3JrD 7PRI/MqC4OG1O+McI3LHe5LU1EQsgwTx+1Ys7r8zgKuZcv3kDo0W6fkxojXlRjF8hrMC MoFA== X-Gm-Message-State: AC+VfDy4dYJULhvzhnY5MwVgSzlCiUjBqzIc6eXs9TnePDErv8FP4x0C EvYj+M8UZIMrlRHBGk3wKR6Yz4fGFqpsYaJxDtzW1Q== X-Google-Smtp-Source: ACHHUZ7a7unASecX5MLe/Jp9iw8YQtBfBVudy/ODdsU9zIIH1x++rWwBtkijoYbTGD6cG8rA94OeYg== X-Received: by 2002:a92:cb43:0:b0:329:5813:8de6 with SMTP id f3-20020a92cb43000000b0032958138de6mr3956890ilq.18.1682697776888; Fri, 28 Apr 2023 09:02:56 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id a17-20020a92d351000000b0032f2f3e5edesm1022997ilh.8.2023.04.28.09.02.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 09:02:56 -0700 (PDT) From: Tom Tromey Date: Fri, 28 Apr 2023 10:02:53 -0600 Subject: [PATCH 3/3] Remove evaluate_type MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230428-minor-expr-cleanuups-v1-3-0a634e8d5c25@adacore.com> References: <20230428-minor-expr-cleanuups-v1-0-0a634e8d5c25@adacore.com> In-Reply-To: <20230428-minor-expr-cleanuups-v1-0-0a634e8d5c25@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Like evaluate_expression, evaluate_type is also just a simple wrapper. Removing it makes the code a little nicer. --- gdb/dtrace-probe.c | 2 +- gdb/eval.c | 9 --------- gdb/expression.h | 5 +++++ gdb/gnu-v3-abi.c | 2 +- gdb/mi/mi-main.c | 2 +- gdb/typeprint.c | 4 ++-- gdb/value.h | 2 -- gdb/varobj.c | 2 +- 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index dad15df5b99..a742c3c25e3 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -494,7 +494,7 @@ dtrace_process_dof_probe (struct objfile *objfile, } if (expr != NULL && expr->first_opcode () == OP_TYPE) - type = evaluate_type (expr.get ())->type (); + type = expr->evaluate_type ()->type (); args.emplace_back (type, std::move (type_str), std::move (expr)); } diff --git a/gdb/eval.c b/gdb/eval.c index a8d5c78e09e..a75bddcadfd 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -116,15 +116,6 @@ expression::evaluate (struct type *expect_type, enum noside noside) return retval; } -/* Evaluate an expression, avoiding all memory references - and getting a value whose type alone is correct. */ - -struct value * -evaluate_type (struct expression *exp) -{ - return exp->evaluate (nullptr, EVAL_AVOID_SIDE_EFFECTS); -} - /* Find the current value of a watchpoint on EXP. Return the value in *VALP and *RESULTP and the chain of intermediate and final values in *VAL_CHAIN. RESULTP and VAL_CHAIN may be NULL if the caller does diff --git a/gdb/expression.h b/gdb/expression.h index 5bfb051a393..e6e4bec2e80 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -225,6 +225,11 @@ struct expression struct value *evaluate (struct type *expect_type = nullptr, enum noside noside = EVAL_NORMAL); + /* Evaluate an expression, avoiding all memory references + and getting a value whose type alone is correct. */ + struct value *evaluate_type () + { return evaluate (nullptr, EVAL_AVOID_SIDE_EFFECTS); } + /* Language it was entered in. */ const struct language_defn *language_defn; /* Architecture it was parsed in. */ diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 12bc5b09a93..687bf7e89bd 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1211,7 +1211,7 @@ gnuv3_get_type_from_type_info (struct value *type_info_ptr) internal form to reconstruct the type somehow. */ std::string type_name = gnuv3_get_typename_from_type_info (type_info_ptr); expression_up expr (parse_expression (type_name.c_str ())); - struct value *type_val = evaluate_type (expr.get ()); + struct value *type_val = expr->evaluate_type (); return type_val->type (); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 683d36d93d5..19cdf47a283 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2466,7 +2466,7 @@ print_variable_or_computed (const char *expression, enum print_values values) expression_up expr = parse_expression (expression); if (values == PRINT_SIMPLE_VALUES) - val = evaluate_type (expr.get ()); + val = expr->evaluate_type (); else val = expr->evaluate (); diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 06ecd2c4776..6dbd44eb4cd 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -511,7 +511,7 @@ whatis_exp (const char *exp, int show) "whatis" prints the type of the expression without stripping any typedef level. "ptype" always strips all levels of typedefs. */ - val = evaluate_type (expr.get ()); + val = expr->evaluate_type (); type = val->type (); if (show == -1 && expr->first_opcode () == OP_TYPE) @@ -708,7 +708,7 @@ maintenance_print_type (const char *type_name, int from_tty) if (type_name != NULL) { expression_up expr = parse_expression (type_name); - struct value *val = evaluate_type (expr.get ()); + struct value *val = expr->evaluate_type (); struct type *type = val->type (); if (type != nullptr) diff --git a/gdb/value.h b/gdb/value.h index f6092aba5a4..d042d816409 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1299,8 +1299,6 @@ extern int using_struct_return (struct gdbarch *gdbarch, struct value *function, struct type *value_type); -extern struct value *evaluate_type (struct expression *exp); - extern value *evaluate_var_value (enum noside noside, const block *blk, symbol *var); diff --git a/gdb/varobj.c b/gdb/varobj.c index 75b4d44b109..dd39784a21c 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -375,7 +375,7 @@ varobj_create (const char *objname, { /* Error getting the value. Try to at least get the right type. */ - struct value *type_only_value = evaluate_type (var->root->exp.get ()); + struct value *type_only_value = var->root->exp->evaluate_type (); var->type = type_only_value->type (); } -- 2.39.1