From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 5DC09385B526 for ; Mon, 13 Feb 2023 03:15:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DC09385B526 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id CE399100403C3 for ; Mon, 13 Feb 2023 03:15:29 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id RPJRpyfNLA1zNRPJRplPXd; Mon, 13 Feb 2023 03:15:29 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=CqN6zl0D c=1 sm=1 tr=0 ts=63e9ab51 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=7d_E57ReAAAA:8 a=YuOaWP3hLCLYxZglITYA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=jhqOcbufqs7Y1TYCrUUU:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OZnxVOqFMNlAnaHXUazz1HsUbJJhIqzanKv9Zs2AhqA=; b=JVq3Xp7hHkeBqGKBQicl99Pm+Y 1S7o/FOd4Q6kyDSYhCZn9SfwH7/SFXUSs3Ithe3YPrGSqstDkDEODiiTVxjXcLyHTiI9zVXIH6QGm nIqqqu+p9u3XDMYqlFdEfMIjM; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:37668 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pRPJR-001AGJ-K8; Sun, 12 Feb 2023 20:15:29 -0700 From: Tom Tromey Date: Sun, 12 Feb 2023 20:15:41 -0700 Subject: [PATCH v3 25/50] Turn allocate_optimized_out_value into static "constructor" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230209-submit-value-fixups-2023-v3-25-45e91a20c742@tromey.com> References: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> In-Reply-To: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> To: gdb-patches@sourceware.org Cc: Simon Marchi X-Mailer: b4 0.12.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pRPJR-001AGJ-K8 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net ([192.168.0.21]) [75.166.130.93]:37668 X-Source-Auth: tom+tromey.com X-Email-Count: 53 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: This turns allocate_optimized_out_value into a static "constructor" of value. Approved-By: Simon Marchi --- gdb/ada-lang.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/dwarf2/loc.c | 10 +++++----- gdb/eval.c | 2 +- gdb/findvar.c | 2 +- gdb/frame-unwind.c | 2 +- gdb/python/py-type.c | 2 +- gdb/s390-tdep.c | 2 +- gdb/stack.c | 2 +- gdb/value.c | 10 +++++----- gdb/value.h | 5 +++-- 11 files changed, 21 insertions(+), 20 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3d2c9f4f2ab..727f816b519 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -556,7 +556,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) struct value *result; if (value_optimized_out (val)) - result = allocate_optimized_out_value (type); + result = value::allocate_optimized_out (type); else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ad6cf563562..db88dc368fd 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1044,7 +1044,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, break; case DWARF_VALUE_OPTIMIZED_OUT: - retval = allocate_optimized_out_value (subobj_type); + retval = value::allocate_optimized_out (subobj_type); break; /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 743a0cefd6d..96686d9a110 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1429,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset, invalid_synthetic_pointer (); } else - result = allocate_optimized_out_value (type->target_type ()); + result = value::allocate_optimized_out (type->target_type ()); return result; } @@ -1497,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, invalid_synthetic_pointer (); if (size == 0) - return allocate_optimized_out_value (subobj_type); + return value::allocate_optimized_out (subobj_type); dwarf_expr_context ctx (per_objfile, per_cu->addr_size ()); @@ -1524,7 +1524,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, if (entry_values_debug) exception_print (gdb_stdout, ex); free_values.free_to_mark (); - return allocate_optimized_out_value (subobj_type); + return value::allocate_optimized_out (subobj_type); } else throw; @@ -3906,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame) CORE_ADDR pc; if (frame == NULL || !get_frame_func_if_available (frame, &pc)) - return allocate_optimized_out_value (symbol->type ()); + return value::allocate_optimized_out (symbol->type ()); data = dwarf2_find_location_expression (dlbaton, &size, pc); if (data == NULL) - return allocate_optimized_out_value (symbol->type ()); + return value::allocate_optimized_out (symbol->type ()); return value_of_dwarf_block_entry (symbol->type (), frame, data, size); } diff --git a/gdb/eval.c b/gdb/eval.c index 5f8d294322b..bb72043a28a 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2855,7 +2855,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp, return value_zero (size_type, not_lval); else if (is_dynamic_type (type->index_type ()) && type->bounds ()->high.kind () == PROP_UNDEFINED) - return allocate_optimized_out_value (size_type); + return value::allocate_optimized_out (size_type); } } return evaluate_subexp_for_sizeof_base (exp, type); diff --git a/gdb/findvar.c b/gdb/findvar.c index b59962c65ba..048e439ac33 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -769,7 +769,7 @@ language_defn::read_var_value (struct symbol *var, case LOC_OPTIMIZED_OUT: if (is_dynamic_type (type)) type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); default: error (_("Cannot look up value of a botched symbol `%s'."), diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index d3baedb8a6f..ab6c33fc59c 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -267,7 +267,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum) struct gdbarch *gdbarch = frame_unwind_arch (frame); struct type *type = register_type (gdbarch, regnum); - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); } /* Return a value which indicates that FRAME copied REGNUM into diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 81b595140af..0a3787815ec 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1189,7 +1189,7 @@ typy_optimized_out (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - return value_to_value_object (allocate_optimized_out_value (type)); + return value_to_value_object (value::allocate_optimized_out (type)); } /* Return a gdb.Field object for the field named by the argument. */ diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 9aa2c06cec1..822f66dfc3c 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2239,7 +2239,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum) return value_cast (type, val); } - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); } /* Translate a .eh_frame register to DWARF register, or adjust a diff --git a/gdb/stack.c b/gdb/stack.c index 9952c3a73df..ca6087f3414 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts, || (fp_opts.print_entry_values == print_entry_values_preferred && (!val || value_optimized_out (val)))) { - entryval = allocate_optimized_out_value (sym->type ()); + entryval = value::allocate_optimized_out (sym->type ()); entryval_error = NULL; } } diff --git a/gdb/value.c b/gdb/value.c index 7fb12d8e9a6..a95737238e9 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1008,10 +1008,10 @@ value::allocate_computed (struct type *type, return v; } -/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ +/* See value.h. */ struct value * -allocate_optimized_out_value (struct type *type) +value::allocate_optimized_out (struct type *type) { struct value *retval = value::allocate_lazy (type); @@ -2875,7 +2875,7 @@ value_static_field (struct type *type, int fieldno) struct type *field_type = type->field (fieldno).type (); if (!msym.minsym) - retval = allocate_optimized_out_value (field_type); + retval = value::allocate_optimized_out (field_type); else retval = value_at_lazy (field_type, msym.value_address ()); } @@ -3224,7 +3224,7 @@ unpack_value_bitfield (struct value *dest_val, valid. Optimized out/unavailable bits are read as zero, but that's OK, as they'll end up marked below. If the VAL is wholly-invalid we may have skipped allocating its contents, - though. See allocate_optimized_out_value. */ + though. See value::allocate_optimized_out. */ if (valaddr != NULL) { LONGEST num; @@ -4196,7 +4196,7 @@ test_value_copy () /* Verify that we can copy an entirely optimized out value, that may not have its contents allocated. */ - value_ref_ptr val = release_value (allocate_optimized_out_value (type)); + value_ref_ptr val = release_value (value::allocate_optimized_out (type)); value_ref_ptr copy = release_value (value_copy (val.get ())); SELF_CHECK (value_entirely_optimized_out (val.get ())); diff --git a/gdb/value.h b/gdb/value.h index dbbb61932b8..4d5ef01279f 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -175,6 +175,9 @@ struct value const struct lval_funcs *funcs, void *closure); + /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ + static struct value *allocate_optimized_out (struct type *type); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -625,8 +628,6 @@ struct lval_funcs void (*free_closure) (struct value *v); }; -extern struct value *allocate_optimized_out_value (struct type *type); - /* Throw an error complaining that the value has been optimized out. */ -- 2.39.1