* [7/10] Remove unused builtin_type_frame_reg
@ 2007-06-08 23:17 Ulrich Weigand
2007-06-08 23:20 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2007-06-08 23:17 UTC (permalink / raw)
To: gdb-patches
Hello,
another instance of gdbarch-swapped types is the msym_.._type variables used to
represent the contents of variables without debug information.
This patch replace those variables by a per-gdbarch data structure to hold the
types, completely analogous to the main builtin_type.
(The types could have been added to builtin_type, but I prefer this way as it
keeps the parse.c file self-contained.)
Bye,
Ulrich
ChangeLog:
* parse.c (struct msym_type): New data type.
(msym_data): New global variable.
(msym_type): New function.
(msym_post_init): Likewise.
(msym_text_symbol_type, msym_data_symbol_type,
msym_unknown_symbol_type, msym_tls_symbol_type): Remove.
(write_exp_msymbol): Call msym_type instead of using global variables.
(build_parse): Remove.
(_initialize_parse): Do not call build_parse. Do not swap variables.
Register msym_data per-gdbarch data.
diff -urNp gdb-orig/gdb/parse.c gdb-head/gdb/parse.c
--- gdb-orig/gdb/parse.c 2007-06-08 22:17:44.812130679 +0200
+++ gdb-head/gdb/parse.c 2007-06-08 22:21:55.621046338 +0200
@@ -377,6 +377,52 @@ write_exp_bitstring (struct stoken str)
write_exp_elt_longcst ((LONGEST) bits);
}
+
+/* Default data types used for minimal symbols. */
+
+struct msym_type
+ {
+ struct type *text_symbol;
+ struct type *data_symbol;
+ struct type *unknown_symbol;
+ struct type *tls_symbol;
+ };
+
+static struct gdbarch_data *msym_data;
+
+static const struct msym_type *
+msym_type (struct gdbarch *gdbarch)
+{
+ return gdbarch_data (gdbarch, msym_data);
+}
+
+static void *
+msym_post_init (struct gdbarch *gdbarch)
+{
+ struct msym_type *msym_type
+ = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct msym_type);
+
+ msym_type->text_symbol =
+ init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
+ TYPE_TARGET_TYPE (msym_type->text_symbol) =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0, "int", NULL);
+
+ msym_type->data_symbol =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
+ "<data variable, no debug info>", NULL);
+
+ msym_type->unknown_symbol =
+ init_type (TYPE_CODE_INT, 1, 0,
+ "<variable (not text or data), no debug info>",
+ NULL);
+
+ msym_type->tls_symbol =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
+ "<thread local variable, no debug info>", NULL);
+
+ return msym_type;
+}
+
/* Add the appropriate elements for a minimal symbol to the end of
the expression. The rationale behind passing in text_symbol_type and
data_symbol_type was so that Modula-2 could pass in WORD for
@@ -384,11 +430,6 @@ 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,
@@ -419,7 +460,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 (msym_type (current_gdbarch)->tls_symbol);
write_exp_elt_opcode (UNOP_MEMVAL_TLS);
return;
}
@@ -430,18 +471,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 (msym_type (current_gdbarch)->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 (msym_type (current_gdbarch)->data_symbol);
break;
default:
- write_exp_elt_type (msym_unknown_symbol_type);
+ write_exp_elt_type (msym_type (current_gdbarch)->unknown_symbol);
break;
}
write_exp_elt_opcode (UNOP_MEMVAL);
@@ -1175,28 +1216,6 @@ follow_types (struct type *follow_type)
return follow_type;
}
\f
-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, TARGET_INT_BIT / 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, TARGET_INT_BIT / 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
@@ -1222,15 +1241,7 @@ _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);
+ msym_data = gdbarch_data_register_post_init (msym_post_init);
add_setshow_zinteger_cmd ("expression", class_maintenance,
&expressiondebug, _("\
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [7/10] Remove unused builtin_type_frame_reg
2007-06-08 23:17 [7/10] Remove unused builtin_type_frame_reg Ulrich Weigand
@ 2007-06-08 23:20 ` Ulrich Weigand
2007-06-16 18:32 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2007-06-08 23:20 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
Oops, wrong file attached. This is the right one:
Hello,
std-regs.c contains another gdbarch-swapped type, but this is actually nowhere
used (the code that uses it is disabled). This patch removes that disable code
completely; if at any time in the future we want to re-enable it, that type
needs to implemented properly.
Bye,
Ulrich
ChangeLog:
* std-regs.c (builtin_type_frame_reg, build_builtin_type_frame_reg,
value_of_builtin_frame_reg): Remove.
(_initialize_frame_reg): Do not swap builtin_type_frame_reg. Remove
inactive call to value_of_builtin_frame_reg.
diff -urNp gdb-orig/gdb/std-regs.c gdb-head/gdb/std-regs.c
--- gdb-orig/gdb/std-regs.c 2007-06-06 17:19:37.000000000 +0200
+++ gdb-head/gdb/std-regs.c 2007-06-08 18:38:09.209782869 +0200
@@ -28,48 +28,6 @@
#include "value.h"
#include "gdb_string.h"
-/* Types that describe the various builtin registers. */
-
-static struct type *builtin_type_frame_reg;
-
-/* Constructors for those types. */
-
-static void
-build_builtin_type_frame_reg (void)
-{
- /* $frame. */
- if (builtin_type_frame_reg == NULL)
- {
-#if 0
- struct frame
- {
- void *base;
- };
-#endif
- builtin_type_frame_reg = init_composite_type ("frame", TYPE_CODE_STRUCT);
- append_composite_type_field (builtin_type_frame_reg, "base",
- builtin_type_void_data_ptr);
- }
-}
-
-static struct value *
-value_of_builtin_frame_reg (struct frame_info *frame, const void *baton)
-{
- struct value *val;
- gdb_byte *buf;
- build_builtin_type_frame_reg ();
- val = allocate_value (builtin_type_frame_reg);
- VALUE_LVAL (val) = not_lval;
- buf = value_contents_raw (val);
- memset (buf, 0, TYPE_LENGTH (value_type (val)));
- /* frame.base. */
- if (frame != NULL)
- gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
- buf, get_frame_base (frame));
- buf += TYPE_LENGTH (builtin_type_void_data_ptr);
- /* frame.XXX. */
- return val;
-}
static struct value *
value_of_builtin_frame_fp_reg (struct frame_info *frame, const void *baton)
@@ -138,12 +96,6 @@ extern initialize_file_ftype _initialize
void
_initialize_frame_reg (void)
{
- /* FIXME: cagney/2002-02-08: At present the local builtin types
- can't be initialized using _initialize*() or gdbarch. Due mainly
- to non-multi-arch targets, GDB initializes things piece meal and,
- as a consequence can leave these types NULL. */
- DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_frame_reg);
-
/* Frame based $fp, $pc, $sp and $ps. These only come into play
when the target does not define its own version of these
registers. */
@@ -151,10 +103,4 @@ _initialize_frame_reg (void)
user_reg_add_builtin ("pc", value_of_builtin_frame_pc_reg, NULL);
user_reg_add_builtin ("sp", value_of_builtin_frame_sp_reg, NULL);
user_reg_add_builtin ("ps", value_of_builtin_frame_ps_reg, NULL);
-
- /* NOTE: cagney/2002-04-05: For moment leave the $frame / $gdbframe
- / $gdb.frame disabled. It isn't yet clear which of the many
- options is the best. */
- if (0)
- user_reg_add_builtin ("frame", value_of_builtin_frame_reg, NULL);
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [7/10] Remove unused builtin_type_frame_reg
2007-06-08 23:20 ` Ulrich Weigand
@ 2007-06-16 18:32 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2007-06-16 18:32 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> * std-regs.c (builtin_type_frame_reg, build_builtin_type_frame_reg,
> value_of_builtin_frame_reg): Remove.
> (_initialize_frame_reg): Do not swap builtin_type_frame_reg. Remove
> inactive call to value_of_builtin_frame_reg.
I've now committed this one as well.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-16 18:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-08 23:17 [7/10] Remove unused builtin_type_frame_reg Ulrich Weigand
2007-06-08 23:20 ` Ulrich Weigand
2007-06-16 18:32 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox