Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org, gdb@sourceware.org,
	        Vladimir Prus <vladimir@codesourcery.com>
Subject: Re: [patch] Re: Regression: field type preservation: 7.0 ->  7.0.1+HEAD
Date: Sun, 03 Jan 2010 05:48:00 -0000	[thread overview]
Message-ID: <20100103054727.GA31207@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <20100103045717.GZ2788@adacore.com>

On Sun, 03 Jan 2010 05:57:17 +0100, Joel Brobecker wrote:
> So, my proposal, if the other maintainers agree, is to document
> the side-effect of check_typedef (sets the typedef TYPE_LENGTH)
> as this appears to be a fully-intended behavior, and then do:

OK, attached.  As I find the type system [censored] I am never sure how it can
be used in a sane way.

OK to check-in with this wording?

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.


Thanks,
Jan


gdb/
2010-01-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* gdbtypes.c (check_typedef): New comment on type length.
	* value.c (allocate_value_lazy): Remove the unused atype variable.  New
	comment on type length.
	(value_primitive_field): Keep the original TYPE value, new comment.

gdb/testsuite/
2010-01-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.mi/var-cmd.c (do_bitfield_tests): Change "V.sharable" type to
	"uint_for_mi_testing".

--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1342,12 +1342,17 @@ stub_noname_complaint (void)
    symbols which contain a full definition for the type.
 
    This used to be coded as a macro, but I don't think it is called 
-   often enough to merit such treatment.  */
+   often enough to merit such treatment.
 
-/* Find the real type of TYPE.  This function returns the real type,
+   Find the real type of TYPE.  This function returns the real type,
    after removing all layers of typedefs and completing opaque or stub
    types.  Completion changes the TYPE argument, but stripping of
-   typedefs does not.  */
+   typedefs does not.
+
+   If TYPE is a TYPE_CODE_TYPEDEF, its length is (also) set to the length of
+   the target type instead of zero.  However, in the case of TYPE_CODE_TYPEDEF
+   check_typedef can still return different type than the original TYPE
+   pointer.  */
 
 struct type *
 check_typedef (struct type *type)
--- a/gdb/testsuite/gdb.mi/var-cmd.c
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
@@ -494,7 +494,7 @@ void do_bitfield_tests ()
     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"}
+        {"V.sharable" "sharable" "0" "uint_for_mi_testing"}
     } "list children of Data"
     mi_check_varobj_value V.sharable 3 "access bitfield"
     :*/
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -254,7 +254,14 @@ struct value *
 allocate_value_lazy (struct type *type)
 {
   struct value *val;
-  struct type *atype = check_typedef (type);
+
+  /* Call check_typedef on our type to make sure that, if TYPE
+     is a TYPE_CODE_TYPEDEF, its length is set to the length
+     of the target type instead of zero.  However, we do not
+     replace the typedef type by the target type, because we want
+     to keep the typedef in order to be able to set the VAL's type
+     description correctly.  */
+  check_typedef (type);
 
   val = (struct value *) xzalloc (sizeof (struct value));
   val->contents = NULL;
@@ -1873,7 +1880,14 @@ value_primitive_field (struct value *arg1, int offset,
 
   CHECK_TYPEDEF (arg_type);
   type = TYPE_FIELD_TYPE (arg_type, fieldno);
-  type = check_typedef (type);
+
+  /* Call check_typedef on our type to make sure that, if TYPE
+     is a TYPE_CODE_TYPEDEF, its length is set to the length
+     of the target type instead of zero.  However, we do not
+     replace the typedef type by the target type, because we want
+     to keep the typedef in order to be able to print the type
+     description correctly.  */
+  check_typedef (type);
 
   /* Handle packed fields */
 


  reply	other threads:[~2010-01-03  5:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100101184505.GA18391@host0.dyn.jankratochvil.net>
     [not found] ` <201001021308.19130.vladimir@codesourcery.com>
2010-01-02 20:30   ` Jan Kratochvil
2010-01-03  4:58     ` Joel Brobecker
2010-01-03  5:48       ` Jan Kratochvil [this message]
2010-01-03  6:03         ` Joel Brobecker
2010-01-03 17:06           ` Daniel Jacobowitz
2010-01-03 19:26             ` Jan Kratochvil
2010-01-03 21:52               ` Daniel Jacobowitz
2010-01-03 22:14                 ` Jan Kratochvil
2010-01-05 17:49       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100103054727.GA31207@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=vladimir@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox