public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix forgotten check_typedef()s
@ 2010-07-11 16:23 Jan Kratochvil
  2010-07-12 17:00 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-07-11 16:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Paul Hilfinger

Hi,

patch
	[COMMIT] 64-bit range types in GDB
	http://sourceware.org/ml/gdb-patches/2009-12/msg00181.html

violates the comment
/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
   But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
   so you only have to call check_typedef once.  Since allocate_value
   calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe.  */
#define TYPE_LENGTH(thistype) (thistype)->length

by not calling check_typedef or CHECK_TYPEDEF before using TYPE_LENGTH in
read_subrange_type.  On gdb.pascal/hello.pas it has no effect but apparently
the calculation is not right:

(gdb) p base_type->length
$7 = 0
(gdb) p base_type->main_type->flag_unsigned 
$8 = 0
(gdb) p/x negative_mask
$5 = 0x8000000000000000
(gdb) p check_typedef (base_type)
$9 = (struct type *) 0x1ed9190
(gdb) p $9->length
$12 = 1
(gdb) p $9->main_type->flag_unsigned
$13 = 1
(gdb) p/x low
$14 = 0x0
(gdb) p/x high
$15 = 0xff

I did not try to find a reproducer.

With the archer-jankratochvil-vla patchset there is a regression as LENGTH is
check_typedef'ed there.


pascal_printstr is the same class of bug, unrelated to the 64-bit range types
patch above.  (archer-jankratochvil-vla has a problem as create_array_type
does not do CHECK_TYPEDEF (element_type) when it is not immediately required.)

[ In a longterm IMO check_typedef should return a different GDB C type than
what is its argument so that check_typedef is enforced during gdb compilation.
]

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

OK to check-in?


Thanks,
Jan


gdb/
2010-07-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (read_subrange_type): Call read_subrange_type.
	* p-lang.c (pascal_printstr): Likewise.

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6332,6 +6332,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   LONGEST negative_mask;
 
   base_type = die_type (die, cu);
+  /* Preserve BASE_TYPE's original type, just set its LENGTH.  */
+  check_typedef (base_type);
 
   /* The die_type call above may have already set the type for this DIE.  */
   range_type = get_die_type (die, cu);
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -222,7 +222,11 @@ pascal_printstr (struct ui_file *stream, struct type *type,
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
-  int width = TYPE_LENGTH (type);
+  int width;
+
+  /* Preserve TYPE's original type, just set its LENGTH.  */
+  check_typedef (type);
+  width = TYPE_LENGTH (type);
 
   /* If the string was not truncated due to `set print elements', and
      the last byte of it is a null, we don't print that, in traditional C

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix forgotten check_typedef()s
  2010-07-11 16:23 [patch] Fix forgotten check_typedef()s Jan Kratochvil
@ 2010-07-12 17:00 ` Tom Tromey
  2010-07-12 17:08   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-07-12 17:00 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Paul Hilfinger

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> 2010-07-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	* dwarf2read.c (read_subrange_type): Call read_subrange_type.
Jan> 	* p-lang.c (pascal_printstr): Likewise.

This is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix forgotten check_typedef()s
  2010-07-12 17:00 ` Tom Tromey
@ 2010-07-12 17:08   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-07-12 17:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Paul Hilfinger

On Mon, 12 Jul 2010 19:00:01 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> 2010-07-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	* dwarf2read.c (read_subrange_type): Call read_subrange_type.
> Jan> 	* p-lang.c (pascal_printstr): Likewise.
> 
> This is ok.  Thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-07/msg00069.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-12 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-11 16:23 [patch] Fix forgotten check_typedef()s Jan Kratochvil
2010-07-12 17:00 ` Tom Tromey
2010-07-12 17:08   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).