aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/mi/mi-cmd-var.c13
-rw-r--r--gdb/varobj.c3
3 files changed, 21 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3f3f3f3..6738267 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2015-01-30 Simon Marchi <simon.marchi@ericsson.com>
+ * mi-cmd-var.c (print_varobj): Free varobj_get_expression
+ result.
+ (mi_cmd_var_info_expression): Same.
+ * varobj.c (varobj_get_expression): Mention in the comment that
+ the result must by freed by the caller.
+
+2015-01-30 Simon Marchi <simon.marchi@ericsson.com>
+
* mi/mi-cmd-var.c (mi_cmd_var_info_type): Free result of
varobj_get_type.
(varobj_update_one): Same.
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index d873a17..d9b37f8 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -55,7 +55,12 @@ print_varobj (struct varobj *var, enum print_values print_values,
ui_out_field_string (uiout, "name", varobj_get_objname (var));
if (print_expression)
- ui_out_field_string (uiout, "exp", varobj_get_expression (var));
+ {
+ char *exp = varobj_get_expression (var);
+
+ ui_out_field_string (uiout, "exp", exp);
+ xfree (exp);
+ }
ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
if (mi_print_value_p (var, print_values))
@@ -485,6 +490,7 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc)
struct ui_out *uiout = current_uiout;
const struct language_defn *lang;
struct varobj *var;
+ char *exp;
if (argc != 1)
error (_("-var-info-expression: Usage: NAME."));
@@ -495,7 +501,10 @@ mi_cmd_var_info_expression (char *command, char **argv, int argc)
lang = varobj_get_language (var);
ui_out_field_string (uiout, "lang", lang->la_natural_name);
- ui_out_field_string (uiout, "exp", varobj_get_expression (var));
+
+ exp = varobj_get_expression (var);
+ ui_out_field_string (uiout, "exp", exp);
+ xfree (exp);
}
void
diff --git a/gdb/varobj.c b/gdb/varobj.c
index dad284d..6c9257d 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -492,7 +492,8 @@ varobj_get_objname (struct varobj *var)
return var->obj_name;
}
-/* Given the handle, return the expression represented by the object. */
+/* Given the handle, return the expression represented by the object. The
+ result must be freed by the caller. */
char *
varobj_get_expression (struct varobj *var)