This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [1/2] Clean up built-in types v2: Add default "nodebug" types
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 17 Jun 2007 23:53:10 +0200 (CEST)
- Subject: [rfc] [1/2] Clean up built-in types v2: Add default "nodebug" types
Hello,
my original patch series introduced a local per-gdbarch data structure in
parse.c holding a set of data types used to mark symbols without debug
information.
However, it turns out that other symbol readers also create local types
for exactly the same purpose. The xcoffread.c instance of this caused
in fact a problem with the original type elimination patches: it uses
builtin_type_int in an init routine (_initialize_xcoffread) when creating
those types. This doesn't work correctly any more ...
To fix this problem, and to remove the duplicated types, this patch now
adds this set of data types to the master builtin_type structure, and
changes all the symbol readers and parse.c to use those generic types
instead of creating their own.
Tested on powerpc-ibm-aix5.3.0.0, powerpc64-linux, spu-elf, s390-ibm-linux,
and s390x-ibm-linux.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (struct builtin_type): New members nodebug_text_symbol,
nodebug_data_symbol, nodebug_unknown_symbol, and nodebug_tls_symbol.
* gdbtypes.c (gdbtypes_post_init): Initialize nodebug_ default types.
* parse.c (msym_text_symbol_type, msym_data_symbol_type): Remove.
(msym_unknown_symbol_type, msym_tls_symbol_type): Remove.
(write_exp_msymbol): Use builtin nodebug_ types instead of them.
(build_parse): Remove.
(_initialize_parse): Do not call build_parse. Do not register
msym_ types for gdbarch-swapping.
* dwarf2read.c (new_symbol): Use default nodebug_data_symbol type
instead of creating private type.
* xcoffread.c (func_symbol_type, var_symbol_type): Remove.
(_initialize_xcoffread): Do not initialized them.
(process_xcoff_symbol): Use builtin nodebug_ types instead of them.
* mdebugread.c (nodebug_func_symbol_type): Remove.
(nodebug_var_symbol_type): Remove.
(_initialize_mdebugread): Do not initialize them.
(parse_symbol): Use builtin nodebug_ type instead of them.
(parse_procedure): Likewise.
diff -urNp gdb-orig/gdb/dwarf2read.c gdb-head/gdb/dwarf2read.c
--- gdb-orig/gdb/dwarf2read.c 2007-06-16 20:59:48.231201000 +0200
+++ gdb-head/gdb/dwarf2read.c 2007-06-16 21:01:39.064106081 +0200
@@ -7150,11 +7150,9 @@ new_symbol (struct die_info *die, struct
with missing type entries. Change the misleading `void' type
to something sensible. */
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
- SYMBOL_TYPE (sym) = init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch)
- / HOST_CHAR_BIT,
- 0, "<variable, no debug info>",
- objfile);
+ SYMBOL_TYPE (sym)
+ = builtin_type (current_gdbarch)->nodebug_data_symbol;
+
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
{
diff -urNp gdb-orig/gdb/gdbtypes.c gdb-head/gdb/gdbtypes.c
--- gdb-orig/gdb/gdbtypes.c 2007-06-16 20:59:48.279194000 +0200
+++ gdb-head/gdb/gdbtypes.c 2007-06-16 21:01:39.112099160 +0200
@@ -3582,6 +3582,23 @@ gdbtypes_post_init (struct gdbarch *gdba
TYPE_FLAG_UNSIGNED,
"__CORE_ADDR", (struct objfile *) NULL);
+
+ /* The following set of types is used for symbols with no
+ debug information. */
+ builtin_type->nodebug_text_symbol
+ = init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
+ TYPE_TARGET_TYPE (builtin_type->nodebug_text_symbol)
+ = builtin_type->builtin_int;
+ builtin_type->nodebug_data_symbol
+ = init_type (TYPE_CODE_INT, gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
+ "<data variable, no debug info>", NULL);
+ builtin_type->nodebug_unknown_symbol
+ = init_type (TYPE_CODE_INT, 1, 0,
+ "<variable (not text or data), no debug info>", NULL);
+ builtin_type->nodebug_tls_symbol
+ = init_type (TYPE_CODE_INT, gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
+ "<thread local variable, no debug info>", NULL);
+
return builtin_type;
}
diff -urNp gdb-orig/gdb/gdbtypes.h gdb-head/gdb/gdbtypes.h
--- gdb-orig/gdb/gdbtypes.h 2007-06-16 20:59:48.323188000 +0200
+++ gdb-head/gdb/gdbtypes.h 2007-06-16 21:01:39.156092817 +0200
@@ -1001,6 +1001,14 @@ struct builtin_type
/* The target CPU's address type. This is the ISA address size. */
struct type *builtin_core_addr;
+
+ /* Types used for symbols with no debug information. */
+ struct type *nodebug_text_symbol;
+ struct type *nodebug_data_symbol;
+ struct type *nodebug_unknown_symbol;
+ struct type *nodebug_tls_symbol;
+
+
/* Integral types. */
/* We use this for the '/c' print format, because c_char is just a
diff -urNp gdb-orig/gdb/mdebugread.c gdb-head/gdb/mdebugread.c
--- gdb-orig/gdb/mdebugread.c 2007-06-16 20:59:48.336186000 +0200
+++ gdb-head/gdb/mdebugread.c 2007-06-16 21:01:39.167091231 +0200
@@ -237,11 +237,6 @@ static struct type *mdebug_type_fixed_de
static struct type *mdebug_type_float_dec;
static struct type *mdebug_type_string;
-/* Types for symbols from files compiled without debugging info. */
-
-static struct type *nodebug_func_symbol_type;
-static struct type *nodebug_var_symbol_type;
-
/* Nonzero if we have seen ecoff debugging info for a file. */
static int found_ecoff_debugging_info;
@@ -660,7 +655,7 @@ parse_symbol (SYMR *sh, union aux_ext *a
/* Type could be missing if file is compiled without debugging info. */
if (SC_IS_UNDEF (sh->sc)
|| sh->sc == scNil || sh->index == indexNil)
- SYMBOL_TYPE (s) = nodebug_var_symbol_type;
+ SYMBOL_TYPE (s) = builtin_type (current_gdbarch)->nodebug_data_symbol;
else
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
/* Value of a data symbol is its memory address */
@@ -1984,7 +1979,7 @@ parse_procedure (PDR *pr, struct symtab
if (processing_gcc_compilation == 0
&& found_ecoff_debugging_info == 0
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID)
- SYMBOL_TYPE (s) = nodebug_func_symbol_type;
+ SYMBOL_TYPE (s) = builtin_type (current_gdbarch)->nodebug_text_symbol;
}
/* Parse the external symbol ES. Just call parse_symbol() after
@@ -4881,12 +4876,4 @@ _initialize_mdebugread (void)
gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
0, "floating decimal",
(struct objfile *) NULL);
-
- nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
- "<function, no debug info>", NULL);
- TYPE_TARGET_TYPE (nodebug_func_symbol_type) = mdebug_type_int;
- nodebug_var_symbol_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
- "<variable, no debug info>", NULL);
}
diff -urNp gdb-orig/gdb/parse.c gdb-head/gdb/parse.c
--- gdb-orig/gdb/parse.c 2007-06-16 20:59:48.379314000 +0200
+++ gdb-head/gdb/parse.c 2007-06-16 21:01:39.211084887 +0200
@@ -384,16 +384,12 @@ write_exp_bitstring (struct stoken str)
based on the language, but they no longer have names like "int", so
the initial rationale is gone. */
-static struct type *msym_text_symbol_type;
-static struct type *msym_data_symbol_type;
-static struct type *msym_unknown_symbol_type;
-static struct type *msym_tls_symbol_type;
-
void
write_exp_msymbol (struct minimal_symbol *msymbol,
struct type *text_symbol_type,
struct type *data_symbol_type)
{
+ struct gdbarch *gdbarch = current_gdbarch;
CORE_ADDR addr;
write_exp_elt_opcode (OP_LONG);
@@ -419,7 +415,7 @@ write_exp_msymbol (struct minimal_symbol
write_exp_elt_opcode (UNOP_MEMVAL_TLS);
write_exp_elt_objfile (ofp);
- write_exp_elt_type (msym_tls_symbol_type);
+ write_exp_elt_type (builtin_type (gdbarch)->nodebug_tls_symbol);
write_exp_elt_opcode (UNOP_MEMVAL_TLS);
return;
}
@@ -430,18 +426,18 @@ write_exp_msymbol (struct minimal_symbol
case mst_text:
case mst_file_text:
case mst_solib_trampoline:
- write_exp_elt_type (msym_text_symbol_type);
+ write_exp_elt_type (builtin_type (gdbarch)->nodebug_text_symbol);
break;
case mst_data:
case mst_file_data:
case mst_bss:
case mst_file_bss:
- write_exp_elt_type (msym_data_symbol_type);
+ write_exp_elt_type (builtin_type (gdbarch)->nodebug_data_symbol);
break;
default:
- write_exp_elt_type (msym_unknown_symbol_type);
+ write_exp_elt_type (builtin_type (gdbarch)->nodebug_unknown_symbol);
break;
}
write_exp_elt_opcode (UNOP_MEMVAL);
@@ -1177,30 +1173,6 @@ follow_types (struct type *follow_type)
return follow_type;
}
-static void build_parse (void);
-static void
-build_parse (void)
-{
- int i;
-
- msym_text_symbol_type =
- init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
- TYPE_TARGET_TYPE (msym_text_symbol_type) = builtin_type_int;
- msym_data_symbol_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
- "<data variable, no debug info>", NULL);
- msym_unknown_symbol_type =
- init_type (TYPE_CODE_INT, 1, 0,
- "<variable (not text or data), no debug info>",
- NULL);
-
- msym_tls_symbol_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
- "<thread local variable, no debug info>", NULL);
-}
-
/* This function avoids direct calls to fprintf
in the parser generated debug code. */
void
@@ -1226,16 +1198,6 @@ _initialize_parse (void)
type_stack = (union type_stack_elt *)
xmalloc (type_stack_size * sizeof (*type_stack));
- build_parse ();
-
- /* FIXME - For the moment, handle types by swapping them in and out.
- Should be using the per-architecture data-pointer and a large
- struct. */
- DEPRECATED_REGISTER_GDBARCH_SWAP (msym_text_symbol_type);
- DEPRECATED_REGISTER_GDBARCH_SWAP (msym_data_symbol_type);
- DEPRECATED_REGISTER_GDBARCH_SWAP (msym_unknown_symbol_type);
- deprecated_register_gdbarch_swap (NULL, 0, build_parse);
-
add_setshow_zinteger_cmd ("expression", class_maintenance,
&expressiondebug, _("\
Set expression debugging."), _("\
diff -urNp gdb-orig/gdb/xcoffread.c gdb-head/gdb/xcoffread.c
--- gdb-orig/gdb/xcoffread.c 2007-06-16 20:59:48.387313000 +0200
+++ gdb-head/gdb/xcoffread.c 2007-06-16 21:01:39.220083590 +0200
@@ -1432,9 +1432,6 @@ read_xcoff_symtab (struct partial_symtab
(ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), &objfile->objfile_obstack);
-static struct type *func_symbol_type;
-static struct type *var_symbol_type;
-
/* process one xcoff symbol. */
static struct symbol *
@@ -1479,7 +1476,7 @@ process_xcoff_symbol (struct coff_symbol
patch_block_stabs (), unless the file was compiled without -g. */
DEPRECATED_SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
- SYMBOL_TYPE (sym) = func_symbol_type;
+ SYMBOL_TYPE (sym) = builtin_type (current_gdbarch)->nodebug_text_symbol;
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_DUP (sym, sym2);
@@ -1492,7 +1489,7 @@ process_xcoff_symbol (struct coff_symbol
else
{
/* In case we can't figure out the type, provide default. */
- SYMBOL_TYPE (sym) = var_symbol_type;
+ SYMBOL_TYPE (sym) = builtin_type (current_gdbarch)->nodebug_data_symbol;
switch (cs->c_sclass)
{
@@ -3022,12 +3019,4 @@ void
_initialize_xcoffread (void)
{
add_symtab_fns (&xcoff_sym_fns);
-
- func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
- "<function, no debug info>", NULL);
- TYPE_TARGET_TYPE (func_symbol_type) = builtin_type_int;
- var_symbol_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
- "<variable, no debug info>", NULL);
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com