From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 08/11] Change varobj_item::value to a value_ref_ptr
Date: Sat, 24 Oct 2020 15:08:53 -0600 [thread overview]
Message-ID: <20201024210856.12021-9-tom@tromey.com> (raw)
In-Reply-To: <20201024210856.12021-1-tom@tromey.com>
This changes varobj_item::value to be a value_ref_ptr, removing some
manual management.
gdb/ChangeLog
2020-10-24 Tom Tromey <tom@tromey.com>
* varobj.c (install_dynamic_child, varobj_clear_saved_item)
(update_dynamic_varobj_children, create_child)
(create_child_with_value): Update.
* varobj-iter.h (struct varobj_item) <value>: Now a
value_ref_ptr.
* python/py-varobj.c (py_varobj_iter::next): Call release_value.
---
gdb/ChangeLog | 9 +++++++++
gdb/python/py-varobj.c | 2 +-
gdb/varobj-iter.h | 2 +-
gdb/varobj.c | 24 ++++++++----------------
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index dfc9e2baf6c..e550c7bf785 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -111,7 +111,7 @@ py_varobj_iter::next ()
}
vitem = new varobj_item ();
- vitem->value = convert_value_from_python (py_v);
+ vitem->value = release_value (convert_value_from_python (py_v));
if (vitem->value == NULL)
gdbpy_print_stack ();
vitem->name = name;
diff --git a/gdb/varobj-iter.h b/gdb/varobj-iter.h
index a05f1cbf8f3..fea14d6c1c6 100644
--- a/gdb/varobj-iter.h
+++ b/gdb/varobj-iter.h
@@ -25,7 +25,7 @@ struct varobj_item
std::string name;
/* Value of this item. */
- struct value *value;
+ value_ref_ptr value;
};
/* A dynamic varobj iterator "class". */
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 9f6d5d651a5..ad7a93f5bfa 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -625,14 +625,15 @@ install_dynamic_child (struct varobj *var,
else
{
varobj *existing = var->children[index];
- bool type_updated = update_type_if_necessary (existing, item->value);
+ bool type_updated = update_type_if_necessary (existing,
+ item->value.get ());
if (type_updated)
{
if (type_changed != NULL)
type_changed->push_back (existing);
}
- if (install_new_value (existing, item->value, 0))
+ if (install_new_value (existing, item->value.get (), 0))
{
if (!type_updated && changed != NULL)
changed->push_back (existing);
@@ -678,10 +679,7 @@ static void
varobj_clear_saved_item (struct varobj_dynamic *var)
{
if (var->saved_item != NULL)
- {
- value_decref (var->saved_item->value);
- var->saved_item.reset (nullptr);
- }
+ var->saved_item.reset (nullptr);
}
static bool
@@ -723,13 +721,7 @@ update_dynamic_varobj_children (struct varobj *var,
if (var->dynamic->saved_item != NULL)
item = std::move (var->dynamic->saved_item);
else
- {
- item = var->dynamic->child_iter->next ();
- /* Release vitem->value so its lifetime is not bound to the
- execution of a command. */
- if (item != NULL && item->value != NULL)
- item->value = release_value (item->value).release ();
- }
+ item = var->dynamic->child_iter->next ();
if (item == NULL)
{
@@ -1804,7 +1796,7 @@ create_child (struct varobj *parent, int index, std::string &name)
struct varobj_item item;
std::swap (item.name, name);
- item.value = value_of_child (parent, index);
+ item.value = release_value (value_of_child (parent, index));
return create_child_with_value (parent, index, &item);
}
@@ -1835,12 +1827,12 @@ create_child_with_value (struct varobj *parent, int index,
if (item->value != NULL)
/* If the child had no evaluation errors, var->value
will be non-NULL and contain a valid type. */
- child->type = value_actual_type (item->value, 0, NULL);
+ child->type = value_actual_type (item->value.get (), 0, NULL);
else
/* Otherwise, we must compute the type. */
child->type = (*child->root->lang_ops->type_of_child) (child->parent,
child->index);
- install_new_value (child, item->value, 1);
+ install_new_value (child, item->value.get (), 1);
return child;
}
--
2.17.2
next prev parent reply other threads:[~2020-10-24 21:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-24 21:08 [PATCH 00/11] Some varobj C++-ification and cleanup Tom Tromey
2020-10-24 21:08 ` [PATCH 01/11] Use htab_t in varobj Tom Tromey
2020-10-24 21:08 ` [PATCH 02/11] Change varobj.c:rootlist to a std::list Tom Tromey
2020-10-24 21:08 ` [PATCH 03/11] Change all_root_varobjs to take a function_view Tom Tromey
2020-10-24 21:08 ` [PATCH 04/11] C++-ify varobj iteration Tom Tromey
2020-10-24 21:08 ` [PATCH 05/11] Change varobj_iter::next to return unique_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 06/11] Change varobj_dynamic::saved_item to unique_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 07/11] Change varobj_dynamic::child_iter " Tom Tromey
2020-10-24 21:08 ` Tom Tromey [this message]
2020-10-24 21:08 ` [PATCH 09/11] Remove varobj_clear_saved_item Tom Tromey
2020-10-24 21:08 ` [PATCH 10/11] Use gdbpy_ref in instantiate_pretty_printer Tom Tromey
2020-10-24 21:08 ` [PATCH 11/11] install_variable cannot fail Tom Tromey
2020-12-11 16:46 ` [PATCH 00/11] Some varobj C++-ification and cleanup 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=20201024210856.12021-9-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).