aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@fit.cvut.cz>2018-07-31 10:15:44 +0100
committerSimon Marchi <simon.marchi@ericsson.com>2018-07-31 10:13:41 -0400
commit5abe0f0cc79a753b80bde28d9c0c7fec9bff3c10 (patch)
treedbcd5afb2099ab8de78e6547553bb2caf634dd0e /gdb/varobj.c
parent472fa5eec2cc521ad5ea37091ea2424ea46552ae (diff)
downloadgdb-5abe0f0cc79a753b80bde28d9c0c7fec9bff3c10.zip
gdb-5abe0f0cc79a753b80bde28d9c0c7fec9bff3c10.tar.gz
gdb-5abe0f0cc79a753b80bde28d9c0c7fec9bff3c10.tar.bz2
Fix segfault when invoking -var-info-path-expression on a dynamic varobj
Invoking -var-info-path-expression on a dynamic varobj lead either in wrong (nonsense) result or to a segmentation fault in cplus_describe_child(). This was caused by the fact that varobj_get_path_expr() called cplus_path_expr_of_child() ignoring the fact the parent of the variable is dynamic. Then, cplus_describe_child() accessed the underlaying C type members by index, causing (i) either wrong (nonsense) expression being returned (since dynamic child may be completely arbibtrary value) or (ii) segmentation fault (in case the index higher than number of underlaying C type members. This fixes the problem by checking whether a varobj is a child of a dynamic varobj and, if so, reporting an error as described in documentation. gdb/ChangeLog: * varobj.c (varobj_get_path_expr_parent): Report an error if parent is a dynamic varobj. gdb/testsuite/Changelog: * gdb.python/py-mi-var-info-path-expression.c: New file. * gdb.python/py-mi-var-info-path-expression.py: New file. * gdb.python/py-mi-var-info-path-expression.exp: New file.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 0244141..af60796 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -948,6 +948,11 @@ varobj_get_path_expr_parent (const struct varobj *var)
while (!is_root_p (parent) && !is_path_expr_parent (parent))
parent = parent->parent;
+ /* Computation of full rooted expression for children of dynamic
+ varobjs is not supported. */
+ if (varobj_is_dynamic_p (parent))
+ error (_("Invalid variable object (child of a dynamic varobj)"));
+
return parent;
}