From 9e19b45e2ed724759be1034349274f006d5a8653 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 21 Dec 2009 09:50:31 +0000 Subject: [PATCH] PR gdb/10884 * value.c (value_primitive_field): Call check_typedef on the type. --- gdb/ChangeLog | 7 ++++++ gdb/testsuite/ChangeLog | 8 +++++++ gdb/testsuite/gdb.mi/mi-var-cmd.exp | 2 ++ gdb/testsuite/gdb.mi/var-cmd.c | 35 +++++++++++++++++++++++++++++ gdb/value.c | 1 + 5 files changed, 53 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5356d245262..3ba26408dd8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2009-12-21 Vladimir Prus + + PR gdb/10884 + + * value.c (value_primitive_field): Call check_typedef + on the type. + 2009-12-21 Joel Brobecker * COPYING: Update to GPL version 3. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 180dc87d278..62eb4aaf9bd 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-12-21 Vladimir Prus + + PR gdb/10884 + + * gdb.mi/var-cmd.c (do_bitfield_tests): New + (main): Call do_bitfield_tests. + * gdb.mi/mi-cmd-var.exp: Run the 'bitfield' testcase. + 2009-12-20 Joel Brobecker * Makefile.in gdb.ada/gnat_ada.gpr, gdb.base/gcore-buffer-overflow.c, diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp index 6efb3332d10..4cb2552f7f4 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp @@ -577,6 +577,8 @@ proc set_frozen {varobjs flag} { mi_prepare_inline_tests $srcfile mi_run_inline_test frozen +mi_run_inline_test bitfield + # Since the inline test framework does not really work with # function calls, first to inline tests and then do the reminder # manually. diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c index 6372f64b5de..bbadc24ba7a 100644 --- a/gdb/testsuite/gdb.mi/var-cmd.c +++ b/gdb/testsuite/gdb.mi/var-cmd.c @@ -468,6 +468,40 @@ void do_at_tests () /*: END: floating :*/ } +/* Some header appear to define uint already, so apply some + uglification. Note that without uglification, the compile + does not fail, rather, we don't test what we want because + something else calls check_typedef on 'uint' already. */ +typedef unsigned int uint_for_mi_testing; + +struct Data { + int alloc; + uint_for_mi_testing sharable : 4; +}; + +/* Accessing a value of a bitfield whose type is a typed used to + result in division by zero. See: + + http://sourceware.org/bugzilla/show_bug.cgi?id=10884 + + This tests for this bug. */ + +void do_bitfield_tests () +{ + /*: BEGIN: bitfield :*/ + struct Data d = {0, 3}; + /*: + mi_create_varobj V d "create varobj for Data" + mi_list_varobj_children "V" { + {"V.alloc" "alloc" "0" "int"} + {"V.sharable" "sharable" "0" "unsigned int"} + } "list children of Data" + mi_check_varobj_value V.sharable 3 "access bitfield" + :*/ + return; + /*: END: bitfield :*/ +} + int main (int argc, char *argv []) { @@ -477,6 +511,7 @@ main (int argc, char *argv []) do_special_tests (); do_frozen_tests (); do_at_tests (); + do_bitfield_tests (); exit (0); } diff --git a/gdb/value.c b/gdb/value.c index 589e03b1496..e240c7add07 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1873,6 +1873,7 @@ value_primitive_field (struct value *arg1, int offset, CHECK_TYPEDEF (arg_type); type = TYPE_FIELD_TYPE (arg_type, fieldno); + type = check_typedef (type); /* Handle packed fields */ -- 2.30.2