This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[2/7] Eliminate builtin character types
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 26 Jun 2009 18:40:34 +0200 (CEST)
- Subject: [2/7] Eliminate builtin character types
Hello,
this patch removes builtin_type_true_char and builtin_type_true_unsigned_char
and replaces them by new members of builtin_type.
The new/pre-existing references to current_gdbarch will be replaced by
per-type architecture later.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (builtin_type_true_char): Remove.
(builtin_type_true_unsigned_char): Likewise.
(struct builtin_type): Add builtin_true_char and
builtin_true_unsigned_char members.
* gdbtypes.c (builtin_type_true_char): Remove.
(builtin_type_true_unsigned_char): Likewise.
(_initialize_gdbtypes): Do not initialize them.
(gdbtypes_post_init): Initialize builtin_true_char and
builtin_true_unsigned_char members of builtin_type.
* printcmd.c (print_scalar_formatted): Use builtin_type
members instead of builtin_type_true_char and
builtin_type_true_unsigned_char.
* ada-valprint.c (ada_val_print_1): Likewise.
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -108,11 +108,6 @@ struct type *builtin_type_arm_ext;
struct type *builtin_type_ia64_spill;
struct type *builtin_type_ia64_quad;
-/* Platform-neutral character types. */
-struct type *builtin_type_true_char;
-struct type *builtin_type_true_unsigned_char;
-
-
int opaque_type_resolution = 1;
static void
show_opaque_type_resolution (struct ui_file *file, int from_tty,
@@ -3191,6 +3186,16 @@ gdbtypes_post_init (struct gdbarch *gdba
0,
"_Decimal128", (struct objfile *) NULL);
+ /* "True" character types. */
+ builtin_type->builtin_true_char =
+ init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0,
+ "true character", (struct objfile *) NULL);
+ builtin_type->builtin_true_unsigned_char =
+ init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "true character", (struct objfile *) NULL);
+
/* Default data/code pointer types. */
builtin_type->builtin_data_ptr =
make_pointer_type (builtin_type->builtin_void, NULL);
@@ -3430,15 +3435,6 @@ _initialize_gdbtypes (void)
builtin_type_ia64_quad =
build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
- builtin_type_true_char =
- init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- 0,
- "true character", (struct objfile *) NULL);
- builtin_type_true_unsigned_char =
- init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED,
- "true character", (struct objfile *) NULL);
-
add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
Set debugging of C++ overloading."), _("\
Show debugging of C++ overloading."), _("\
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -983,6 +983,13 @@ struct builtin_type
struct type *builtin_decdouble;
struct type *builtin_declong;
+ /* "True" character types.
+ We use these for the '/c' print format, because c_char is just a
+ one-byte integral type, which languages less laid back than C
+ will print as ... well, a one-byte integral type. */
+ struct type *builtin_true_char;
+ struct type *builtin_true_unsigned_char;
+
/* Pointer types. */
@@ -1086,14 +1093,6 @@ extern struct type *builtin_type_ia64_sp
extern struct type *builtin_type_ia64_quad;
-/* Platform-neutral character types.
- We use these for the '/c' print format, because c_char is just a
- one-byte integral type, which languages less laid back than C
- will print as ... well, a one-byte integral type. */
-extern struct type *builtin_type_true_char;
-extern struct type *builtin_type_true_unsigned_char;
-
-
/* Maximum and minimum values of built-in types */
#define MAX_OF_TYPE(t) \
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -344,9 +344,10 @@ print_scalar_formatted (const void *vala
const struct value_print_options *options,
int size, struct ui_file *stream)
{
+ struct gdbarch *gdbarch = current_gdbarch;
LONGEST val_long = 0;
unsigned int len = TYPE_LENGTH (type);
- enum bfd_endian byte_order = gdbarch_byte_order (current_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* If we get here with a string format, try again without it. Go
all the way back to the language printers, which may call us
@@ -395,7 +396,7 @@ print_scalar_formatted (const void *vala
same, then at this point, the value's length (in target bytes) is
gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- len = gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT;
+ len = gdbarch_addr_bit (gdbarch) / TARGET_CHAR_BIT;
/* If we are printing it as unsigned, truncate it in case it is actually
a negative signed value (e.g. "print/u (short)-1" should print 65535
@@ -454,13 +455,13 @@ print_scalar_formatted (const void *vala
{
struct value_print_options opts = *options;
opts.format = 0;
+
if (TYPE_UNSIGNED (type))
- value_print (value_from_longest (builtin_type_true_unsigned_char,
- val_long),
- stream, &opts);
- else
- value_print (value_from_longest (builtin_type_true_char, val_long),
- stream, &opts);
+ type = builtin_type (gdbarch)->builtin_true_unsigned_char;
+ else
+ type = builtin_type (gdbarch)->builtin_true_char;
+
+ value_print (value_from_longest (type, val_long), stream, &opts);
}
break;
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -746,9 +746,10 @@ ada_val_print_1 (struct type *type, cons
struct value *func = ada_vax_float_print_function (type);
if (func != 0)
{
+ struct gdbarch *gdbarch = current_gdbarch;
CORE_ADDR addr;
addr = value_as_address (call_function_by_hand (func, 1, &val));
- val_print_string (builtin_type_true_char,
+ val_print_string (builtin_type (gdbarch)->builtin_true_char,
addr, -1, stream, options);
return 0;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com