diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-21 18:02:11 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-01-10 19:14:12 -0700 |
commit | eb115069323087e15210c09e3b581be0f6fb5852 (patch) | |
tree | a75b8fad89deba750322443fbd0275b3faed3cf9 /gdb/value.h | |
parent | 906768f970826102252e8cfd30ee72da71de29f7 (diff) | |
download | binutils-eb115069323087e15210c09e3b581be0f6fb5852.zip binutils-eb115069323087e15210c09e3b581be0f6fb5852.tar.gz binutils-eb115069323087e15210c09e3b581be0f6fb5852.tar.bz2 |
Add scoped_value_mark
This adds a scoped_value_mark class, that records the value mark in
the constructor and then calls value_free_to_mark in the destructor.
It then updates various spots in gdb to use this class, rather than a
cleanup.
It would be better overall to replace "struct value *" with a
shared_ptr, maybe eliminating the need for this class (watchpoints
would perhaps need some new mechanism as well). However, that's
difficult to do.
2017-01-10 Tom Tromey <tom@tromey.com>
* python/py-value.c (valpy_dereference, valpy_referenced_value)
(valpy_reference_value, valpy_const_value, valpy_get_address)
(valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
(valpy_getitem, valpy_call, valpy_binop_throw, valpy_negative)
(valpy_absolute, valpy_richcompare_throw): Use scoped_value_mark.
* dwarf2loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
scoped_value_mark.
* dwarf2-frame.c (execute_stack_op): Use scoped_value_mark.
* value.h (scoped_value_mark): New class.
Diffstat (limited to 'gdb/value.h')
-rw-r--r-- | gdb/value.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/value.h b/gdb/value.h index 4aba8c0..0c5ab28 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -714,6 +714,28 @@ extern struct value *value_mark (void); extern void value_free_to_mark (const struct value *mark); +/* A helper class that uses value_mark at construction time and calls + value_free_to_mark in the destructor. This is used to clear out + temporary values created during the lifetime of this object. */ +class scoped_value_mark +{ + public: + + scoped_value_mark () + : m_value (value_mark ()) + { + } + + ~scoped_value_mark () + { + value_free_to_mark (m_value); + } + + private: + + const struct value *m_value; +}; + extern struct value *value_cstring (const char *ptr, ssize_t len, struct type *char_type); extern struct value *value_string (const char *ptr, ssize_t len, |