keiths / rpms / gdb

Forked from rpms/gdb 16 days ago
Clone
d7bd836
http://sourceware.org/ml/gdb-patches/2010-01/msg00030.html
d7bd836
Subject: [patch] Re: Regression: field type preservation: 7.0 -> 7.0.1+HEAD
d7bd836
d7bd836
On Friday 01 January 2010 21:45:05 Jan Kratochvil wrote:
d7bd836
> -PASS: gdb.mi/mi-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
> +FAIL: gdb.mi/mi-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
> -PASS: gdb.mi/mi2-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
> +FAIL: gdb.mi/mi2-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
> -PASS: gdb.python/py-mi.exp: examine container children=0, no pretty-printing
d7bd836
> +FAIL: gdb.python/py-mi.exp: examine container children=0, no pretty-printing
d7bd836
> 
d7bd836
> due to:
d7bd836
> Re: RFA: unbreak typedefed bitfield
d7bd836
> http://sourceware.org/ml/gdb-patches/2009-12/msg00295.html
d7bd836
> commit fc85da4ee2a7c32afc53b1b334a4f84e2e9bd84e
d7bd836
> http://sourceware.org/ml/gdb-cvs/2009-12/msg00100.html
d7bd836
d7bd836
attached a fix on top of existing HEAD.
d7bd836
d7bd836
Original PR gdb/10884 was a regression 6.8 -> 7.0 due to:
d7bd836
RFC: Lazy bitfields
d7bd836
http://sourceware.org/ml/gdb-patches/2009-07/msg00437.html
d7bd836
http://sourceware.org/ml/gdb-cvs/2009-07/msg00143.html
d7bd836
07491b3409f6ace0b7a9a707775a56ce10fece1c
d7bd836
d7bd836
No regressions for HEAD on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.  Plus:
d7bd836
-FAIL: gdb.mi/mi-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
+PASS: gdb.mi/mi-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
-FAIL: gdb.mi/mi2-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
+PASS: gdb.mi/mi2-var-child.exp: get children of struct_declarations.s2.u2.u1s1
d7bd836
-FAIL: gdb.python/py-mi.exp: examine container children=0, no pretty-printing
d7bd836
+PASS: gdb.python/py-mi.exp: examine container children=0, no pretty-printing
d7bd836
d7bd836
Going to check it in also for gdb_7_0-branch after an approval.
d7bd836
d7bd836
d7bd836
Thanks,
d7bd836
Jan
d7bd836
d7bd836
d7bd836
gdb/
d7bd836
2010-01-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
d7bd836
d7bd836
	* value.c (value_primitive_field): Remove one check_typedef call.
d7bd836
	Move bitpos and container_bitsize initialization after
d7bd836
	allocate_value_lazy.  New comment before accessing TYPE_LENGTH.
d7bd836
d7bd836
gdb/testsuite/
d7bd836
2010-01-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
d7bd836
d7bd836
	* gdb.mi/var-cmd.c (do_bitfield_tests): Change "V.sharable" type to
d7bd836
	"uint_for_mi_testing".
d7bd836
d7bd836
--- a/gdb/testsuite/gdb.mi/var-cmd.c
d7bd836
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
d7bd836
@@ -494,7 +494,7 @@ void do_bitfield_tests ()
d7bd836
     mi_create_varobj V d "create varobj for Data"
d7bd836
     mi_list_varobj_children "V" {
d7bd836
         {"V.alloc" "alloc" "0" "int"}
d7bd836
-        {"V.sharable" "sharable" "0" "unsigned int"}
d7bd836
+        {"V.sharable" "sharable" "0" "uint_for_mi_testing"}
d7bd836
     } "list children of Data"
d7bd836
     mi_check_varobj_value V.sharable 3 "access bitfield"
d7bd836
     :*/
d7bd836
--- a/gdb/value.c
d7bd836
+++ b/gdb/value.c
d7bd836
@@ -1873,7 +1873,6 @@ value_primitive_field (struct value *arg1, int offset,
d7bd836
 
d7bd836
   CHECK_TYPEDEF (arg_type);
d7bd836
   type = TYPE_FIELD_TYPE (arg_type, fieldno);
d7bd836
-  type = check_typedef (type);
d7bd836
 
d7bd836
   /* Handle packed fields */
d7bd836
 
d7bd836
@@ -1885,10 +1884,14 @@ value_primitive_field (struct value *arg1, int offset,
d7bd836
 	 Otherwise, adjust offset to the byte containing the first
d7bd836
 	 bit.  Assume that the address, offset, and embedded offset
d7bd836
 	 are sufficiently aligned.  */
d7bd836
-      int bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno);
d7bd836
-      int container_bitsize = TYPE_LENGTH (type) * 8;
d7bd836
+      int bitpos, container_bitsize;
d7bd836
 
d7bd836
       v = allocate_value_lazy (type);
d7bd836
+
d7bd836
+      /* TYPE_LENGTH of TYPE gets initialized by allocate_value_lazy.  */
d7bd836
+      bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno);
d7bd836
+      container_bitsize = TYPE_LENGTH (type) * 8;
d7bd836
+
d7bd836
       v->bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno);
d7bd836
       if ((bitpos % container_bitsize) + v->bitsize <= container_bitsize
d7bd836
 	  && TYPE_LENGTH (type) <= (int) sizeof (LONGEST))
d7bd836
@@ -1939,6 +1942,8 @@ value_primitive_field (struct value *arg1, int offset,
d7bd836
       else
d7bd836
 	{
d7bd836
 	  v = allocate_value (type);
d7bd836
+
d7bd836
+	  /* TYPE_LENGTH of TYPE gets initialized by allocate_value.  */
d7bd836
 	  memcpy (value_contents_raw (v),
d7bd836
 		  value_contents_raw (arg1) + offset,
d7bd836
 		  TYPE_LENGTH (type));
d7bd836