From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 10/12] Change value::parent to a value_ref_ptr
Date: Thu, 05 Apr 2018 21:16:00 -0000 [thread overview]
Message-ID: <20180405211507.6103-11-tom@tromey.com> (raw)
In-Reply-To: <20180405211507.6103-1-tom@tromey.com>
This changes value::parent to a value_ref_ptr. This removes a bit of
manual reference count management.
ChangeLog
2018-04-05 Tom Tromey <tom@tromey.com>
* value.c (~value): Update.
(struct value) <parent>: Now a value_ref_ptr.
(value_parent, set_value_parent, value_address, value_copy):
Update.
---
gdb/ChangeLog | 7 +++++++
gdb/value.c | 20 +++++---------------
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 30af33c4d2..e25934b9e3 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -181,11 +181,6 @@ struct value
~value ()
{
- /* If there's an associated parent value, drop our reference to
- it. */
- if (parent != NULL)
- value_decref (parent);
-
if (VALUE_LVAL (this) == lval_computed)
{
const struct lval_funcs *funcs = location.computed.funcs;
@@ -292,7 +287,7 @@ struct value
/* Only used for bitfields; the containing value. This allows a
single read from the target when displaying multiple
bitfields. */
- struct value *parent = nullptr;
+ value_ref_ptr parent;
/* Type of the value. */
struct type *type;
@@ -1128,7 +1123,7 @@ set_value_bitsize (struct value *value, LONGEST bit)
struct value *
value_parent (const struct value *value)
{
- return value->parent;
+ return value->parent.get ();
}
/* See value.h. */
@@ -1136,12 +1131,7 @@ value_parent (const struct value *value)
void
set_value_parent (struct value *value, struct value *parent)
{
- struct value *old = value->parent;
-
- value->parent = parent;
- if (parent != NULL)
- value_incref (parent);
- value_decref (old);
+ value->parent = value_ref_ptr (value_incref (parent));
}
gdb_byte *
@@ -1521,7 +1511,7 @@ value_address (const struct value *value)
if (value->lval != lval_memory)
return 0;
if (value->parent != NULL)
- return value_address (value->parent) + value->offset;
+ return value_address (value->parent.get ()) + value->offset;
if (NULL != TYPE_DATA_LOCATION (value_type (value)))
{
gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value_type (value)));
@@ -1699,7 +1689,7 @@ value_copy (struct value *arg)
}
val->unavailable = VEC_copy (range_s, arg->unavailable);
val->optimized_out = VEC_copy (range_s, arg->optimized_out);
- set_value_parent (val, arg->parent);
+ val->parent = arg->parent;
if (VALUE_LVAL (val) == lval_computed)
{
const struct lval_funcs *funcs = val->location.computed.funcs;
--
2.13.6
next prev parent reply other threads:[~2018-04-05 21:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 21:16 [RFA 00/12] (somewhat) clean up struct value ownership Tom Tromey
2018-04-05 21:16 ` [RFA 01/12] Introduce a gdb_ref_ptr specialization for struct value Tom Tromey
2018-04-06 19:29 ` Pedro Alves
2018-04-05 21:16 ` [RFA 02/12] Change breakpoints to use value_ref_ptr Tom Tromey
2018-04-06 19:31 ` Pedro Alves
2018-04-06 21:31 ` Tom Tromey
2018-04-05 21:16 ` [RFA 12/12] Change value::contents to be a unique_xmalloc_ptr Tom Tromey
2018-04-05 21:16 ` Tom Tromey [this message]
2018-04-05 21:16 ` [RFA 09/12] Use new and delete for values Tom Tromey
2018-04-05 21:16 ` [RFA 11/12] Remove range_s VEC Tom Tromey
2018-04-05 21:16 ` [RFA 05/12] Change value history to use value_ref_ptr Tom Tromey
2018-04-05 21:16 ` [RFA 06/12] Remove free_all_values Tom Tromey
2018-04-05 21:16 ` [RFA 08/12] Remove value::next and value::released Tom Tromey
2018-04-06 19:32 ` Pedro Alves
2018-04-06 21:40 ` Tom Tromey
2018-04-05 21:16 ` [RFA 03/12] Change last_examine_value to value_ref_ptr Tom Tromey
2018-04-05 21:16 ` [RFA 04/12] Change varobj to use value_ref_ptr Tom Tromey
2018-04-05 21:16 ` [RFA 07/12] Remove free_value_chain Tom Tromey
2018-04-06 19:33 ` [RFA 00/12] (somewhat) clean up struct value ownership Pedro Alves
2018-04-06 21:20 ` Tom Tromey
2018-04-06 21:44 ` Tom Tromey
2018-04-08 21:32 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180405211507.6103-11-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox