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 77914bc..b1e9f9f 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-22 Maciej W. Rozycki <macro@mips.com> * MAINTAINERS: Update my company e-mail address. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f9fe3ab..0f02f4a 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-22 Joel Brobecker <brobecker@adacore.com> * gdb.base/break-include.c, gdb.base/break-include.inc, diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp index dd6aeb0..509183e 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 9a12507..c098a3f 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)) |