From patchwork Wed Feb 27 22:18:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31674 Received: (qmail 24501 invoked by alias); 27 Feb 2019 22:18:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 24411 invoked by uid 89); 27 Feb 2019 22:18:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=comply, UD:varobj.c, UD:pretty_printer.release, varobj.c X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 22:18:20 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E3A14116581; Wed, 27 Feb 2019 17:18:18 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2lHr2sZhmIzr; Wed, 27 Feb 2019 17:18:18 -0500 (EST) Received: from murgatroyd.Home (75-166-85-218.hlrn.qwest.net [75.166.85.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 90014116120; Wed, 27 Feb 2019 17:18:18 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 7/7] Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::release Date: Wed, 27 Feb 2019 15:18:14 -0700 Message-Id: <20190227221814.17661-8-tromey@adacore.com> In-Reply-To: <20190227221814.17661-1-tromey@adacore.com> References: <20190227221814.17661-1-tromey@adacore.com> MIME-Version: 1.0 This applies ATTRIBUTE_UNUSED_RESULT to ref_ptr::release and updates a few spots to comply. I believe one use in install_default_visualizer was in error, fixed by this patch. 2019-02-27 Tom Tromey * varobj.c (update_dynamic_varobj_children): Update. (install_default_visualizer): Use reset, not release. * value.c (set_internalvar): Update. * dwarf2loc.c (value_of_dwarf_reg_entry): Update. * common/gdb_ref_ptr.h (class ref_ptr) : Add ATTRIBUTE_UNUSED_RESULT. --- gdb/ChangeLog | 9 +++++++++ gdb/common/gdb_ref_ptr.h | 2 +- gdb/dwarf2loc.c | 3 +-- gdb/value.c | 10 +++++----- gdb/varobj.c | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gdb/common/gdb_ref_ptr.h b/gdb/common/gdb_ref_ptr.h index b104556cc5f..c31c9a2e58b 100644 --- a/gdb/common/gdb_ref_ptr.h +++ b/gdb/common/gdb_ref_ptr.h @@ -135,7 +135,7 @@ class ref_ptr /* Return this instance's referent, and stop managing this reference. The caller is now responsible for the ownership of the reference. */ - T *release () + ATTRIBUTE_UNUSED_RESULT T *release () { T *result = m_obj; diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 9c974a11133..29d289b4d0c 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1472,9 +1472,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, target_type, caller_frame, caller_per_cu); - release_value (target_val).release (); val = allocate_computed_value (type, &entry_data_value_funcs, - target_val /* closure */); + release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ memcpy (value_contents_raw (val), value_contents_raw (outer_val), diff --git a/gdb/value.c b/gdb/value.c index 95b6a56f32e..50e47a936aa 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2274,20 +2274,20 @@ set_internalvar (struct internalvar *var, struct value *val) default: new_kind = INTERNALVAR_VALUE; - new_data.value = value_copy (val); - new_data.value->modifiable = 1; + struct value *copy = value_copy (val); + copy->modifiable = 1; /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or has changed. */ - if (value_lazy (new_data.value)) - value_fetch_lazy (new_data.value); + if (value_lazy (copy)) + value_fetch_lazy (copy); /* Release the value from the value chain to prevent it from being deleted by free_all_values. From here on this function should not call error () until new_data is installed into the var->u to avoid leaking memory. */ - release_value (new_data.value).release (); + new_data.value = release_value (copy).release (); /* Internal variables which are created from values with a dynamic location don't need the location property of the origin anymore. diff --git a/gdb/varobj.c b/gdb/varobj.c index b03307068f3..3715bb6a7df 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -760,7 +760,7 @@ update_dynamic_varobj_children (struct varobj *var, /* Release vitem->value so its lifetime is not bound to the execution of a command. */ if (item != NULL && item->value != NULL) - release_value (item->value).release (); + item->value = release_value (item->value).release (); } if (item == NULL) @@ -1127,7 +1127,7 @@ install_default_visualizer (struct varobj *var) } if (pretty_printer == Py_None) - pretty_printer.release (); + pretty_printer.reset (nullptr); install_visualizer (var->dynamic, NULL, pretty_printer.release ()); }