public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ken Werner <ken@linux.vnet.ibm.com>
To: Tom Tromey <tromey.at.redhat.dot.com@leonard>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: shrink main_type
Date: Wed, 15 Sep 2010 19:23:00 -0000	[thread overview]
Message-ID: <201009151441.43723.ken@linux.vnet.ibm.com> (raw)
In-Reply-To: <m3zln8rism.fsf@fleche.redhat.com>

[-- Attachment #1: Type: Text/Plain, Size: 1804 bytes --]

On Tuesday, August 19, 2008 07:55:37 pm Tom Tromey wrote:
> +  /* Flags about this type.  These fields appear at this location
> +     because they packs nicely here.  See the TYPE_* macros for
> +     documentation about these fields.  */
> +
> +  unsigned int flag_unsigned : 1;
> +  unsigned int flag_nosign : 1;
> +  unsigned int flag_stub : 1;
> +  unsigned int flag_target_stub : 1;
> +  unsigned int flag_static : 1;
> +  unsigned int flag_prototyped : 1;
> +  unsigned int flag_incomplete : 1;
> +  unsigned int flag_varargs : 1;
> +  unsigned int flag_vector : 1;
> +  unsigned int flag_stub_supported : 1;
> +  unsigned int flag_nottext : 1;
> +  unsigned int flag_fixed_instance : 1;

Hi Tom,

This is quite an old change but while debugging gdb I noticed that vector 
types do have a strange bit set into their instance_flags and this seems to go 
back to this patch.
The snippet above introduces the flag_nottext as a bitfield member of the type 
struct while gdbtypes.c:make_vector_type still sets that bit into the 
instance_flags.

The nottext flag is set for the element types of vectors 
(gdbtypes.c:make_vector_type) and for the builtin_int8/builtin_int8 types. The 
flag is read from the c-valprint.c:c_textual_element_type function that 
determines whether arrays of chars should be printed as strings or not.  So, I 
guess that prior to this patch char vectors were printed just like integer 
vectors - plain data. One approach to restore that functionality would be to 
move the nottext flag into to the instance_flags of the type. Attached is an 
untested patch of what I have in mind. Comments are welcome.

This also renders my previous attempt to fix the printing of character vectors 
(http://sourceware.org/ml/gdb-patches/2010-06/msg00573.html) obsolete.

Regards
Ken Werner

[-- Attachment #2: type_nottext.patch --]
[-- Type: text/x-patch, Size: 4791 bytes --]

Index: gdb/c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.72
diff -p -u -r1.72 c-valprint.c
--- gdb/c-valprint.c	14 Jul 2010 14:13:54 -0000	1.72
+++ gdb/c-valprint.c	15 Sep 2010 12:22:49 -0000
@@ -180,8 +180,7 @@ c_val_print (struct type *type, const gd
 
 	  /* Print arrays of textual chars with a string syntax, as
 	     long as the entire array is valid.  */
-          if (!TYPE_VECTOR (type)
-	      && c_textual_element_type (unresolved_elttype, options->format)
+          if (c_textual_element_type (unresolved_elttype, options->format)
 	      && value_bits_valid (original_value,
 				   TARGET_CHAR_BIT * embedded_offset,
 				   TARGET_CHAR_BIT * TYPE_LENGTH (type)))
Index: gdb/gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.199
diff -p -u -r1.199 gdbtypes.c
--- gdb/gdbtypes.c	8 Sep 2010 17:17:42 -0000	1.199
+++ gdb/gdbtypes.c	15 Sep 2010 12:22:49 -0000
@@ -942,7 +942,7 @@ make_vector_type (struct type *array_typ
   elt_type = TYPE_TARGET_TYPE (inner_array);
   if (TYPE_CODE (elt_type) == TYPE_CODE_INT)
     {
-      flags = TYPE_INSTANCE_FLAGS (elt_type) | TYPE_FLAG_NOTTEXT;
+      flags = TYPE_INSTANCE_FLAGS (elt_type) | TYPE_INSTANCE_FLAG_NOTTEXT;
       elt_type = make_qualified_type (elt_type, flags, NULL);
       TYPE_TARGET_TYPE (inner_array) = elt_type;
     }
@@ -1801,8 +1801,6 @@ init_type (enum type_code code, int leng
     TYPE_VECTOR (type) = 1;
   if (flags & TYPE_FLAG_STUB_SUPPORTED)
     TYPE_STUB_SUPPORTED (type) = 1;
-  if (flags & TYPE_FLAG_NOTTEXT)
-    TYPE_NOTTEXT (type) = 1;
   if (flags & TYPE_FLAG_FIXED_INSTANCE)
     TYPE_FIXED_INSTANCE (type) = 1;
 
@@ -3490,8 +3488,10 @@ gdbtypes_post_init (struct gdbarch *gdba
     = arch_integer_type (gdbarch, 128, 0, "int128_t");
   builtin_type->builtin_uint128
     = arch_integer_type (gdbarch, 128, 1, "uint128_t");
-  TYPE_NOTTEXT (builtin_type->builtin_int8) = 1;
-  TYPE_NOTTEXT (builtin_type->builtin_uint8) = 1;
+  TYPE_INSTANCE_FLAGS (builtin_type->builtin_int8) |=
+    TYPE_INSTANCE_FLAG_NOTTEXT;
+  TYPE_INSTANCE_FLAGS (builtin_type->builtin_uint8) |=
+    TYPE_INSTANCE_FLAG_NOTTEXT;
 
   /* Wide character types.  */
   builtin_type->builtin_char16
Index: gdb/gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.134
diff -p -u -r1.134 gdbtypes.h
--- gdb/gdbtypes.h	28 Jul 2010 16:23:58 -0000	1.134
+++ gdb/gdbtypes.h	15 Sep 2010 12:22:49 -0000
@@ -159,18 +159,17 @@ enum type_code
 
 enum type_flag_value
 {
-  TYPE_FLAG_UNSIGNED = (1 << 6),
-  TYPE_FLAG_NOSIGN = (1 << 7),
-  TYPE_FLAG_STUB = (1 << 8),
-  TYPE_FLAG_TARGET_STUB = (1 << 9),
-  TYPE_FLAG_STATIC = (1 << 10),
-  TYPE_FLAG_PROTOTYPED = (1 << 11),
-  TYPE_FLAG_INCOMPLETE = (1 << 12),
-  TYPE_FLAG_VARARGS = (1 << 13),
-  TYPE_FLAG_VECTOR = (1 << 14),
-  TYPE_FLAG_FIXED_INSTANCE = (1 << 15),
-  TYPE_FLAG_STUB_SUPPORTED = (1 << 16),
-  TYPE_FLAG_NOTTEXT = (1 << 17),
+  TYPE_FLAG_UNSIGNED = (1 << 7),
+  TYPE_FLAG_NOSIGN = (1 << 8),
+  TYPE_FLAG_STUB = (1 << 9),
+  TYPE_FLAG_TARGET_STUB = (1 << 10),
+  TYPE_FLAG_STATIC = (1 << 11),
+  TYPE_FLAG_PROTOTYPED = (1 << 12),
+  TYPE_FLAG_INCOMPLETE = (1 << 13),
+  TYPE_FLAG_VARARGS = (1 << 14),
+  TYPE_FLAG_VECTOR = (1 << 15),
+  TYPE_FLAG_FIXED_INSTANCE = (1 << 16),
+  TYPE_FLAG_STUB_SUPPORTED = (1 << 17),
 
   /* Used for error-checking.  */
   TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED
@@ -186,7 +185,8 @@ enum type_instance_flag_value
   TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
   TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
   TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
-  TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5)
+  TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
+  TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
 };
 
 /* Unsigned integer type.  If this is not set for a TYPE_CODE_INT, the
@@ -269,7 +269,7 @@ enum type_instance_flag_value
 /* Not textual.  By default, GDB treats all single byte integers as
    characters (or elements of strings) unless this flag is set.  */
 
-#define TYPE_NOTTEXT(t)		(TYPE_MAIN_TYPE (t)->flag_nottext)
+#define TYPE_NOTTEXT(t)	(TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_NOTTEXT)
 
 /* Type owner.  If TYPE_OBJFILE_OWNED is true, the type is owned by
    the objfile retrieved as TYPE_OBJFILE.  Otherweise, the type is
@@ -388,7 +388,6 @@ struct main_type
   unsigned int flag_varargs : 1;
   unsigned int flag_vector : 1;
   unsigned int flag_stub_supported : 1;
-  unsigned int flag_nottext : 1;
   unsigned int flag_fixed_instance : 1;
   unsigned int flag_objfile_owned : 1;
   /* True if this type was declared with "class" rather than

       reply	other threads:[~2010-09-15 12:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m37iafzdcp.fsf@fleche.redhat.com>
     [not found] ` <20080819051306.GQ16894@adacore.com>
     [not found]   ` <m3zln8rism.fsf@fleche.redhat.com>
2010-09-15 19:23     ` Ken Werner [this message]
2010-09-25 14:38       ` Ken Werner
2010-09-30 18:56       ` Joel Brobecker
2010-10-01 13:23         ` Ken Werner
2010-10-01 15:34         ` [patch] move the nottext flag to the instance_flags Ken Werner
2010-10-01 16:15           ` Joel Brobecker
2010-10-05 21:50             ` Tom Tromey
2010-10-06  8:45               ` Ken Werner

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=201009151441.43723.ken@linux.vnet.ibm.com \
    --to=ken@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey.at.redhat.dot.com@leonard \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).