[patch] move the nottext flag to the instance_flags

Ken Werner
2010-10-01T15:34:56Z

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

On Thursday, September 30, 2010 7:55:18 pm Joel Brobecker wrote:
> If you make a proper submission for this patch, I will officially
> review it.

This patch moves the nottext flag into to the instance_flags of the
type to handle the printing of character vectors as discussed here:
http://sourceware.org/ml/gdb-patches/2010-10/msg00005.html
The initial patch on how char vectors should be treated can be found at:
http://sourceware.org/ml/gdb-patches/2007-08/msg00467.html

Tested on powerpc64-*-linux-gnu and i686-*-linux-gnu, no regressions.
OK to apply?

Thanks
-ken

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

ChangeLog:

2010-10-01 Ken Werner <ken.werner@de.ibm.com>

* gdbtypes.h (struct main_type): Remove flag_nottext.
(enum type_flag_value): Remove TYPE_FLAG_NOTTEXT.
(enum type_instance_flag_value): Add TYPE_INSTANCE_FLAG_NOTTEXT.
(TYPE_NOTTEXT): Use TYPE_INSTANCE_FLAG_NOTTEXT instead of flag_nottext.
* gdbtypes.c (make_vector_type): Use TYPE_INSTANCE_FLAG_NOTTEXT instead
of TYPE_FLAG_NOTTEXT.
(init_type): Remove the initialization of the flag_nottext field.
(gdbtypes_post_init): Use TYPE_INSTANCE_FLAG_NOTTEXT instead of
TYPE_FLAG_NOTTEXT.
* c-valprint.c (c_val_print): Remove TYPE_VECTOR check.

testsuite/ChangeLog:

2010-10-01 Ken Werner <ken.werner@de.ibm.com>

* gdb.base/gnu_vector.c: Add variable c4.
* gdb.base/gnu_vector.exp: Add tests for character vector printing.
* gdb.arch/altivec-abi.exp: Fix expect pattern of character vectors.

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 1 Oct 2010 14:13:29 -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 1 Oct 2010 14:13:30 -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 1 Oct 2010 14:13:30 -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
Index: gdb/testsuite/gdb.arch/altivec-abi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-abi.exp,v
retrieving revision 1.20
diff -p -u -r1.20 altivec-abi.exp
--- gdb/testsuite/gdb.arch/altivec-abi.exp 14 Jul 2010 14:54:58 -0000 1.20
+++ gdb/testsuite/gdb.arch/altivec-abi.exp 1 Oct 2010 14:13:30 -0000
@@ -82,7 +82,7 @@ proc altivec_abi_tests { extra_flags for

# now all the arguments of vec_fun are initialized

- set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g', 104 'h', 105 'i', 108 'l', 109 'm', 110 'n', 111 'o', 112 'p', 113 'q', 114 'r'., vuchar_f=.65 'A', 66 'B', 67 'C', 68 'D', 69 'E', 70 'F', 71 'G', 72 'H', 73 'I', 76 'L', 77 'M', 78 'N', 79 'O', 80 'P', 81 'Q', 82 'R'., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.118 'v', 101 'e', 99 'c', 116 't', 111 'o', 114 'r', 32 ' ', 111 'o', 102 'f', 32 ' ', 99 'c', 104 'h', 97 'a', 114 'r', 115 's', 46 '.'., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."
+ set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.97, 98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 114., vuchar_f=.65, 66, 67, 68, 69, 70, 71, 72, 73, 76, 77, 78, 79, 80, 81, 82., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.118, 101, 99, 116, 111, 114, 32, 111, 102, 32, 99, 104, 97, 114, 115, 46., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."

set pattern1 $pattern
append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;"
Index: gdb/testsuite/gdb.base/gnu_vector.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/gnu_vector.c,v
retrieving revision 1.1
diff -p -u -r1.1 gnu_vector.c
--- gdb/testsuite/gdb.base/gnu_vector.c 11 Aug 2010 16:48:26 -0000 1.1
+++ gdb/testsuite/gdb.base/gnu_vector.c 1 Oct 2010 14:13:30 -0000
@@ -17,6 +17,7 @@

Contributed by Ken Werner <ken.werner@de.ibm.com> */

+char __attribute__ ((vector_size (4 * sizeof(char)))) c4 = {1, 2, 3, 4};
int __attribute__ ((vector_size (4 * sizeof(int)))) i4a = {2, 4, 8, 16};
int __attribute__ ((vector_size (4 * sizeof(int)))) i4b = {1, 2, 8, 4};
float __attribute__ ((vector_size (4 * sizeof(float)))) f4a = {2, 4, 8, 16};
Index: gdb/testsuite/gdb.base/gnu_vector.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/gnu_vector.exp,v
retrieving revision 1.1
diff -p -u -r1.1 gnu_vector.exp
--- gdb/testsuite/gdb.base/gnu_vector.exp 11 Aug 2010 16:48:26 -0000 1.1
+++ gdb/testsuite/gdb.base/gnu_vector.exp 1 Oct 2010 14:13:30 -0000
@@ -46,6 +46,10 @@ if { ![runto main] } {
return -1
}

+# Test printing of character vector types
+gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "print c4\[2\]" "\\\$$decimal = 3"
+
# Test binary operators on integer vector types
gdb_test "print i4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
gdb_test "print i4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"