From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33944 invoked by alias); 30 Apr 2018 04:21:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 33825 invoked by uid 89); 30 Apr 2018 04:21:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=owned, helps, H*MI:sk:2018043, precisely X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.180.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Apr 2018 04:21:53 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 1E1A1459F for ; Sun, 29 Apr 2018 23:21:52 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id D0K0fa6em5CKDD0K0f7Cfc; Sun, 29 Apr 2018 23:21:52 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:34252 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fD0Jz-001psR-TZ; Sun, 29 Apr 2018 23:21:52 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 3/4] Use new_reference for struct value Date: Mon, 30 Apr 2018 04:21:00 -0000 Message-Id: <20180430042147.28337-4-tom@tromey.com> In-Reply-To: <20180430042147.28337-1-tom@tromey.com> References: <20180430042147.28337-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fD0Jz-001psR-TZ X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:34252 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-04/txt/msg00608.txt.bz2 value_incref returned its argument just as a convenience, which in the end turned out to only be used in precisely the cases where new_reference helps. So, this patch changes value_incref to return void and changes some value-using code to use new_reference. I also noticed that the comments for value_incref and value_decref were swapped, so this patch fixes those. 2018-04-29 Tom Tromey * varobj.c (install_new_value): Use new_reference. * value.h (value_incref): Return void. Swap intro comment with value_decref. * value.c (set_value_parent): Use new_reference. (value_incref): Return void. Update intro comment. (release_value): Use new_reference. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use new_reference. --- gdb/ChangeLog | 10 ++++++++++ gdb/dwarf2loc.c | 2 +- gdb/value.c | 10 ++++------ gdb/value.h | 8 ++++---- gdb/varobj.c | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 243e047b9a..78d46688bc 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -2482,7 +2482,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, /* Preserve VALUE because we are going to free values back to the mark, but we still need the value contents below. */ - value_ref_ptr value_holder (value_incref (value)); + value_ref_ptr value_holder = value_ref_ptr::new_reference (value); free_values.free_to_mark (); retval = allocate_value (subobj_type); diff --git a/gdb/value.c b/gdb/value.c index 12aa2b8bb4..eefaaaab49 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1133,7 +1133,7 @@ value_parent (const struct value *value) void set_value_parent (struct value *value, struct value *parent) { - value->parent = value_ref_ptr (value_incref (parent)); + value->parent = value_ref_ptr::new_reference (parent); } gdb_byte * @@ -1572,14 +1572,12 @@ value_mark (void) return all_values.back ().get (); } -/* Take a reference to VAL. VAL will not be deallocated until all - references are released. */ +/* See value.h. */ -struct value * +void value_incref (struct value *val) { val->reference_count++; - return val; } /* Release a reference to VAL, which was acquired with value_incref. @@ -1635,7 +1633,7 @@ release_value (struct value *val) /* We must always return an owned reference. Normally this happens because we transfer the reference from the value chain, but in this case the value was not on the chain. */ - return value_ref_ptr (value_incref (val)); + return value_ref_ptr::new_reference (val); } /* See value.h. */ diff --git a/gdb/value.h b/gdb/value.h index b58f78998a..060cef5639 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -88,12 +88,12 @@ struct value_print_options; struct value; -/* Decrease VAL's reference count. When the reference count drops to - 0, VAL will be freed. */ +/* Increase VAL's reference count. VAL is returned. */ -extern struct value *value_incref (struct value *val); +extern void value_incref (struct value *val); -/* Increate VAL's reference count. VAL is returned. */ +/* Decrease VAL's reference count. When the reference count drops to + 0, VAL will be freed. */ extern void value_decref (struct value *val); diff --git a/gdb/varobj.c b/gdb/varobj.c index 2d00964317..4656bfa6b9 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1329,7 +1329,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) code that might release it. */ value_ref_ptr value_holder; if (value != NULL) - value_holder.reset (value_incref (value)); + value_holder = value_ref_ptr::new_reference (value); /* Below, we'll be comparing string rendering of old and new values. Don't get string rendering if the value is -- 2.13.6