aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-11-12 11:48:48 -0700
committerTom Tromey <tom@tromey.com>2017-01-10 19:13:55 -0700
commit1eba63835ea23cbae6059c076db985a47e39ce24 (patch)
tree9fb10dbc2c7b84b8d23df9464f16f6f19ccfdcea /gdb/varobj.c
parentbde7b3e3a0d5e1f0b66730d692b21c98a8686f75 (diff)
downloadgdb-1eba63835ea23cbae6059c076db985a47e39ce24.zip
gdb-1eba63835ea23cbae6059c076db985a47e39ce24.tar.gz
gdb-1eba63835ea23cbae6059c076db985a47e39ce24.tar.bz2
Change type of encoding argument to gdbpy_extract_lazy_string
This changes gdbpy_extract_lazy_string's "encoding" argument to be a unique_xmalloc_ptr. I chose this rather than std::string because it can sometimes be NULL. 2017-01-10 Tom Tromey <tom@tromey.com> * python/py-prettyprint.c (print_string_repr, print_children): Update. * python/py-lazy-string.c (gdbpy_extract_lazy_string): Change type of "encoding". * varobj.c (varobj_value_get_print_value): Update. * python/python-internal.h (gdbpy_extract_lazy_string): Update.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 43acc31..d75c9b8 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2413,7 +2413,7 @@ varobj_value_get_print_value (struct value *value,
struct value_print_options opts;
struct type *type = NULL;
long len = 0;
- char *encoding = NULL;
+ gdb::unique_xmalloc_ptr<char> encoding;
/* Initialize it just to avoid a GCC false warning. */
CORE_ADDR str_addr = 0;
int string_print = 0;
@@ -2464,7 +2464,6 @@ varobj_value_get_print_value (struct value *value,
{
gdbpy_extract_lazy_string (output, &str_addr, &type,
&len, &encoding);
- make_cleanup (free_current_contents, &encoding);
string_print = 1;
}
else
@@ -2520,11 +2519,11 @@ varobj_value_get_print_value (struct value *value,
/* If the THEVALUE has contents, it is a regular string. */
if (!thevalue.empty ())
LA_PRINT_STRING (stb, type, (gdb_byte *) thevalue.c_str (),
- len, encoding, 0, &opts);
+ len, encoding.get (), 0, &opts);
else if (string_print)
/* Otherwise, if string_print is set, and it is not a regular
string, it is a lazy string. */
- val_print_string (type, encoding, str_addr, len, stb, &opts);
+ val_print_string (type, encoding.get (), str_addr, len, stb, &opts);
else
/* All other cases. */
common_val_print (value, stb, 0, &opts, current_language);