diff options
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/whatis.exp | 25 | ||||
-rw-r--r-- | gdb/typeprint.c | 6 |
4 files changed, 38 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 91093a5b11..ce6bb21771 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-01-22 Pedro Alves <palves@redhat.com> + Sergio Durigan Junior <sergiodj@redhat.com> + + * typeprint.c (whatis_exp): Initialize "val" in the "whatis type" + case. + 2018-01-17 Sergio Durigan Junior <sergiodj@redhat.com> * compile/compile.c (compile_to_object): Convert "triplet_rx" diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 061475b50d..ede93ae212 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-01-22 Pedro Alves <palves@redhat.com> + Sergio Durigan Junior <sergiodj@redhat.com> + + * gdb.base/whatis.exp: Add tests for 'set print object on' + + 'whatis <struct>' 'whatis <struct> *' and 'whatis <struct> &'. + 2018-01-17 Yao Qi <yao.qi@linaro.org> * gdb.compile/compile.exp: Match the address printed for diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp index dd6aeb02f9..509183e2ea 100644 --- a/gdb/testsuite/gdb.base/whatis.exp +++ b/gdb/testsuite/gdb.base/whatis.exp @@ -282,14 +282,31 @@ gdb_test "whatis v_double_pointer" \ # test whatis command with structure types + +# First with a type argument, with both "set print object" set to "on" +# and "off", ending with "off" for the following tests. +foreach_with_prefix print_object {"on" "off"} { + gdb_test_no_output "set print object $print_object" + + gdb_test "whatis struct t_struct" \ + "type = struct t_struct" \ + "whatis named structure using type name" + + gdb_test "whatis struct t_struct *" \ + "type = struct t_struct \\*" \ + "whatis named structure using type name and pointer" + + gdb_test "whatis struct t_struct &" \ + "type = struct t_struct &" \ + "whatis named structure using type name and reference" +} + +# Now with an expression argument. + gdb_test "whatis v_struct1" \ "type = struct t_struct" \ "whatis named structure" -gdb_test "whatis struct t_struct" \ - "type = struct t_struct" \ - "whatis named structure using type name" - gdb_test "whatis v_struct2" \ "type = struct \{\.\.\.\}" \ "whatis unnamed structure" diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 9a125076a1..c098a3f426 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -489,6 +489,10 @@ whatis_exp (const char *exp, int show) check_typedef (type); if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) type = TYPE_TARGET_TYPE (type); + + /* If the expression is actually a type, then there's no + value to fetch the dynamic type from. */ + val = NULL; } else { @@ -506,7 +510,7 @@ whatis_exp (const char *exp, int show) } get_user_print_options (&opts); - if (opts.objectprint) + if (val != NULL && opts.objectprint) { if (((TYPE_CODE (type) == TYPE_CODE_PTR) || TYPE_IS_REFERENCE (type)) && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT)) |