* [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (13 preceding siblings ...)
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-06 0:38 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
` (24 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-void --]
[-- Type: text/plain, Size: 8140 bytes --]
Hello,
builtin_type_void is currently per-gdbarch type macro, even though the
"void" type conceptually does not depend on the architecture.
The rationale for this is that types derived from it (e.g. pointer to
void or function returning void) *are* gdbarch-specific, and pointers
to those are cached in the type data structure.
However, this problem can be fixed by simply making sure that noone
ever calls lookup_pointer_type, lookup_reference_type, or lookup_function_type
on the platform-neutral builtin_type_void type.
This is nearly everywhere already the case, since we have the per-
gdbarch builtin_data_ptr and builtin_func_ptr for these purposes.
This patch fixes the remaining uses, and converts builtin_type_void
back to a global platform-neutral variable. This allows other parts
of GDB to continue using builtin_type_void in platform-neutral code.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (builtin_type_void): Remove macro, add declaration.
(builtin_type_f_void): Remove macro.
* gdbtypes.c (builtin_type_void): New global variable.
(_initialize_gdbtypes): Initialize it.
* gnu-v3-abi.c (build_gdb_vtable_type): Do not call
lookup_pointer_type or lookup_function_type on builtin_type_void.
* printcmd.c (set_next_address): Likewise.
* objc-lang.c (value_nsstring): Likewise.
* mt-tdep.c (mt_copro_register_type): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* symfile.c (syms_from_objfile): Remove special handling
of builtin_type_void and builtin_type_char.
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -108,6 +108,9 @@ struct type *builtin_type_arm_ext;
struct type *builtin_type_ia64_spill;
struct type *builtin_type_ia64_quad;
+/* Platform-neutral void type. */
+struct type *builtin_type_void;
+
int opaque_type_resolution = 1;
static void
@@ -3330,6 +3333,11 @@ _initialize_gdbtypes (void)
builtin_type_ia64_quad =
build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
+ builtin_type_void =
+ init_type (TYPE_CODE_VOID, 1,
+ 0,
+ "void", (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
@@ -1020,8 +1020,6 @@ extern const struct builtin_type *builti
(builtin_type (current_gdbarch)->builtin_core_addr)
#define builtin_type_true_char \
(builtin_type (current_gdbarch)->builtin_true_char)
-#define builtin_type_void \
- (builtin_type (current_gdbarch)->builtin_void)
#define builtin_type_char \
(builtin_type (current_gdbarch)->builtin_char)
#define builtin_type_short \
@@ -1096,9 +1094,13 @@ extern struct type *builtin_type_arm_ext
extern struct type *builtin_type_ia64_spill;
extern struct type *builtin_type_ia64_quad;
+/* Platform-neutral void type. Never attempt to construct a pointer
+ or reference type to this, because those cannot be platform-neutral.
+ You must use builtin_type (...)->builtin_void in those cases. */
+extern struct type *builtin_type_void;
+
/* This type represents a type that was unrecognized in symbol
read-in. */
-
extern struct type *builtin_type_error;
@@ -1176,8 +1178,6 @@ extern const struct builtin_f_type *buil
(builtin_f_type (current_gdbarch)->builtin_complex_s16)
#define builtin_type_f_complex_s32 \
(builtin_f_type (current_gdbarch)->builtin_complex_s32)
-#define builtin_type_f_void \
- (builtin_f_type (current_gdbarch)->builtin_void)
/* RTTI for C++ */
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -107,9 +107,9 @@ build_gdb_vtable_type (struct gdbarch *a
int offset;
struct type *void_ptr_type
- = lookup_pointer_type (builtin_type_void);
+ = builtin_type (arch)->builtin_data_ptr;
struct type *ptr_to_void_fn_type
- = lookup_pointer_type (lookup_function_type (builtin_type_void));
+ = builtin_type (arch)->builtin_func_ptr;
/* ARCH can't give us the true ptrdiff_t type, so we guess. */
struct type *ptrdiff_type
Index: gdb-head/gdb/mt-tdep.c
===================================================================
--- gdb-head.orig/gdb/mt-tdep.c
+++ gdb-head/gdb/mt-tdep.c
@@ -251,19 +251,13 @@ mt_copro_register_type (struct gdbarch *
static struct type *
mt_register_type (struct gdbarch *arch, int regnum)
{
- static struct type *void_func_ptr = NULL;
- static struct type *void_ptr = NULL;
- static struct type *copro_type;
+ static struct type *copro_type = NULL;
if (regnum >= 0 && regnum < MT_NUM_REGS + MT_NUM_PSEUDO_REGS)
{
- if (void_func_ptr == NULL)
+ if (copro_type == NULL)
{
struct type *temp;
-
- void_ptr = lookup_pointer_type (builtin_type_void);
- void_func_ptr =
- lookup_pointer_type (lookup_function_type (builtin_type_void));
temp = create_range_type (NULL, builtin_type_unsigned_int, 0, 1);
copro_type = create_array_type (NULL, builtin_type_int16, temp);
}
@@ -272,10 +266,10 @@ mt_register_type (struct gdbarch *arch,
case MT_PC_REGNUM:
case MT_RA_REGNUM:
case MT_IRA_REGNUM:
- return void_func_ptr;
+ return builtin_type (arch)->builtin_func_ptr;
case MT_SP_REGNUM:
case MT_FP_REGNUM:
- return void_ptr;
+ return builtin_type (arch)->builtin_data_ptr;
case MT_COPRO_REGNUM:
case MT_COPRO_PSEUDOREG_REGNUM:
return copro_type;
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -173,7 +173,7 @@ value_nsstring (char *ptr, int len)
if (sym == NULL)
sym = lookup_struct_typedef("NXString", 0, 1);
if (sym == NULL)
- type = lookup_pointer_type(builtin_type_void);
+ type = builtin_type_void_data_ptr;
else
type = lookup_pointer_type(SYMBOL_TYPE (sym));
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -513,8 +513,7 @@ set_next_address (CORE_ADDR addr)
/* Make address available to the user as $_. */
set_internalvar (lookup_internalvar ("_"),
- value_from_pointer (lookup_pointer_type (builtin_type_void),
- addr));
+ value_from_pointer (builtin_type_void_data_ptr, addr));
}
/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
Index: gdb-head/gdb/symfile.c
===================================================================
--- gdb-head.orig/gdb/symfile.c
+++ gdb-head/gdb/symfile.c
@@ -898,14 +898,6 @@ syms_from_objfile (struct objfile *objfi
(*objfile->sf->sym_read) (objfile, mainline);
- /* Don't allow char * to have a typename (else would get caddr_t).
- Ditto void *. FIXME: Check whether this is now done by all the
- symbol readers themselves (many of them now do), and if so remove
- it from here. */
-
- TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0;
- TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0;
-
/* Mark the objfile has having had initial symbol read attempted. Note
that this does not mean we found any symbols... */
Index: gdb-head/gdb/xtensa-tdep.c
===================================================================
--- gdb-head.orig/gdb/xtensa-tdep.c
+++ gdb-head/gdb/xtensa-tdep.c
@@ -233,7 +233,7 @@ xtensa_register_type (struct gdbarch *gd
if (regnum == gdbarch_pc_regnum (gdbarch)
|| regnum == gdbarch_tdep (gdbarch)->a0_base + 1)
- return lookup_pointer_type (builtin_type_void);
+ return builtin_type (gdbarch)->builtin_data_ptr;
/* Return the stored type for all other registers. */
else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (9 preceding siblings ...)
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-05 18:18 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines uweigand
` (28 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-sizeof --]
[-- Type: text/plain, Size: 2187 bytes --]
Hello,
evaluate_subexp_for_sizeof simply uses "builtin_type_int" as the type
of its result. This should really be a platform-specific "size_t" type.
The following patch at least uses the proper gdbarch; at some later
point we can add a "size_t" as gdbarch property.
Bye,
Ulrich
ChangeLog:
* eval.c (evaluate_subexp_for_sizeof): Use builtin_int type of
the expression architecture instead of builtin_type_int as the
sizeof return type.
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -2335,6 +2335,8 @@ evaluate_subexp_with_coercion (struct ex
static struct value *
evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
{
+ /* FIXME: This should size_t. */
+ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
enum exp_opcode op;
int pc;
struct type *type;
@@ -2358,24 +2360,22 @@ evaluate_subexp_for_sizeof (struct expre
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
error (_("Attempt to take contents of a non-pointer value."));
type = check_typedef (TYPE_TARGET_TYPE (type));
- return value_from_longest (builtin_type_int, (LONGEST)
- TYPE_LENGTH (type));
+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
case UNOP_MEMVAL:
(*pos) += 3;
type = check_typedef (exp->elts[pc + 1].type);
- return value_from_longest (builtin_type_int,
- (LONGEST) TYPE_LENGTH (type));
+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
case OP_VAR_VALUE:
(*pos) += 4;
type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
return
- value_from_longest (builtin_type_int, (LONGEST) TYPE_LENGTH (type));
+ value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
default:
val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- return value_from_longest (builtin_type_int,
+ return value_from_longest (size_type,
(LONGEST) TYPE_LENGTH (value_type (val)));
}
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (8 preceding siblings ...)
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-01 7:19 ` Tom Tromey
2008-09-05 23:02 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
` (29 subsequent siblings)
39 siblings, 2 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-derefint --]
[-- Type: text/plain, Size: 4394 bytes --]
Hello,
GDB allows to dereference an integer type, treating it as if it were
an "int *". This patch pulls support for this special extension out
of common value_ind code (which doesn't know which architecture to
use for that "int" type) and into the expression evaluators -- which
already handle it for the EVAL_AVOID_SIDE_EFFECTS case.
It might make sense to check for which languages this extension
is actually useful, and remove it from the rest.
Bye,
Ulrich
ChangeLog:
* valops.c (value_ind): No longer allow dereferencing an
integer type.
* eval.c (evaluate_subexp_standard): Handle deferencing an
integer type here.
* ada-lang.c (ada_evaluate_subexp): Likewise.
* jv-lang.c (evaluate_subexp_java): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -9194,7 +9194,8 @@ ada_evaluate_subexp (struct type *expect
}
else if (TYPE_CODE (type) == TYPE_CODE_INT)
/* GDB allows dereferencing an int. */
- return value_zero (builtin_type_int, lval_memory);
+ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ lval_memory);
else
error (_("Attempt to take contents of a non-pointer value."));
}
@@ -9204,6 +9205,10 @@ ada_evaluate_subexp (struct type *expect
if (ada_is_array_descriptor_type (type))
/* GDB allows dereferencing GNAT array descriptors. */
return ada_coerce_to_simple_array (arg1);
+ else if (TYPE_CODE (type) == TYPE_CODE_INT)
+ /* GDB allows dereferencing an int. */
+ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+ (CORE_ADDR) value_as_address (arg1));
else
return ada_value_ind (arg1);
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -2288,10 +2288,19 @@ evaluate_subexp_standard (struct type *e
lval_memory);
else if (TYPE_CODE (type) == TYPE_CODE_INT)
/* GDB allows dereferencing an int. */
- return value_zero (builtin_type_int, lval_memory);
+ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ lval_memory);
else
error (_("Attempt to take contents of a non-pointer value."));
}
+
+ /* Allow * on an integer so we can cast it to whatever we want.
+ This returns an int, which seems like the most C-like thing to
+ do. "long long" variables are rare enough that
+ BUILTIN_TYPE_LONGEST would seem to be a mistake. */
+ if (TYPE_CODE (type) == TYPE_CODE_INT)
+ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+ (CORE_ADDR) value_as_address (arg1));
return value_ind (arg1);
case UNOP_ADDR:
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -855,6 +855,10 @@ evaluate_subexp_java (struct type *expec
}
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_INT)
+ /* GDB allows dereferencing an int. */
+ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+ (CORE_ADDR) value_as_address (arg1));
return value_ind (arg1);
case BINOP_SUBSCRIPT:
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -1166,14 +1166,7 @@ value_ind (struct value *arg1)
base_type = check_typedef (value_type (arg1));
- /* Allow * on an integer so we can cast it to whatever we want.
- This returns an int, which seems like the most C-like thing to
- do. "long long" variables are rare enough that
- BUILTIN_TYPE_LONGEST would seem to be a mistake. */
- if (TYPE_CODE (base_type) == TYPE_CODE_INT)
- return value_at_lazy (builtin_type_int,
- (CORE_ADDR) value_as_address (arg1));
- else if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
+ if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
{
struct type *enc_type;
/* We may be pointing to something embedded in a larger object.
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (5 preceding siblings ...)
2008-08-31 17:52 ` [rfc][33/37] Eliminate builtin_type_ macros: Default target word size uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters uweigand
` (32 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-axgdb --]
[-- Type: text/plain, Size: 29016 bytes --]
Hello,
this patch makes changes equivalent to those done by the previous
series patches to the expression evaluator in ax-gdb.c:
- use the expression's gdbarch instead of current_gdbarch
- use language_bool_type as result type of logical operations
- separate pointer and integer arithmetic; pull out types used
as size_t and ptrdiff_t
Overall, this patch removes all instances of current_gdbarch
(except one) or builtin_type_ macros from ax-gdb.c.
Bye,
Ulrich
ChangeLog:
* ax-gdb.c: Include "language.h".
(gen_frame_args_address): Add GDBARCH parameter; use it
instead of current_gdbarch.
(gen_frame_locals_address): Likewise.
(gen_var_ref): Add GDBARCH parameter. Update calls to
gen_frame_args_address and gen_frame_locals_address. Use
pointer type from gdbarch.
(gen_usual_unary): Add EXP parameter. Use integer type
from exp->gdbarch.
(gen_usual_arithmetic): Likewise.
(gen_integral_promotions): Likewise.
(gen_add, gen_sub): Remove.
(gen_ptradd, gen_ptrsub, gen_ptrdiff): New functions.
(gen_logical_not): Use passed-in boolean result type
instead of builtin_type_int.
(gen_complement): Do not call gen_usual_unary or
gen_integral_promotions.
(gen_struct_ref): Call require_rvalue instead of gen_usual_unary.
(gen_repeat): Add EXP parameter. Update call to gen_expr.
Use builtin_type_int32 as internal range type.
(gen_sizeof): Add EXP and SIZE_TYPE parameters. Use SIZE_TYPE
as result type. Update call to gen_expr.
(gen_expr): Add EXP parameter. Update calls to gen_expr,
gen_repeat, gen_var_ref, gen_usual_unary, gen_usual_arithmetic,
and gen_integral_promotions. Call gen_ptradd, gen_ptrsub,
gen_ptrdiff, or gen_binop instead of gen_add or gen_sub.
Use exp->gdbarch instead of current_gdbarch.
Call language_bool_type to determine result type of UNOP_LOGICAL_NOT.
Index: gdb-head/gdb/ax-gdb.c
===================================================================
--- gdb-head.orig/gdb/ax-gdb.c
+++ gdb-head/gdb/ax-gdb.c
@@ -34,6 +34,7 @@
#include "block.h"
#include "regcache.h"
#include "user-regs.h"
+#include "language.h"
/* To make sense of this file, you should read doc/agentexpr.texi.
Then look at the types and enums in ax-gdb.h. For the code itself,
@@ -72,11 +73,11 @@ static void gen_fetch (struct agent_expr
static void gen_left_shift (struct agent_expr *, int);
-static void gen_frame_args_address (struct agent_expr *);
-static void gen_frame_locals_address (struct agent_expr *);
+static void gen_frame_args_address (struct gdbarch *, struct agent_expr *);
+static void gen_frame_locals_address (struct gdbarch *, struct agent_expr *);
static void gen_offset (struct agent_expr *ax, int offset);
static void gen_sym_offset (struct agent_expr *, struct symbol *);
-static void gen_var_ref (struct agent_expr *ax,
+static void gen_var_ref (struct gdbarch *, struct agent_expr *ax,
struct axs_value *value, struct symbol *var);
@@ -86,35 +87,39 @@ static void gen_int_literal (struct agen
static void require_rvalue (struct agent_expr *ax, struct axs_value *value);
-static void gen_usual_unary (struct agent_expr *ax, struct axs_value *value);
+static void gen_usual_unary (struct expression *exp, struct agent_expr *ax,
+ struct axs_value *value);
static int type_wider_than (struct type *type1, struct type *type2);
static struct type *max_type (struct type *type1, struct type *type2);
static void gen_conversion (struct agent_expr *ax,
struct type *from, struct type *to);
static int is_nontrivial_conversion (struct type *from, struct type *to);
-static void gen_usual_arithmetic (struct agent_expr *ax,
+static void gen_usual_arithmetic (struct expression *exp,
+ struct agent_expr *ax,
struct axs_value *value1,
struct axs_value *value2);
-static void gen_integral_promotions (struct agent_expr *ax,
+static void gen_integral_promotions (struct expression *exp,
+ struct agent_expr *ax,
struct axs_value *value);
static void gen_cast (struct agent_expr *ax,
struct axs_value *value, struct type *type);
static void gen_scale (struct agent_expr *ax,
enum agent_op op, struct type *type);
-static void gen_add (struct agent_expr *ax,
- struct axs_value *value,
- struct axs_value *value1,
- struct axs_value *value2, char *name);
-static void gen_sub (struct agent_expr *ax,
- struct axs_value *value,
- struct axs_value *value1, struct axs_value *value2);
+static void gen_ptradd (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2);
+static void gen_ptrsub (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2);
+static void gen_ptrdiff (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2,
+ struct type *result_type);
static void gen_binop (struct agent_expr *ax,
struct axs_value *value,
struct axs_value *value1,
struct axs_value *value2,
enum agent_op op,
enum agent_op op_unsigned, int may_carry, char *name);
-static void gen_logical_not (struct agent_expr *ax, struct axs_value *value);
+static void gen_logical_not (struct agent_expr *ax, struct axs_value *value,
+ struct type *result_type);
static void gen_complement (struct agent_expr *ax, struct axs_value *value);
static void gen_deref (struct agent_expr *, struct axs_value *);
static void gen_address_of (struct agent_expr *, struct axs_value *);
@@ -126,11 +131,12 @@ static void gen_struct_ref (struct agent
struct axs_value *value,
char *field,
char *operator_name, char *operand_name);
-static void gen_repeat (union exp_element **pc,
+static void gen_repeat (struct expression *exp, union exp_element **pc,
struct agent_expr *ax, struct axs_value *value);
-static void gen_sizeof (union exp_element **pc,
- struct agent_expr *ax, struct axs_value *value);
-static void gen_expr (union exp_element **pc,
+static void gen_sizeof (struct expression *exp, union exp_element **pc,
+ struct agent_expr *ax, struct axs_value *value,
+ struct type *size_type);
+static void gen_expr (struct expression *exp, union exp_element **pc,
struct agent_expr *ax, struct axs_value *value);
static void agent_command (char *exp, int from_tty);
@@ -455,12 +461,12 @@ gen_left_shift (struct agent_expr *ax, i
/* Generate code to push the base address of the argument portion of
the top stack frame. */
static void
-gen_frame_args_address (struct agent_expr *ax)
+gen_frame_args_address (struct gdbarch *gdbarch, struct agent_expr *ax)
{
int frame_reg;
LONGEST frame_offset;
- gdbarch_virtual_frame_pointer (current_gdbarch,
+ gdbarch_virtual_frame_pointer (gdbarch,
ax->scope, &frame_reg, &frame_offset);
ax_reg (ax, frame_reg);
gen_offset (ax, frame_offset);
@@ -470,12 +476,12 @@ gen_frame_args_address (struct agent_exp
/* Generate code to push the base address of the locals portion of the
top stack frame. */
static void
-gen_frame_locals_address (struct agent_expr *ax)
+gen_frame_locals_address (struct gdbarch *gdbarch, struct agent_expr *ax)
{
int frame_reg;
LONGEST frame_offset;
- gdbarch_virtual_frame_pointer (current_gdbarch,
+ gdbarch_virtual_frame_pointer (gdbarch,
ax->scope, &frame_reg, &frame_offset);
ax_reg (ax, frame_reg);
gen_offset (ax, frame_offset);
@@ -520,7 +526,8 @@ gen_sym_offset (struct agent_expr *ax, s
symbol VAR. Set VALUE to describe the result. */
static void
-gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
+gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax,
+ struct axs_value *value, struct symbol *var)
{
/* Dereference any typedefs. */
value->type = check_typedef (SYMBOL_TYPE (var));
@@ -550,22 +557,22 @@ gen_var_ref (struct agent_expr *ax, stru
break;
case LOC_ARG: /* var lives in argument area of frame */
- gen_frame_args_address (ax);
+ gen_frame_args_address (gdbarch, ax);
gen_sym_offset (ax, var);
value->kind = axs_lvalue_memory;
break;
case LOC_REF_ARG: /* As above, but the frame slot really
holds the address of the variable. */
- gen_frame_args_address (ax);
+ gen_frame_args_address (gdbarch, ax);
gen_sym_offset (ax, var);
/* Don't assume any particular pointer size. */
- gen_fetch (ax, lookup_pointer_type (builtin_type_void));
+ gen_fetch (ax, builtin_type (gdbarch)->builtin_data_ptr);
value->kind = axs_lvalue_memory;
break;
case LOC_LOCAL: /* var lives in locals area of frame */
- gen_frame_locals_address (ax);
+ gen_frame_locals_address (gdbarch, ax);
gen_sym_offset (ax, var);
value->kind = axs_lvalue_memory;
break;
@@ -697,7 +704,8 @@ require_rvalue (struct agent_expr *ax, s
lvalue through unchanged, and let `+' raise an error. */
static void
-gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
+gen_usual_unary (struct expression *exp, struct agent_expr *ax,
+ struct axs_value *value)
{
/* We don't have to generate any code for the usual integral
conversions, since values are always represented as full-width on
@@ -732,7 +740,7 @@ gen_usual_unary (struct agent_expr *ax,
/* If the value is an enum, call it an integer. */
case TYPE_CODE_ENUM:
- value->type = builtin_type_int;
+ value->type = builtin_type (exp->gdbarch)->builtin_int;
break;
}
@@ -817,8 +825,8 @@ is_nontrivial_conversion (struct type *f
and promotes each argument to that type. *VALUE1 and *VALUE2
describe the values as they are passed in, and as they are left. */
static void
-gen_usual_arithmetic (struct agent_expr *ax, struct axs_value *value1,
- struct axs_value *value2)
+gen_usual_arithmetic (struct expression *exp, struct agent_expr *ax,
+ struct axs_value *value1, struct axs_value *value2)
{
/* Do the usual binary conversions. */
if (TYPE_CODE (value1->type) == TYPE_CODE_INT
@@ -829,7 +837,7 @@ gen_usual_arithmetic (struct agent_expr
unsigned type is considered "wider" than an n-bit signed
type. Promote to the "wider" of the two types, and always
promote at least to int. */
- struct type *target = max_type (builtin_type_int,
+ struct type *target = max_type (builtin_type (exp->gdbarch)->builtin_int,
max_type (value1->type, value2->type));
/* Deal with value2, on the top of the stack. */
@@ -854,17 +862,20 @@ gen_usual_arithmetic (struct agent_expr
the value on the top of the stack, as described by VALUE. Assume
the value has integral type. */
static void
-gen_integral_promotions (struct agent_expr *ax, struct axs_value *value)
+gen_integral_promotions (struct expression *exp, struct agent_expr *ax,
+ struct axs_value *value)
{
- if (!type_wider_than (value->type, builtin_type_int))
+ const struct builtin_type *builtin = builtin_type (exp->gdbarch);
+
+ if (!type_wider_than (value->type, builtin->builtin_int))
{
- gen_conversion (ax, value->type, builtin_type_int);
- value->type = builtin_type_int;
+ gen_conversion (ax, value->type, builtin->builtin_int);
+ value->type = builtin->builtin_int;
}
- else if (!type_wider_than (value->type, builtin_type_unsigned_int))
+ else if (!type_wider_than (value->type, builtin->builtin_unsigned_int))
{
- gen_conversion (ax, value->type, builtin_type_unsigned_int);
- value->type = builtin_type_unsigned_int;
+ gen_conversion (ax, value->type, builtin->builtin_unsigned_int);
+ value->type = builtin->builtin_unsigned_int;
}
}
@@ -937,105 +948,60 @@ gen_scale (struct agent_expr *ax, enum a
}
-/* Generate code for an addition; non-trivial because we deal with
- pointer arithmetic. We set VALUE to describe the result value; we
- assume VALUE1 and VALUE2 describe the two operands, and that
- they've undergone the usual binary conversions. Used by both
- BINOP_ADD and BINOP_SUBSCRIPT. NAME is used in error messages. */
+/* Generate code for pointer arithmetic PTR + INT. */
static void
-gen_add (struct agent_expr *ax, struct axs_value *value,
- struct axs_value *value1, struct axs_value *value2, char *name)
+gen_ptradd (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2)
{
- /* Is it INT+PTR? */
- if (TYPE_CODE (value1->type) == TYPE_CODE_INT
- && TYPE_CODE (value2->type) == TYPE_CODE_PTR)
- {
- /* Swap the values and proceed normally. */
- ax_simple (ax, aop_swap);
- gen_scale (ax, aop_mul, value2->type);
- ax_simple (ax, aop_add);
- gen_extend (ax, value2->type); /* Catch overflow. */
- value->type = value2->type;
- }
+ gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+ gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_INT);
- /* Is it PTR+INT? */
- else if (TYPE_CODE (value1->type) == TYPE_CODE_PTR
- && TYPE_CODE (value2->type) == TYPE_CODE_INT)
- {
- gen_scale (ax, aop_mul, value1->type);
- ax_simple (ax, aop_add);
- gen_extend (ax, value1->type); /* Catch overflow. */
- value->type = value1->type;
- }
+ gen_scale (ax, aop_mul, value1->type);
+ ax_simple (ax, aop_add);
+ gen_extend (ax, value1->type); /* Catch overflow. */
+ value->type = value1->type;
+ value->kind = axs_rvalue;
+}
- /* Must be number + number; the usual binary conversions will have
- brought them both to the same width. */
- else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
- && TYPE_CODE (value2->type) == TYPE_CODE_INT)
- {
- ax_simple (ax, aop_add);
- gen_extend (ax, value1->type); /* Catch overflow. */
- value->type = value1->type;
- }
- else
- error (_("Invalid combination of types in %s."), name);
+/* Generate code for pointer arithmetic PTR - INT. */
+static void
+gen_ptrsub (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2)
+{
+ gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+ gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_INT);
+ gen_scale (ax, aop_mul, value1->type);
+ ax_simple (ax, aop_sub);
+ gen_extend (ax, value1->type); /* Catch overflow. */
+ value->type = value1->type;
value->kind = axs_rvalue;
}
-/* Generate code for an addition; non-trivial because we have to deal
- with pointer arithmetic. We set VALUE to describe the result
- value; we assume VALUE1 and VALUE2 describe the two operands, and
- that they've undergone the usual binary conversions. */
+/* Generate code for pointer arithmetic PTR - PTR. */
static void
-gen_sub (struct agent_expr *ax, struct axs_value *value,
- struct axs_value *value1, struct axs_value *value2)
-{
- if (TYPE_CODE (value1->type) == TYPE_CODE_PTR)
- {
- /* Is it PTR - INT? */
- if (TYPE_CODE (value2->type) == TYPE_CODE_INT)
- {
- gen_scale (ax, aop_mul, value1->type);
- ax_simple (ax, aop_sub);
- gen_extend (ax, value1->type); /* Catch overflow. */
- value->type = value1->type;
- }
-
- /* Is it PTR - PTR? Strictly speaking, the types ought to
- match, but this is what the normal GDB expression evaluator
- tests for. */
- else if (TYPE_CODE (value2->type) == TYPE_CODE_PTR
- && (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
- == TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))))
- {
- ax_simple (ax, aop_sub);
- gen_scale (ax, aop_div_unsigned, value1->type);
- value->type = builtin_type_long; /* FIXME --- should be ptrdiff_t */
- }
- else
- error (_("\
+gen_ptrdiff (struct agent_expr *ax, struct axs_value *value,
+ struct axs_value *value1, struct axs_value *value2,
+ struct type *result_type)
+{
+ gdb_assert (TYPE_CODE (value1->type) == TYPE_CODE_PTR);
+ gdb_assert (TYPE_CODE (value2->type) == TYPE_CODE_PTR);
+
+ if (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
+ != TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type)))
+ error (_("\
First argument of `-' is a pointer, but second argument is neither\n\
an integer nor a pointer of the same type."));
- }
-
- /* Must be number + number. */
- else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
- && TYPE_CODE (value2->type) == TYPE_CODE_INT)
- {
- ax_simple (ax, aop_sub);
- gen_extend (ax, value1->type); /* Catch overflow. */
- value->type = value1->type;
- }
-
- else
- error (_("Invalid combination of types in subtraction."));
+ ax_simple (ax, aop_sub);
+ gen_scale (ax, aop_div_unsigned, value1->type);
+ value->type = result_type;
value->kind = axs_rvalue;
}
+
/* Generate code for a binary operator that doesn't do pointer magic.
We set VALUE to describe the result value; we assume VALUE1 and
VALUE2 describe the two operands, and that they've undergone the
@@ -1062,15 +1028,15 @@ gen_binop (struct agent_expr *ax, struct
static void
-gen_logical_not (struct agent_expr *ax, struct axs_value *value)
+gen_logical_not (struct agent_expr *ax, struct axs_value *value,
+ struct type *result_type)
{
if (TYPE_CODE (value->type) != TYPE_CODE_INT
&& TYPE_CODE (value->type) != TYPE_CODE_PTR)
error (_("Invalid type of operand to `!'."));
- gen_usual_unary (ax, value);
ax_simple (ax, aop_log_not);
- value->type = builtin_type_int;
+ value->type = result_type;
}
@@ -1080,8 +1046,6 @@ gen_complement (struct agent_expr *ax, s
if (TYPE_CODE (value->type) != TYPE_CODE_INT)
error (_("Invalid type of operand to `~'."));
- gen_usual_unary (ax, value);
- gen_integral_promotions (ax, value);
ax_simple (ax, aop_bit_not);
gen_extend (ax, value->type);
}
@@ -1355,7 +1319,7 @@ gen_struct_ref (struct agent_expr *ax, s
should at least be consistent. */
while (TYPE_CODE (value->type) == TYPE_CODE_PTR)
{
- gen_usual_unary (ax, value);
+ require_rvalue (ax, value);
gen_deref (ax, value);
}
type = check_typedef (value->type);
@@ -1400,13 +1364,13 @@ gen_struct_ref (struct agent_expr *ax, s
stack slots, doing weird things with sizeof, etc. So we require
the right operand to be a constant expression. */
static void
-gen_repeat (union exp_element **pc, struct agent_expr *ax,
- struct axs_value *value)
+gen_repeat (struct expression *exp, union exp_element **pc,
+ struct agent_expr *ax, struct axs_value *value)
{
struct axs_value value1;
/* We don't want to turn this into an rvalue, so no conversions
here. */
- gen_expr (pc, ax, &value1);
+ gen_expr (exp, pc, ax, &value1);
if (value1.kind != axs_lvalue_memory)
error (_("Left operand of `@' must be an object in memory."));
@@ -1429,7 +1393,7 @@ gen_repeat (union exp_element **pc, stru
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
struct type *range
- = create_range_type (0, builtin_type_int, 0, length - 1);
+ = create_range_type (0, builtin_type_int32, 0, length - 1);
struct type *array = create_array_type (0, value1.type, range);
value->kind = axs_lvalue_memory;
@@ -1443,8 +1407,9 @@ gen_repeat (union exp_element **pc, stru
*PC should point at the start of the operand expression; we advance it
to the first instruction after the operand. */
static void
-gen_sizeof (union exp_element **pc, struct agent_expr *ax,
- struct axs_value *value)
+gen_sizeof (struct expression *exp, union exp_element **pc,
+ struct agent_expr *ax, struct axs_value *value,
+ struct type *size_type)
{
/* We don't care about the value of the operand expression; we only
care about its type. However, in the current arrangement, the
@@ -1452,14 +1417,14 @@ gen_sizeof (union exp_element **pc, stru
So we generate code for the operand, and then throw it away,
replacing it with code that simply pushes its size. */
int start = ax->len;
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
/* Throw away the code we just generated. */
ax->len = start;
ax_const_l (ax, TYPE_LENGTH (value->type));
value->kind = axs_rvalue;
- value->type = builtin_type_int;
+ value->type = size_type;
}
\f
@@ -1469,8 +1434,8 @@ gen_sizeof (union exp_element **pc, stru
/* A gen_expr function written by a Gen-X'er guy.
Append code for the subexpression of EXPR starting at *POS_P to AX. */
static void
-gen_expr (union exp_element **pc, struct agent_expr *ax,
- struct axs_value *value)
+gen_expr (struct expression *exp, union exp_element **pc,
+ struct agent_expr *ax, struct axs_value *value)
{
/* Used to hold the descriptions of operand expressions. */
struct axs_value value1, value2;
@@ -1503,18 +1468,40 @@ gen_expr (union exp_element **pc, struct
case BINOP_BITWISE_IOR:
case BINOP_BITWISE_XOR:
(*pc)++;
- gen_expr (pc, ax, &value1);
- gen_usual_unary (ax, &value1);
- gen_expr (pc, ax, &value2);
- gen_usual_unary (ax, &value2);
- gen_usual_arithmetic (ax, &value1, &value2);
+ gen_expr (exp, pc, ax, &value1);
+ gen_usual_unary (exp, ax, &value1);
+ gen_expr (exp, pc, ax, &value2);
+ gen_usual_unary (exp, ax, &value2);
+ gen_usual_arithmetic (exp, ax, &value1, &value2);
switch (op)
{
case BINOP_ADD:
- gen_add (ax, value, &value1, &value2, "addition");
+ if (TYPE_CODE (value1.type) == TYPE_CODE_INT
+ && TYPE_CODE (value2.type) == TYPE_CODE_PTR)
+ {
+ /* Swap the values and proceed normally. */
+ ax_simple (ax, aop_swap);
+ gen_ptradd (ax, value, &value2, &value1);
+ }
+ else if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+ && TYPE_CODE (value2.type) == TYPE_CODE_INT)
+ gen_ptradd (ax, value, &value1, &value2);
+ else
+ gen_binop (ax, value, &value1, &value2,
+ aop_add, aop_add, 1, "addition");
break;
case BINOP_SUB:
- gen_sub (ax, value, &value1, &value2);
+ if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+ && TYPE_CODE (value2.type) == TYPE_CODE_INT)
+ gen_ptrsub (ax,value, &value1, &value2);
+ else if (TYPE_CODE (value1.type) == TYPE_CODE_PTR
+ && TYPE_CODE (value2.type) == TYPE_CODE_PTR)
+ /* FIXME --- result type should be ptrdiff_t */
+ gen_ptrdiff (ax, value, &value1, &value2,
+ builtin_type (exp->gdbarch)->builtin_long);
+ else
+ gen_binop (ax, value, &value1, &value2,
+ aop_sub, aop_sub, 1, "subtraction");
break;
case BINOP_MUL:
gen_binop (ax, value, &value1, &value2,
@@ -1529,7 +1516,7 @@ gen_expr (union exp_element **pc, struct
aop_rem_signed, aop_rem_unsigned, 1, "remainder");
break;
case BINOP_SUBSCRIPT:
- gen_add (ax, value, &value1, &value2, "array subscripting");
+ gen_ptradd (ax, value, &value1, &value2);
if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
error (_("Invalid combination of types in array subscripting."));
gen_deref (ax, value);
@@ -1565,12 +1552,12 @@ gen_expr (union exp_element **pc, struct
variables it mentions get traced. */
case BINOP_COMMA:
(*pc)++;
- gen_expr (pc, ax, &value1);
+ gen_expr (exp, pc, ax, &value1);
/* Don't just dispose of the left operand. We might be tracing,
in which case we want to emit code to trace it if it's an
lvalue. */
gen_traced_pop (ax, &value1);
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
/* It's the consumer's responsibility to trace the right operand. */
break;
@@ -1584,7 +1571,7 @@ gen_expr (union exp_element **pc, struct
break;
case OP_VAR_VALUE:
- gen_var_ref (ax, value, (*pc)[2].symbol);
+ gen_var_ref (exp->gdbarch, ax, value, (*pc)[2].symbol);
(*pc) += 4;
break;
@@ -1593,18 +1580,17 @@ gen_expr (union exp_element **pc, struct
const char *name = &(*pc)[2].string;
int reg;
(*pc) += 4 + BYTES_TO_EXP_ELEM ((*pc)[1].longconst + 1);
- reg = user_reg_map_name_to_regnum (current_gdbarch,
- name, strlen (name));
+ reg = user_reg_map_name_to_regnum (exp->gdbarch, name, strlen (name));
if (reg == -1)
internal_error (__FILE__, __LINE__,
_("Register $%s not available"), name);
- if (reg >= gdbarch_num_regs (current_gdbarch))
+ if (reg >= gdbarch_num_regs (exp->gdbarch))
error (_("'%s' is a pseudo-register; "
"GDB cannot yet trace pseudoregister contents."),
name);
value->kind = axs_lvalue_register;
value->u.reg = reg;
- value->type = register_type (current_gdbarch, reg);
+ value->type = register_type (exp->gdbarch, reg);
}
break;
@@ -1615,14 +1601,14 @@ gen_expr (union exp_element **pc, struct
case BINOP_REPEAT:
/* Note that gen_repeat handles its own argument evaluation. */
(*pc)++;
- gen_repeat (pc, ax, value);
+ gen_repeat (exp, pc, ax, value);
break;
case UNOP_CAST:
{
struct type *type = (*pc)[1].type;
(*pc) += 3;
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
gen_cast (ax, value, type);
}
break;
@@ -1631,7 +1617,7 @@ gen_expr (union exp_element **pc, struct
{
struct type *type = check_typedef ((*pc)[1].type);
(*pc) += 3;
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
/* I'm not sure I understand UNOP_MEMVAL entirely. I think
it's just a hack for dealing with minsyms; you take some
integer constant, pretend it's the address of an lvalue of
@@ -1648,37 +1634,41 @@ gen_expr (union exp_element **pc, struct
case UNOP_PLUS:
(*pc)++;
/* + FOO is equivalent to 0 + FOO, which can be optimized. */
- gen_expr (pc, ax, value);
- gen_usual_unary (ax, value);
+ gen_expr (exp, pc, ax, value);
+ gen_usual_unary (exp, ax, value);
break;
case UNOP_NEG:
(*pc)++;
/* -FOO is equivalent to 0 - FOO. */
- gen_int_literal (ax, &value1, (LONGEST) 0, builtin_type_int);
- gen_usual_unary (ax, &value1); /* shouldn't do much */
- gen_expr (pc, ax, &value2);
- gen_usual_unary (ax, &value2);
- gen_usual_arithmetic (ax, &value1, &value2);
- gen_sub (ax, value, &value1, &value2);
+ gen_int_literal (ax, &value1, (LONGEST) 0, builtin_type_int8);
+ gen_usual_unary (exp, ax, &value1); /* shouldn't do much */
+ gen_expr (exp, pc, ax, &value2);
+ gen_usual_unary (exp, ax, &value2);
+ gen_usual_arithmetic (exp, ax, &value1, &value2);
+ gen_binop (ax, value, &value1, &value2, aop_sub, aop_sub, 1, "negation");
break;
case UNOP_LOGICAL_NOT:
(*pc)++;
- gen_expr (pc, ax, value);
- gen_logical_not (ax, value);
+ gen_expr (exp, pc, ax, value);
+ gen_usual_unary (exp, ax, value);
+ gen_logical_not (ax, value,
+ language_bool_type (exp->language_defn, exp->gdbarch));
break;
case UNOP_COMPLEMENT:
(*pc)++;
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
+ gen_usual_unary (exp, ax, value);
+ gen_integral_promotions (exp, ax, value);
gen_complement (ax, value);
break;
case UNOP_IND:
(*pc)++;
- gen_expr (pc, ax, value);
- gen_usual_unary (ax, value);
+ gen_expr (exp, pc, ax, value);
+ gen_usual_unary (exp, ax, value);
if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
error (_("Argument of unary `*' is not a pointer."));
gen_deref (ax, value);
@@ -1686,7 +1676,7 @@ gen_expr (union exp_element **pc, struct
case UNOP_ADDR:
(*pc)++;
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
gen_address_of (ax, value);
break;
@@ -1695,7 +1685,8 @@ gen_expr (union exp_element **pc, struct
/* Notice that gen_sizeof handles its own operand, unlike most
of the other unary operator functions. This is because we
have to throw away the code we generate. */
- gen_sizeof (pc, ax, value);
+ gen_sizeof (exp, pc, ax, value,
+ builtin_type (exp->gdbarch)->builtin_int);
break;
case STRUCTOP_STRUCT:
@@ -1705,7 +1696,7 @@ gen_expr (union exp_element **pc, struct
char *name = &(*pc)[2].string;
(*pc) += 4 + BYTES_TO_EXP_ELEM (length + 1);
- gen_expr (pc, ax, value);
+ gen_expr (exp, pc, ax, value);
if (op == STRUCTOP_STRUCT)
gen_struct_ref (ax, value, name, ".", "structure or union");
else if (op == STRUCTOP_PTR)
@@ -1748,7 +1739,7 @@ gen_trace_for_expr (CORE_ADDR scope, str
pc = expr->elts;
trace_kludge = 1;
- gen_expr (&pc, ax, &value);
+ gen_expr (expr, &pc, ax, &value);
/* Make sure we record the final object, and get rid of it. */
gen_traced_pop (ax, &value);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (10 preceding siblings ...)
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit uweigand
` (27 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-valarith --]
[-- Type: text/plain, Size: 2011 bytes --]
Hello,
this removes the last remaining instances of builtin_type_ in valarith.c.
value_x_unop can simply use a platform-neutral type for the constant 0
argument ot the UNOP_POSTINCREMENT/UNOP_POSTDECREMENT operator inferior
calls; call_function_by_hand will take care of promoting this to the
proper architecture-specific type when performing the call.
value_bit_index only wants to access one single target byte; there is
no need to use an architecture-specific type to do so.
Bye,
Ulrich
ChangeLog:
* valarith.c (value_x_unop): Use builtin_type_int8 as type for
UNOP_POSTINCREMENT/UNOP_POSTDECREMENT constant 0 argument.
(value_bit_index): Use extract_unsigned_integer
instead of unpack_long to read single byte.
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -541,13 +541,13 @@ value_x_unop (struct value *arg1, enum e
break;
case UNOP_POSTINCREMENT:
strcpy (ptr, "++");
- argvec[2] = value_from_longest (builtin_type_int, 0);
+ argvec[2] = value_from_longest (builtin_type_int8, 0);
argvec[3] = 0;
nargs ++;
break;
case UNOP_POSTDECREMENT:
strcpy (ptr, "--");
- argvec[2] = value_from_longest (builtin_type_int, 0);
+ argvec[2] = value_from_longest (builtin_type_int8, 0);
argvec[3] = 0;
nargs ++;
break;
@@ -1558,8 +1558,7 @@ value_bit_index (struct type *type, cons
if (index < low_bound || index > high_bound)
return -1;
rel_index = index - low_bound;
- word = unpack_long (builtin_type_unsigned_char,
- valaddr + (rel_index / TARGET_CHAR_BIT));
+ word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1);
rel_index %= TARGET_CHAR_BIT;
if (gdbarch_bits_big_endian (current_gdbarch))
rel_index = TARGET_CHAR_BIT - 1 - rel_index;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (16 preceding siblings ...)
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:53 ` [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros uweigand
` (21 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-frame --]
[-- Type: text/plain, Size: 6154 bytes --]
Hello,
a couple of places used builtin_type_ macros where we should be
determining the types from the frame architecture.
Bye,
Ulrich
ChangeLog:
* stack.c (return_command): Use frame architecture to determine
default integer return type.
* f-valprint.c (f77_get_dynamic_lowerbound): Use frame architecture
to determine pointer types.
(f77_get_dynamic_upperbound): Likewise.
* objc-lang.c (OBJC_FETCH_POINTER_ARGUMENT): Remove.
(resolve_msgsend): Use architecture of current frame to determine
pointer types. Inline OBJC_FETCH_POINTER_ARGUMENT.
(resolve_msgsend_stret, resolve_msgsend_super,
resolve_msgsend_super_stret): Likewise.
Index: gdb-head/gdb/f-valprint.c
===================================================================
--- gdb-head.orig/gdb/f-valprint.c
+++ gdb-head/gdb/f-valprint.c
@@ -99,10 +99,11 @@ f77_get_dynamic_lowerbound (struct type
current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
+ struct gdbarch *arch = get_frame_arch (frame);
ptr_to_lower_bound =
read_memory_typed_address (current_frame_addr +
TYPE_ARRAY_LOWER_BOUND_VALUE (type),
- builtin_type_void_data_ptr);
+ builtin_type (arch)->builtin_data_ptr);
*lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
}
else
@@ -165,10 +166,11 @@ f77_get_dynamic_upperbound (struct type
current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
+ struct gdbarch *arch = get_frame_arch (frame);
ptr_to_upper_bound =
read_memory_typed_address (current_frame_addr +
TYPE_ARRAY_UPPER_BOUND_VALUE (type),
- builtin_type_void_data_ptr);
+ builtin_type (arch)->builtin_data_ptr);
*upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
}
else
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -1679,19 +1679,19 @@ find_implementation (CORE_ADDR object, C
return find_implementation_from_class (ostr.isa, sel);
}
-#define OBJC_FETCH_POINTER_ARGUMENT(argi) \
- gdbarch_fetch_pointer_argument (current_gdbarch, get_current_frame (), \
- argi, builtin_type_void_func_ptr)
-
static int
resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc)
{
+ struct frame_info *frame = get_current_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
CORE_ADDR object;
CORE_ADDR sel;
CORE_ADDR res;
- object = OBJC_FETCH_POINTER_ARGUMENT (0);
- sel = OBJC_FETCH_POINTER_ARGUMENT (1);
+ object = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
+ sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
res = find_implementation (object, sel);
if (new_pc != 0)
@@ -1704,12 +1704,16 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR
static int
resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
{
+ struct frame_info *frame = get_current_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
CORE_ADDR object;
CORE_ADDR sel;
CORE_ADDR res;
- object = OBJC_FETCH_POINTER_ARGUMENT (1);
- sel = OBJC_FETCH_POINTER_ARGUMENT (2);
+ object = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
+ sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
res = find_implementation (object, sel);
if (new_pc != 0)
@@ -1722,14 +1726,18 @@ resolve_msgsend_stret (CORE_ADDR pc, COR
static int
resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc)
{
+ struct frame_info *frame = get_current_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
struct objc_super sstr;
CORE_ADDR super;
CORE_ADDR sel;
CORE_ADDR res;
- super = OBJC_FETCH_POINTER_ARGUMENT (0);
- sel = OBJC_FETCH_POINTER_ARGUMENT (1);
+ super = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
+ sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
read_objc_super (super, &sstr);
if (sstr.class == 0)
@@ -1746,14 +1754,18 @@ resolve_msgsend_super (CORE_ADDR pc, COR
static int
resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
{
+ struct frame_info *frame = get_current_frame ();
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
struct objc_super sstr;
CORE_ADDR super;
CORE_ADDR sel;
CORE_ADDR res;
- super = OBJC_FETCH_POINTER_ARGUMENT (1);
- sel = OBJC_FETCH_POINTER_ARGUMENT (2);
+ super = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
+ sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
read_objc_super (super, &sstr);
if (sstr.class == 0)
Index: gdb-head/gdb/stack.c
===================================================================
--- gdb-head.orig/gdb/stack.c
+++ gdb-head/gdb/stack.c
@@ -1780,11 +1780,13 @@ down_command (char *count_exp, int from_
void
return_command (char *retval_exp, int from_tty)
{
+ struct frame_info *thisframe;
struct symbol *thisfun;
struct value *return_value = NULL;
const char *query_prefix = "";
- thisfun = get_frame_function (get_selected_frame ("No selected frame."));
+ thisframe = get_selected_frame ("No selected frame.");
+ thisfun = get_frame_function (thisframe);
/* Compute the return value. If the computation triggers an error,
let it bail. If the return type can't be handled, set
@@ -1803,7 +1805,7 @@ return_command (char *retval_exp, int fr
if (thisfun != NULL)
return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
if (return_type == NULL)
- return_type = builtin_type_int;
+ return_type = builtin_type (get_frame_arch (thisframe))->builtin_int;
CHECK_TYPEDEF (return_type);
return_value = value_cast (return_type, return_value);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (6 preceding siblings ...)
2008-08-31 17:52 ` [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
` (31 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-msym --]
[-- Type: text/plain, Size: 9463 bytes --]
Hello,
this patch removes the (unused) TEXT_SYMBOL_TYPE and DATA_SYMBOL_TYPE
arguments from write_exp_msymbol, removing the need for all callers
to construct type parameters to pass in.
Bye,
Ulrich
ChangeLog:
* parser-defs.h (write_exp_msymbol): Remove TEXT_SYMBOL_TYPE
and DATA_SYMBOL_TYPE arguments.
* parse.c (write_exp_msymbol): Remove TEXT_SYMBOL_TYPE and
DATA_SYMBOL_TYPE arguments. Replace use of builtin_type_CORE_ADDR.
(write_dollar_variable): Update call.
* ada-exp.y (write_var_or_type): Update call.
* c-exp.y: Likewise.
* f-exp.y: Likewise.
* jv-exp.y: Likewise.
* m2-exp.y: Likewise.
* objc-exp.y: Likewise.
* p-exp.y: Likewise.
Index: gdb-head/gdb/ada-exp.y
===================================================================
--- gdb-head.orig/gdb/ada-exp.y
+++ gdb-head/gdb/ada-exp.y
@@ -1370,8 +1370,7 @@ write_var_or_type (struct block *block,
= ada_lookup_simple_minsym (encoded_name);
if (msym != NULL)
{
- write_exp_msymbol (msym, lookup_function_type (type_int ()),
- type_int ());
+ write_exp_msymbol (msym);
/* Maybe cause error here rather than later? FIXME? */
write_selectors (encoded_name + tail_index);
return NULL;
Index: gdb-head/gdb/c-exp.y
===================================================================
--- gdb-head.orig/gdb/c-exp.y
+++ gdb-head/gdb/c-exp.y
@@ -700,16 +700,11 @@ variable: qualified_name
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
- builtin_type (current_gdbarch)->builtin_int);
- }
+ write_exp_msymbol (msymbol);
+ else if (!have_full_symbols () && !have_partial_symbols ())
+ error ("No symbol table is loaded. Use the \"file\" command.");
else
- if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
- else
- error ("No symbol \"%s\" in current context.", name);
+ error ("No symbol \"%s\" in current context.", name);
}
;
@@ -756,11 +751,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
- builtin_type (current_gdbarch)->builtin_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
else
Index: gdb-head/gdb/f-exp.y
===================================================================
--- gdb-head.orig/gdb/f-exp.y
+++ gdb-head/gdb/f-exp.y
@@ -510,11 +510,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
else
Index: gdb-head/gdb/jv-exp.y
===================================================================
--- gdb-head.orig/gdb/jv-exp.y
+++ gdb-head/gdb/jv-exp.y
@@ -1397,11 +1397,7 @@ push_expression_name (name)
msymbol = lookup_minimal_symbol (tmp, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command"));
else
Index: gdb-head/gdb/m2-exp.y
===================================================================
--- gdb-head.orig/gdb/m2-exp.y
+++ gdb-head/gdb/m2-exp.y
@@ -630,12 +630,7 @@ variable: NAME
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol
- (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"symbol-file\" command.");
else
Index: gdb-head/gdb/objc-exp.y
===================================================================
--- gdb-head.orig/gdb/objc-exp.y
+++ gdb-head/gdb/objc-exp.y
@@ -715,16 +715,11 @@ variable: qualified_name
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
+ else if (!have_full_symbols () && !have_partial_symbols ())
+ error ("No symbol table is loaded. Use the \"file\" command.");
else
- if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
- else
- error ("No symbol \"%s\" in current context.", name);
+ error ("No symbol \"%s\" in current context.", name);
}
;
@@ -771,11 +766,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () &&
!have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -400,16 +400,10 @@ write_exp_bitstring (struct stoken str)
}
/* 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
- data_symbol_type. Perhaps it still is useful to have those types vary
- based on the language, but they no longer have names like "int", so
- the initial rationale is gone. */
+ the expression. */
void
-write_exp_msymbol (struct minimal_symbol *msymbol,
- struct type *text_symbol_type,
- struct type *data_symbol_type)
+write_exp_msymbol (struct minimal_symbol *msymbol)
{
struct objfile *objfile = msymbol_objfile (msymbol);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -436,7 +430,7 @@ write_exp_msymbol (struct minimal_symbol
write_exp_elt_opcode (OP_LONG);
/* Let's make the type big enough to hold a 64-bit address. */
- write_exp_elt_type (builtin_type_CORE_ADDR);
+ write_exp_elt_type (builtin_type (gdbarch)->builtin_core_addr);
write_exp_elt_longcst ((LONGEST) addr);
write_exp_elt_opcode (OP_LONG);
@@ -576,9 +570,7 @@ write_dollar_variable (struct stoken str
msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
if (msym)
{
- write_exp_msymbol (msym,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
+ write_exp_msymbol (msym);
return;
}
Index: gdb-head/gdb/parser-defs.h
===================================================================
--- gdb-head.orig/gdb/parser-defs.h
+++ gdb-head/gdb/parser-defs.h
@@ -133,8 +133,7 @@ extern void write_exp_elt_block (struct
extern void write_exp_elt_objfile (struct objfile *objfile);
-extern void write_exp_msymbol (struct minimal_symbol *,
- struct type *, struct type *);
+extern void write_exp_msymbol (struct minimal_symbol *);
extern void write_dollar_variable (struct stoken str);
Index: gdb-head/gdb/p-exp.y
===================================================================
--- gdb-head.orig/gdb/p-exp.y
+++ gdb-head/gdb/p-exp.y
@@ -654,16 +654,11 @@ variable: qualified_name
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
+ else if (!have_full_symbols () && !have_partial_symbols ())
+ error ("No symbol table is loaded. Use the \"file\" command.");
else
- if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
- else
- error ("No symbol \"%s\" in current context.", name);
+ error ("No symbol \"%s\" in current context.", name);
}
;
@@ -725,11 +720,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
+ write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
else
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (12 preceding siblings ...)
2008-08-31 17:52 ` [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-02 12:43 ` Daniel Jacobowitz
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
` (25 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-internal --]
[-- Type: text/plain, Size: 10531 bytes --]
Hello,
the values stored in internal variables (like $_, $bpnum,
$_exitcode etc.) currently use architecture-specific types
like builtin_type_int. However, in many cases this doesn't
really make sense, as it is not quite clear which architecture
should be used ...
The patch below converts all internal variables to always use
platform-neutral types to store values. For integral values,
builtin_type_int32 is used. For characters, builtin_type_true_char.
One problem is the $_ variable, which holds a pointer value. To
allow using a platform-neutral type for this, I'm introducing a
new platform-neutral pointer type builtin_type_void_ptr. The
lenght of this type is chosen so that it can hold every CORE_ADDR
value.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (builtin_type_void_ptr): New declaration.
* gdbtypes.c (builtin_type_void_ptr): New variable.
(_initialize_gdbtypes): Initialize it.
* breakpoint.c (set_breakpoint_count): Use platform-neutral
types for internal variable values.
* findcmd.c (find_command): Likewise.
* infrun.c (handle_inferior_event): Likewise.
* printcmd.c (set_next_address): Likewise.
* source.c (forward_search_command, reverse_search_command): Likewise.
* tracepoint.c (set_tracepoint_count, set_traceframe_num,
set_tracepoint_num, set_traceframe_context): Likewise.
Index: gdb-head/gdb/breakpoint.c
===================================================================
--- gdb-head.orig/gdb/breakpoint.c
+++ gdb-head/gdb/breakpoint.c
@@ -401,7 +401,7 @@ set_breakpoint_count (int num)
{
breakpoint_count = num;
set_internalvar (lookup_internalvar ("bpnum"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Used in run_command to zero the hit count when a new run starts. */
Index: gdb-head/gdb/findcmd.c
===================================================================
--- gdb-head.orig/gdb/findcmd.c
+++ gdb-head/gdb/findcmd.c
@@ -292,12 +292,12 @@ find_command (char *args, int from_tty)
/* Record and print the results. */
set_internalvar (lookup_internalvar ("numfound"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) found_count));
if (found_count > 0)
{
set_internalvar (lookup_internalvar ("_"),
- value_from_pointer (builtin_type_void_data_ptr,
+ value_from_pointer (builtin_type_void_ptr,
last_found_addr));
}
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -2017,7 +2017,7 @@ handle_inferior_event (struct execution_
/* Record the exit code in the convenience variable $_exitcode, so
that the user can inspect this again later. */
set_internalvar (lookup_internalvar ("_exitcode"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) ecs->ws.value.integer));
gdb_flush (gdb_stdout);
target_mourn_inferior ();
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -509,7 +509,7 @@ set_next_address (CORE_ADDR addr)
/* Make address available to the user as $_. */
set_internalvar (lookup_internalvar ("_"),
- value_from_pointer (builtin_type_void_data_ptr, addr));
+ value_from_pointer (builtin_type_void_ptr, addr));
}
/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
Index: gdb-head/gdb/source.c
===================================================================
--- gdb-head.orig/gdb/source.c
+++ gdb-head/gdb/source.c
@@ -1614,7 +1614,7 @@ forward_search_command (char *regex, int
fclose (stream);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) line));
current_source_line = max (line - lines_to_list / 2, 1);
return;
@@ -1696,7 +1696,7 @@ reverse_search_command (char *regex, int
fclose (stream);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) line));
current_source_line = max (line - lines_to_list / 2, 1);
return;
Index: gdb-head/gdb/tracepoint.c
===================================================================
--- gdb-head.orig/gdb/tracepoint.c
+++ gdb-head/gdb/tracepoint.c
@@ -220,7 +220,7 @@ set_tracepoint_count (int num)
{
tracepoint_count = num;
set_internalvar (lookup_internalvar ("tpnum"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set traceframe number to NUM. */
@@ -229,7 +229,7 @@ set_traceframe_num (int num)
{
traceframe_number = num;
set_internalvar (lookup_internalvar ("trace_frame"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set tracepoint number to NUM. */
@@ -238,8 +238,7 @@ set_tracepoint_num (int num)
{
tracepoint_number = num;
set_internalvar (lookup_internalvar ("tracepoint"),
- value_from_longest (builtin_type_int,
- (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set externally visible debug variables for querying/printing
@@ -252,23 +251,19 @@ set_traceframe_context (CORE_ADDR trace_
static struct type *func_range, *file_range;
struct value *func_val;
struct value *file_val;
- static struct type *charstar;
int len;
- if (charstar == (struct type *) NULL)
- charstar = lookup_pointer_type (builtin_type_char);
-
if (trace_pc == -1) /* Cease debugging any trace buffers. */
{
traceframe_fun = 0;
traceframe_sal.pc = traceframe_sal.line = 0;
traceframe_sal.symtab = NULL;
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_pointer (charstar, (LONGEST) 0));
+ value_from_pointer (builtin_type_void_ptr, 0));
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_pointer (charstar, (LONGEST) 0));
+ value_from_pointer (builtin_type_void_ptr, 0));
set_internalvar (lookup_internalvar ("trace_line"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) - 1));
return;
}
@@ -280,7 +275,7 @@ set_traceframe_context (CORE_ADDR trace_
/* Save linenumber as "$trace_line", a debugger variable visible to
users. */
set_internalvar (lookup_internalvar ("trace_line"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) traceframe_sal.line));
/* Save func name as "$trace_func", a debugger variable visible to
@@ -288,14 +283,14 @@ set_traceframe_context (CORE_ADDR trace_
if (traceframe_fun == NULL ||
SYMBOL_LINKAGE_NAME (traceframe_fun) == NULL)
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_pointer (charstar, (LONGEST) 0));
+ value_from_pointer (builtin_type_void_ptr, 0));
else
{
len = strlen (SYMBOL_LINKAGE_NAME (traceframe_fun));
func_range = create_range_type (func_range,
- builtin_type_int, 0, len - 1);
+ builtin_type_int32, 0, len - 1);
func_string = create_array_type (func_string,
- builtin_type_char, func_range);
+ builtin_type_true_char, func_range);
func_val = allocate_value (func_string);
deprecated_set_value_type (func_val, func_string);
memcpy (value_contents_raw (func_val),
@@ -310,14 +305,14 @@ set_traceframe_context (CORE_ADDR trace_
if (traceframe_sal.symtab == NULL ||
traceframe_sal.symtab->filename == NULL)
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_pointer (charstar, (LONGEST) 0));
+ value_from_pointer (builtin_type_void_ptr, 0));
else
{
len = strlen (traceframe_sal.symtab->filename);
file_range = create_range_type (file_range,
- builtin_type_int, 0, len - 1);
+ builtin_type_int32, 0, len - 1);
file_string = create_array_type (file_string,
- builtin_type_char, file_range);
+ builtin_type_true_char, file_range);
file_val = allocate_value (file_string);
deprecated_set_value_type (file_val, file_string);
memcpy (value_contents_raw (file_val),
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -111,6 +111,9 @@ struct type *builtin_type_ia64_quad;
/* Platform-neutral void type. */
struct type *builtin_type_void;
+/* Platform-neutral void pointer type. */
+struct type *builtin_type_void_ptr;
+
/* Platform-neutral character types. */
struct type *builtin_type_true_char;
struct type *builtin_type_true_unsigned_char;
@@ -3333,6 +3336,12 @@ _initialize_gdbtypes (void)
init_type (TYPE_CODE_VOID, 1,
0,
"void", (struct objfile *) NULL);
+ builtin_type_void_ptr =
+ init_type (TYPE_CODE_PTR, sizeof (CORE_ADDR),
+ TYPE_FLAG_UNSIGNED,
+ NULL, (struct objfile *) NULL);
+ TYPE_TARGET_TYPE (builtin_type_void_ptr) = builtin_type_void;
+
builtin_type_true_char =
init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0,
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -1091,6 +1091,10 @@ extern struct type *builtin_type_ia64_qu
You must use builtin_type (...)->builtin_void in those cases. */
extern struct type *builtin_type_void;
+/* Platform-neutral void pointer type. The size of this type is chosen
+ so it is large enough to hold every CORE_ADDR value. */
+extern struct type *builtin_type_void_ptr;
+
/* 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
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc uweigand
` (38 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-printfixes --]
[-- Type: text/plain, Size: 6752 bytes --]
Hello,
this removes a number of builtin_type_ uses remaining in value-printing code.
Note that the printcmd.c locations still access current_gdbarch after this
patch; making the print routines architecture-aware will require some
additional follow-on effort.
Bye,
Ulrich
ChangeLog:
* expprint.c (print_subexp_standard): Compare against builtin type
associated with exp->gdbarch instead of builtin_type_char.
* f-valprint.c (f_val_print): Use extract_unsigned_integer to
extract values of arbitrary logical type. Handle arbitrary
complex types.
* printcmd.c (float_type_from_length): New function.
(print_scalar_formatted, printf_command): Use it.
Index: gdb-head/gdb/expprint.c
===================================================================
--- gdb-head.orig/gdb/expprint.c
+++ gdb-head/gdb/expprint.c
@@ -237,7 +237,8 @@ print_subexp_standard (struct expression
nargs++;
tem = 0;
if (exp->elts[pc + 4].opcode == OP_LONG
- && exp->elts[pc + 5].type == builtin_type_char
+ && exp->elts[pc + 5].type
+ == builtin_type (exp->gdbarch)->builtin_char
&& exp->language_defn->la_language == language_c)
{
/* Attempt to print C character arrays using string syntax.
@@ -252,7 +253,8 @@ print_subexp_standard (struct expression
while (tem < nargs)
{
if (exp->elts[pc].opcode != OP_LONG
- || exp->elts[pc + 1].type != builtin_type_char)
+ || exp->elts[pc + 1].type
+ != builtin_type (exp->gdbarch)->builtin_char)
{
/* Not a simple array of char, use regular array printing. */
tem = 0;
Index: gdb-head/gdb/f-valprint.c
===================================================================
--- gdb-head.orig/gdb/f-valprint.c
+++ gdb-head/gdb/f-valprint.c
@@ -523,26 +523,7 @@ f_val_print (struct type *type, const gd
print_scalar_formatted (valaddr, type, format, 0, stream);
else
{
- val = 0;
- switch (TYPE_LENGTH (type))
- {
- case 1:
- val = unpack_long (builtin_type_f_logical_s1, valaddr);
- break;
-
- case 2:
- val = unpack_long (builtin_type_f_logical_s2, valaddr);
- break;
-
- case 4:
- val = unpack_long (builtin_type_f_logical, valaddr);
- break;
-
- default:
- error (_("Logicals of length %d bytes not supported"),
- TYPE_LENGTH (type));
-
- }
+ val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
if (val == 0)
fprintf_filtered (stream, ".FALSE.");
@@ -562,20 +543,7 @@ f_val_print (struct type *type, const gd
break;
case TYPE_CODE_COMPLEX:
- switch (TYPE_LENGTH (type))
- {
- case 8:
- type = builtin_type_f_real;
- break;
- case 16:
- type = builtin_type_f_real_s8;
- break;
- case 32:
- type = builtin_type_f_real_s16;
- break;
- default:
- error (_("Cannot print out complex*%d variables"), TYPE_LENGTH (type));
- }
+ type = TYPE_TARGET_TYPE (type);
fputs_filtered ("(", stream);
print_floating (valaddr, type, stream);
fputs_filtered (",", stream);
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -309,6 +309,24 @@ print_formatted (struct value *val, int
format, size, stream);
}
+/* Return builtin floating point type of same length as TYPE.
+ If no such type is found, return TYPE itself. */
+static struct type *
+float_type_from_length (struct gdbarch *gdbarch, struct type *type)
+{
+ const struct builtin_type *builtin = builtin_type (gdbarch);
+ unsigned int len = TYPE_LENGTH (type);
+
+ if (len == TYPE_LENGTH (builtin->builtin_float))
+ type = builtin->builtin_float;
+ else if (len == TYPE_LENGTH (builtin->builtin_double))
+ type = builtin->builtin_double;
+ else if (len == TYPE_LENGTH (builtin->builtin_long_double))
+ type = builtin->builtin_long_double;
+
+ return type;
+}
+
/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
according to letters FORMAT and SIZE on STREAM.
FORMAT may not be zero. Formats s and i are not supported at this level.
@@ -434,12 +452,7 @@ print_scalar_formatted (const void *vala
break;
case 'f':
- if (len == TYPE_LENGTH (builtin_type_float))
- type = builtin_type_float;
- else if (len == TYPE_LENGTH (builtin_type_double))
- type = builtin_type_double;
- else if (len == TYPE_LENGTH (builtin_type_long_double))
- type = builtin_type_long_double;
+ type = float_type_from_length (current_gdbarch, type);
print_floating (valaddr, type, stream);
break;
@@ -1994,17 +2007,6 @@ printf_command (char *arg, int from_tty)
s1 = s;
val_args[nargs] = parse_to_comma_and_eval (&s1);
- /* If format string wants a float, unchecked-convert the value to
- floating point of the same size */
-
- if (argclass[nargs] == double_arg)
- {
- struct type *type = value_type (val_args[nargs]);
- if (TYPE_LENGTH (type) == sizeof (float))
- deprecated_set_value_type (val_args[nargs], builtin_type_float);
- if (TYPE_LENGTH (type) == sizeof (double))
- deprecated_set_value_type (val_args[nargs], builtin_type_double);
- }
nargs++;
s = s1;
if (*s == ',')
@@ -2048,15 +2050,35 @@ printf_command (char *arg, int from_tty)
break;
case double_arg:
{
- double val = value_as_double (val_args[i]);
- printf_filtered (current_substring, val);
+ struct type *type = value_type (val_args[i]);
+ DOUBLEST val;
+ int inv;
+
+ /* If format string wants a float, unchecked-convert the value
+ to floating point of the same size. */
+ type = float_type_from_length (current_gdbarch, type);
+ val = unpack_double (type, value_contents (val_args[i]), &inv);
+ if (inv)
+ error (_("Invalid floating value found in program."));
+
+ printf_filtered (current_substring, (double) val);
break;
}
case long_double_arg:
#ifdef HAVE_LONG_DOUBLE
{
- long double val = value_as_double (val_args[i]);
- printf_filtered (current_substring, val);
+ struct type *type = value_type (val_args[i]);
+ DOUBLEST val;
+ int inv;
+
+ /* If format string wants a float, unchecked-convert the value
+ to floating point of the same size. */
+ type = float_type_from_length (current_gdbarch, type);
+ val = unpack_double (type, value_contents (val_args[i]), &inv);
+ if (inv)
+ error (_("Invalid floating value found in program."));
+
+ printf_filtered (current_substring, (long double) val);
break;
}
#else
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (3 preceding siblings ...)
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][33/37] Eliminate builtin_type_ macros: Default target word size uweigand
` (34 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-parse --]
[-- Type: text/plain, Size: 46200 bytes --]
Hello,
this patch introduces a new member of struct expression to hold
the architecture the expression was parsed in. It uses this
member throughout the language parsers to refer to properties
of the architecture, replacing current_gdbarch and builtin_type_
macros. In addition, some uses of current_language are replaced
in favour of the (already existing) language_defn field of struct
expression.
parse_exp_in_context initializes the new field to current_gdbarch;
this should be pushed up into the callers (together with the use
of current_language at the same place). Joel has been working on
a patch set to push up current_language; it should be simple to
extend this to also push up current_gdbarch. This is not part
of the current patch series, however.
Bye,
Ulrich
ChangeLog:
* expression.h (struct expression): New member GDBARCH.
* parse.c (parse_exp_in_context): Initialize it.
* parser-def.h (parse_gdbarch, parse_language): New macros.
* ada-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
Replace current_language by parse_language.
* ada-lex.l (processInt): Replace current_gdbarch by parse_gdbarch.
Replace builtin_type_ macros.
* c-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* f-exp.y (parse_type, parse_f_type): New macros.
Replace builtin_type_ macros by using parse_{f_,}type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* jv-exp.y (parse_type): New macro.
(parse_number): Replace builtin_type_ macros by using parse_type.
* m2-exp.y (parse_type, parse_m2_type): New macros.
Replace builtin_type_ macros by using parse_{m2_,}type.
* objc-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* p-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
Index: gdb-head/gdb/ada-exp.y
===================================================================
--- gdb-head.orig/gdb/ada-exp.y
+++ gdb-head/gdb/ada-exp.y
@@ -52,6 +52,8 @@ Boston, MA 02110-1301, USA. */
#include "frame.h"
#include "block.h"
+#define parse_type builtin_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. These are only the variables
@@ -571,7 +573,7 @@ opt_type_prefix :
type_prefix
| /* EMPTY */
{ write_exp_elt_opcode (OP_TYPE);
- write_exp_elt_type (builtin_type_void);
+ write_exp_elt_type (parse_type->builtin_void);
write_exp_elt_opcode (OP_TYPE); }
;
@@ -1081,8 +1083,8 @@ static struct type*
find_primitive_type (char *name)
{
struct type *type;
- type = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch,
+ type = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch,
name);
if (type == NULL && strcmp ("system__address", name) == 0)
type = type_system_address ();
@@ -1463,59 +1465,59 @@ convert_char_literal (struct type *type,
static struct type *
type_int (void)
{
- return builtin_type_int;
+ return parse_type->builtin_int;
}
static struct type *
type_long (void)
{
- return builtin_type_long;
+ return parse_type->builtin_long;
}
static struct type *
type_long_long (void)
{
- return builtin_type_long_long;
+ return parse_type->builtin_long_long;
}
static struct type *
type_float (void)
{
- return builtin_type_float;
+ return parse_type->builtin_float;
}
static struct type *
type_double (void)
{
- return builtin_type_double;
+ return parse_type->builtin_double;
}
static struct type *
type_long_double (void)
{
- return builtin_type_long_double;
+ return parse_type->builtin_long_double;
}
static struct type *
type_char (void)
{
- return language_string_char_type (current_language, current_gdbarch);
+ return language_string_char_type (parse_language, parse_gdbarch);
}
static struct type *
type_boolean (void)
{
- return builtin_type_bool;
+ return parse_type->builtin_bool;
}
static struct type *
type_system_address (void)
{
struct type *type
- = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch,
+ = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch,
"system__address");
- return type != NULL ? type : lookup_pointer_type (builtin_type_void);
+ return type != NULL ? type : parse_type->builtin_data_ptr;
}
void
Index: gdb-head/gdb/ada-lex.l
===================================================================
--- gdb-head.orig/gdb/ada-lex.l
+++ gdb-head/gdb/ada-lex.l
@@ -351,11 +351,11 @@ processInt (const char *base0, const cha
exp -= 1;
}
- if ((result >> (gdbarch_int_bit (current_gdbarch)-1)) == 0)
+ if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0)
yylval.typed_val.type = type_int ();
- else if ((result >> (gdbarch_long_bit (current_gdbarch)-1)) == 0)
+ else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0)
yylval.typed_val.type = type_long ();
- else if (((result >> (gdbarch_long_bit (current_gdbarch)-1)) >> 1) == 0)
+ else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0)
{
/* We have a number representable as an unsigned integer quantity.
For consistency with the C treatment, we will treat it as an
@@ -364,7 +364,8 @@ processInt (const char *base0, const cha
for the mess, but C doesn't officially guarantee that a simple
assignment does the trick (no, it doesn't; read the reference manual).
*/
- yylval.typed_val.type = builtin_type_unsigned_long;
+ yylval.typed_val.type
+ = builtin_type (parse_gdbarch)->builtin_unsigned_long;
if (result & LONGEST_SIGN)
yylval.typed_val.val =
(LONGEST) (result & ~LONGEST_SIGN)
@@ -386,10 +387,10 @@ processReal (const char *num0)
sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
yylval.typed_val_float.type = type_float ();
- if (sizeof(DOUBLEST) >= gdbarch_double_bit (current_gdbarch)
+ if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch)
/ TARGET_CHAR_BIT)
yylval.typed_val_float.type = type_double ();
- if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (current_gdbarch)
+ if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch)
/ TARGET_CHAR_BIT)
yylval.typed_val_float.type = type_long_double ();
Index: gdb-head/gdb/c-exp.y
===================================================================
--- gdb-head.orig/gdb/c-exp.y
+++ gdb-head/gdb/c-exp.y
@@ -55,6 +55,8 @@ Boston, MA 02110-1301, USA. */
#include "cp-support.h"
#include "dfp.h"
+#define parse_type builtin_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
@@ -554,7 +556,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int);
+ write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
@@ -570,12 +572,12 @@ exp : STRING
while (count-- > 0)
{
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG);
}
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY);
@@ -587,14 +589,14 @@ exp : STRING
/* C++. */
exp : TRUEKEYWORD
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
+ write_exp_elt_type (parse_type->builtin_bool);
write_exp_elt_longcst ((LONGEST) 1);
write_exp_elt_opcode (OP_LONG); }
;
exp : FALSEKEYWORD
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
+ write_exp_elt_type (parse_type->builtin_bool);
write_exp_elt_longcst ((LONGEST) 0);
write_exp_elt_opcode (OP_LONG); }
;
@@ -841,61 +843,61 @@ typebase /* Implements (approximately):
: TYPENAME
{ $$ = $1.type; }
| INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_int; }
+ { $$ = parse_type->builtin_int; }
| LONG
- { $$ = builtin_type (current_gdbarch)->builtin_long; }
+ { $$ = parse_type->builtin_long; }
| SHORT
- { $$ = builtin_type (current_gdbarch)->builtin_short; }
+ { $$ = parse_type->builtin_short; }
| LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long; }
+ { $$ = parse_type->builtin_long; }
| LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long; }
+ { $$ = parse_type->builtin_long; }
| LONG SIGNED_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long; }
+ { $$ = parse_type->builtin_long; }
| SIGNED_KEYWORD LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long; }
+ { $$ = parse_type->builtin_long; }
| UNSIGNED LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+ { $$ = parse_type->builtin_unsigned_long; }
| LONG UNSIGNED INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+ { $$ = parse_type->builtin_unsigned_long; }
| LONG UNSIGNED
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
+ { $$ = parse_type->builtin_unsigned_long; }
| LONG LONG
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| LONG LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| LONG LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| LONG LONG SIGNED_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| SIGNED_KEYWORD LONG LONG
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| SIGNED_KEYWORD LONG LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| UNSIGNED LONG LONG
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| UNSIGNED LONG LONG INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| LONG LONG UNSIGNED
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| LONG LONG UNSIGNED INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| SHORT INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_short; }
+ { $$ = parse_type->builtin_short; }
| SHORT SIGNED_KEYWORD INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_short; }
+ { $$ = parse_type->builtin_short; }
| SHORT SIGNED_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_short; }
+ { $$ = parse_type->builtin_short; }
| UNSIGNED SHORT INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+ { $$ = parse_type->builtin_unsigned_short; }
| SHORT UNSIGNED
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+ { $$ = parse_type->builtin_unsigned_short; }
| SHORT UNSIGNED INT_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
+ { $$ = parse_type->builtin_unsigned_short; }
| DOUBLE_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_double; }
+ { $$ = parse_type->builtin_double; }
| LONG DOUBLE_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_long_double; }
+ { $$ = parse_type->builtin_long_double; }
| STRUCT name
{ $$ = lookup_struct (copy_name ($2),
expression_context_block); }
@@ -911,11 +913,11 @@ typebase /* Implements (approximately):
| UNSIGNED typename
{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
| UNSIGNED
- { $$ = builtin_type (current_gdbarch)->builtin_unsigned_int; }
+ { $$ = parse_type->builtin_unsigned_int; }
| SIGNED_KEYWORD typename
{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
- { $$ = builtin_type (current_gdbarch)->builtin_int; }
+ { $$ = parse_type->builtin_int; }
/* It appears that this rule for templates is never
reduced; template recognition happens by lookahead
in the token processing code in yylex. */
@@ -1005,19 +1007,19 @@ typename: TYPENAME
{
$$.stoken.ptr = "int";
$$.stoken.length = 3;
- $$.type = builtin_type (current_gdbarch)->builtin_int;
+ $$.type = parse_type->builtin_int;
}
| LONG
{
$$.stoken.ptr = "long";
$$.stoken.length = 4;
- $$.type = builtin_type (current_gdbarch)->builtin_long;
+ $$.type = parse_type->builtin_long;
}
| SHORT
{
$$.stoken.ptr = "short";
$$.stoken.length = 5;
- $$.type = builtin_type (current_gdbarch)->builtin_short;
+ $$.type = parse_type->builtin_short;
}
;
@@ -1120,7 +1122,7 @@ parse_number (p, len, parsed_float, puti
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = builtin_type (current_gdbarch)->builtin_decfloat;
+ = parse_type->builtin_decfloat;
decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
p[len - 2] = 'd';
return DECFLOAT;
@@ -1130,7 +1132,7 @@ parse_number (p, len, parsed_float, puti
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = builtin_type (current_gdbarch)->builtin_decdouble;
+ = parse_type->builtin_decdouble;
decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
p[len - 2] = 'd';
return DECFLOAT;
@@ -1140,7 +1142,7 @@ parse_number (p, len, parsed_float, puti
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = builtin_type (current_gdbarch)->builtin_declong;
+ = parse_type->builtin_declong;
decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
p[len - 2] = 'd';
return DECFLOAT;
@@ -1155,7 +1157,7 @@ parse_number (p, len, parsed_float, puti
if (num == 1)
putithere->typed_val_float.type =
- builtin_type (current_gdbarch)->builtin_double;
+ parse_type->builtin_double;
if (num == 2 )
{
@@ -1163,10 +1165,10 @@ parse_number (p, len, parsed_float, puti
double. */
if (!strcasecmp (s, "f"))
putithere->typed_val_float.type =
- builtin_type (current_gdbarch)->builtin_float;
+ parse_type->builtin_float;
else if (!strcasecmp (s, "l"))
putithere->typed_val_float.type =
- builtin_type (current_gdbarch)->builtin_long_double;
+ parse_type->builtin_long_double;
else
{
free (s);
@@ -1277,9 +1279,9 @@ parse_number (p, len, parsed_float, puti
un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+ high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1287,28 +1289,28 @@ parse_number (p, len, parsed_float, puti
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int;
- signed_type = builtin_type (current_gdbarch)->builtin_int;
+ unsigned_type = parse_type->builtin_unsigned_int;
+ signed_type = parse_type->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
- unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long;
- signed_type = builtin_type (current_gdbarch)->builtin_long;
+ high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+ unsigned_type = parse_type->builtin_unsigned_long;
+ signed_type = parse_type->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (current_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch))
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
- shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
+ shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
high_bit = (ULONGEST) 1 << shift;
- unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long;
- signed_type = builtin_type (current_gdbarch)->builtin_long_long;
+ unsigned_type = parse_type->builtin_unsigned_long_long;
+ signed_type = parse_type->builtin_long_long;
}
putithere->typed_val_int.val = n;
@@ -1481,7 +1483,7 @@ yylex ()
}
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char;
+ yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++;
if (c != '\'')
@@ -1733,7 +1735,7 @@ yylex ()
case 8:
if (strncmp (tokstart, "unsigned", 8) == 0)
return UNSIGNED;
- if (current_language->la_language == language_cplus
+ if (parse_language->la_language == language_cplus
&& strncmp (tokstart, "template", 8) == 0)
return TEMPLATE;
if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1750,7 +1752,7 @@ yylex ()
return DOUBLE_KEYWORD;
break;
case 5:
- if (current_language->la_language == language_cplus)
+ if (parse_language->la_language == language_cplus)
{
if (strncmp (tokstart, "false", 5) == 0)
return FALSEKEYWORD;
@@ -1769,7 +1771,7 @@ yylex ()
return ENUM;
if (strncmp (tokstart, "long", 4) == 0)
return LONG;
- if (current_language->la_language == language_cplus)
+ if (parse_language->la_language == language_cplus)
{
if (strncmp (tokstart, "true", 4) == 0)
return TRUEKEYWORD;
@@ -1805,7 +1807,7 @@ yylex ()
sym = lookup_symbol (tmp, expression_context_block,
VAR_DOMAIN,
- current_language->la_language == language_cplus
+ parse_language->la_language == language_cplus
? &is_a_field_of_this : (int *) NULL);
/* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the
@@ -1838,8 +1840,8 @@ yylex ()
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch, tmp);
if (yylval.tsym.type != NULL)
return TYPENAME;
Index: gdb-head/gdb/expression.h
===================================================================
--- gdb-head.orig/gdb/expression.h
+++ gdb-head/gdb/expression.h
@@ -373,6 +373,7 @@ union exp_element
struct expression
{
const struct language_defn *language_defn; /* language it was entered in */
+ struct gdbarch *gdbarch; /* architecture it was parsed in */
int nelts;
union exp_element elts[1];
};
Index: gdb-head/gdb/f-exp.y
===================================================================
--- gdb-head.orig/gdb/f-exp.y
+++ gdb-head/gdb/f-exp.y
@@ -57,6 +57,9 @@ Boston, MA 02110-1301, USA. */
#include "block.h"
#include <ctype.h>
+#define parse_type builtin_type (parse_gdbarch)
+#define parse_f_type builtin_f_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
@@ -447,7 +450,7 @@ exp : NAME_OR_INT
exp : FLOAT
{ write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (builtin_type_f_real_s8);
+ write_exp_elt_type (parse_f_type->builtin_real_s8);
write_exp_elt_dblcst ($1);
write_exp_elt_opcode (OP_DOUBLE); }
;
@@ -460,7 +463,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_f_integer);
+ write_exp_elt_type (parse_f_type->builtin_integer);
CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
@@ -551,8 +554,8 @@ ptype : typebase
{
range_type =
create_range_type ((struct type *) NULL,
- builtin_type_f_integer, 0,
- array_size - 1);
+ parse_f_type->builtin_integer,
+ 0, array_size - 1);
follow_type =
create_array_type ((struct type *) NULL,
follow_type, range_type);
@@ -597,29 +600,29 @@ typebase /* Implements (approximately):
: TYPENAME
{ $$ = $1.type; }
| INT_KEYWORD
- { $$ = builtin_type_f_integer; }
+ { $$ = parse_f_type->builtin_integer; }
| INT_S2_KEYWORD
- { $$ = builtin_type_f_integer_s2; }
+ { $$ = parse_f_type->builtin_integer_s2; }
| CHARACTER
- { $$ = builtin_type_f_character; }
+ { $$ = parse_f_type->builtin_character; }
| LOGICAL_KEYWORD
- { $$ = builtin_type_f_logical;}
+ { $$ = parse_f_type->builtin_logical; }
| LOGICAL_S2_KEYWORD
- { $$ = builtin_type_f_logical_s2;}
+ { $$ = parse_f_type->builtin_logical_s2; }
| LOGICAL_S1_KEYWORD
- { $$ = builtin_type_f_logical_s1;}
+ { $$ = parse_f_type->builtin_logical_s1; }
| REAL_KEYWORD
- { $$ = builtin_type_f_real;}
+ { $$ = parse_f_type->builtin_real; }
| REAL_S8_KEYWORD
- { $$ = builtin_type_f_real_s8;}
+ { $$ = parse_f_type->builtin_real_s8; }
| REAL_S16_KEYWORD
- { $$ = builtin_type_f_real_s16;}
+ { $$ = parse_f_type->builtin_real_s16; }
| COMPLEX_S8_KEYWORD
- { $$ = builtin_type_f_complex_s8;}
+ { $$ = parse_f_type->builtin_complex_s8; }
| COMPLEX_S16_KEYWORD
- { $$ = builtin_type_f_complex_s16;}
+ { $$ = parse_f_type->builtin_complex_s16; }
| COMPLEX_S32_KEYWORD
- { $$ = builtin_type_f_complex_s32;}
+ { $$ = parse_f_type->builtin_complex_s32; }
;
nonempty_typelist
@@ -762,26 +765,26 @@ parse_number (p, len, parsed_float, puti
target int size is different to the target long size.
In the expression below, we could have tested
- (n >> gdbarch_int_bit (current_gdbarch))
+ (n >> gdbarch_int_bit (parse_gdbarch))
to see if it was zero,
but too many compilers warn about that, when ints and longs
are the same size. So we shift it twice, with fewer bits
each time, for the same result. */
- if ((gdbarch_int_bit (current_gdbarch) != gdbarch_long_bit (current_gdbarch)
+ if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch)
&& ((n >> 2)
- >> (gdbarch_int_bit (current_gdbarch)-2))) /* Avoid shift warning */
+ >> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */
|| long_p)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch)-1);
- unsigned_type = builtin_type_unsigned_long;
- signed_type = builtin_type_long;
+ high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1);
+ unsigned_type = parse_type->builtin_unsigned_long;
+ signed_type = parse_type->builtin_long;
}
else
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch)-1);
- unsigned_type = builtin_type_unsigned_int;
- signed_type = builtin_type_int;
+ high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1);
+ unsigned_type = parse_type->builtin_unsigned_int;
+ signed_type = parse_type->builtin_int;
}
putithere->typed_val.val = n;
@@ -1170,7 +1173,7 @@ yylex ()
sym = lookup_symbol (tmp, expression_context_block,
VAR_DOMAIN,
- current_language->la_language == language_cplus
+ parse_language->la_language == language_cplus
? &is_a_field_of_this : NULL);
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
@@ -1178,8 +1181,8 @@ yylex ()
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch, tmp);
if (yylval.tsym.type != NULL)
return TYPENAME;
Index: gdb-head/gdb/jv-exp.y
===================================================================
--- gdb-head.orig/gdb/jv-exp.y
+++ gdb-head/gdb/jv-exp.y
@@ -51,6 +51,8 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h"
+#define parse_type builtin_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
@@ -723,9 +725,9 @@ parse_number (p, len, parsed_float, puti
c = tolower (p[len - 1]);
if (c == 'f' || c == 'F')
- putithere->typed_val_float.type = builtin_type_float;
+ putithere->typed_val_float.type = parse_type->builtin_float;
else if (isdigit (c) || c == '.' || c == 'd' || c == 'D')
- putithere->typed_val_float.type = builtin_type_double;
+ putithere->typed_val_float.type = parse_type->builtin_double;
else
return ERROR;
Index: gdb-head/gdb/m2-exp.y
===================================================================
--- gdb-head.orig/gdb/m2-exp.y
+++ gdb-head/gdb/m2-exp.y
@@ -52,6 +52,9 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h"
+#define parse_type builtin_type (parse_gdbarch)
+#define parse_m2_type builtin_m2_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
@@ -497,7 +500,7 @@ exp : M2_FALSE
exp : INT
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_int);
+ write_exp_elt_type (parse_m2_type->builtin_int);
write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); }
;
@@ -505,7 +508,7 @@ exp : INT
exp : UINT
{
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_card);
+ write_exp_elt_type (parse_m2_type->builtin_card);
write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG);
}
@@ -513,7 +516,7 @@ exp : UINT
exp : CHAR
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_char);
+ write_exp_elt_type (parse_m2_type->builtin_char);
write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); }
;
@@ -521,7 +524,7 @@ exp : CHAR
exp : FLOAT
{ write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (builtin_type_m2_real);
+ write_exp_elt_type (parse_m2_type->builtin_real);
write_exp_elt_dblcst ($1);
write_exp_elt_opcode (OP_DOUBLE); }
;
@@ -531,7 +534,7 @@ exp : variable
exp : SIZE '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
+ write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
;
@@ -654,14 +657,14 @@ int
overflow(a,b)
long a,b;
{
- return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a;
+ return (MAX_OF_TYPE(parse_m2_type->builtin_int) - b) < a;
}
int
uoverflow(a,b)
unsigned long a,b;
{
- return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a;
+ return (MAX_OF_TYPE(parse_m2_type->builtin_card) - b) < a;
}
#endif /* FIXME */
Index: gdb-head/gdb/objc-exp.y
===================================================================
--- gdb-head.orig/gdb/objc-exp.y
+++ gdb-head/gdb/objc-exp.y
@@ -54,6 +54,8 @@
#include "completer.h" /* For skip_quoted(). */
#include "block.h"
+#define parse_type builtin_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
etc), as well as gratuitiously global symbol names, so we can have
multiple yacc generated parsers in gdb. Note that these are only
@@ -338,7 +340,7 @@ exp : '[' TYPENAME
error ("%s is not an ObjC Class",
copy_name ($2.stoken));
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
+ write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) class);
write_exp_elt_opcode (OP_LONG);
start_msglist();
@@ -353,7 +355,7 @@ exp : '[' TYPENAME
exp : '[' CLASSNAME
{
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
+ write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) $2.class);
write_exp_elt_opcode (OP_LONG);
start_msglist();
@@ -575,7 +577,7 @@ exp : SELECTOR
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
+ write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
@@ -592,12 +594,12 @@ exp : STRING
while (count-- > 0)
{
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG);
}
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY);
@@ -860,31 +862,31 @@ typebase /* Implements (approximately):
$$ = $1.type;
}
| INT_KEYWORD
- { $$ = builtin_type_int; }
+ { $$ = parse_type->builtin_int; }
| LONG
- { $$ = builtin_type_long; }
+ { $$ = parse_type->builtin_long; }
| SHORT
- { $$ = builtin_type_short; }
+ { $$ = parse_type->builtin_short; }
| LONG INT_KEYWORD
- { $$ = builtin_type_long; }
+ { $$ = parse_type->builtin_long; }
| UNSIGNED LONG INT_KEYWORD
- { $$ = builtin_type_unsigned_long; }
+ { $$ = parse_type->builtin_unsigned_long; }
| LONG LONG
- { $$ = builtin_type_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| LONG LONG INT_KEYWORD
- { $$ = builtin_type_long_long; }
+ { $$ = parse_type->builtin_long_long; }
| UNSIGNED LONG LONG
- { $$ = builtin_type_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| UNSIGNED LONG LONG INT_KEYWORD
- { $$ = builtin_type_unsigned_long_long; }
+ { $$ = parse_type->builtin_unsigned_long_long; }
| SHORT INT_KEYWORD
- { $$ = builtin_type_short; }
+ { $$ = parse_type->builtin_short; }
| UNSIGNED SHORT INT_KEYWORD
- { $$ = builtin_type_unsigned_short; }
+ { $$ = parse_type->builtin_unsigned_short; }
| DOUBLE_KEYWORD
- { $$ = builtin_type_double; }
+ { $$ = parse_type->builtin_double; }
| LONG DOUBLE_KEYWORD
- { $$ = builtin_type_long_double; }
+ { $$ = parse_type->builtin_long_double; }
| STRUCT name
{ $$ = lookup_struct (copy_name ($2),
expression_context_block); }
@@ -900,11 +902,11 @@ typebase /* Implements (approximately):
| UNSIGNED typename
{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
| UNSIGNED
- { $$ = builtin_type_unsigned_int; }
+ { $$ = parse_type->builtin_unsigned_int; }
| SIGNED_KEYWORD typename
{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
- { $$ = builtin_type_int; }
+ { $$ = parse_type->builtin_int; }
| TEMPLATE name '<' type '>'
{ $$ = lookup_template_type(copy_name($2), $4,
expression_context_block);
@@ -921,19 +923,19 @@ typename: TYPENAME
{
$$.stoken.ptr = "int";
$$.stoken.length = 3;
- $$.type = builtin_type_int;
+ $$.type = parse_type->builtin_int;
}
| LONG
{
$$.stoken.ptr = "long";
$$.stoken.length = 4;
- $$.type = builtin_type_long;
+ $$.type = parse_type->builtin_long;
}
| SHORT
{
$$.stoken.ptr = "short";
$$.stoken.length = 5;
- $$.type = builtin_type_short;
+ $$.type = parse_type->builtin_short;
}
;
@@ -1019,11 +1021,11 @@ parse_number (p, len, parsed_float, puti
c = tolower (p[len - 1]);
if (c == 'f')
- putithere->typed_val_float.type = builtin_type_float;
+ putithere->typed_val_float.type = parse_type->builtin_float;
else if (c == 'l')
- putithere->typed_val_float.type = builtin_type_long_double;
+ putithere->typed_val_float.type = parse_type->builtin_long_double;
else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = builtin_type_double;
+ putithere->typed_val_float.type = parse_type->builtin_double;
else
return ERROR;
@@ -1129,9 +1131,9 @@ parse_number (p, len, parsed_float, puti
un = (unsigned LONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+ high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1139,28 +1141,28 @@ parse_number (p, len, parsed_float, puti
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = builtin_type_unsigned_int;
- signed_type = builtin_type_int;
+ unsigned_type = parse_type->builtin_unsigned_int;
+ signed_type = parse_type->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
- unsigned_type = builtin_type_unsigned_long;
- signed_type = builtin_type_long;
+ high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+ unsigned_type = parse_type->builtin_unsigned_long;
+ signed_type = parse_type->builtin_long;
}
else
{
high_bit = (((unsigned LONGEST)1)
- << (gdbarch_long_long_bit (current_gdbarch) - 32 - 1)
+ << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1)
<< 16
<< 16);
if (high_bit == 0)
/* A long long does not fit in a LONGEST. */
high_bit =
(unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
- unsigned_type = builtin_type_unsigned_long_long;
- signed_type = builtin_type_long_long;
+ unsigned_type = parse_type->builtin_unsigned_long_long;
+ signed_type = parse_type->builtin_long_long;
}
putithere->typed_val_int.val = n;
@@ -1276,7 +1278,7 @@ yylex ()
error ("Empty character constant.");
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = builtin_type_char;
+ yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++;
if (c != '\'')
@@ -1562,7 +1564,7 @@ yylex ()
case 8:
if (strncmp (tokstart, "unsigned", 8) == 0)
return UNSIGNED;
- if (current_language->la_language == language_cplus
+ if (parse_language->la_language == language_cplus
&& strncmp (tokstart, "template", 8) == 0)
return TEMPLATE;
if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1579,7 +1581,7 @@ yylex ()
return DOUBLE_KEYWORD;
break;
case 5:
- if ((current_language->la_language == language_cplus)
+ if ((parse_language->la_language == language_cplus)
&& strncmp (tokstart, "class", 5) == 0)
return CLASS;
if (strncmp (tokstart, "union", 5) == 0)
@@ -1623,8 +1625,8 @@ yylex ()
int is_a_field_of_this = 0, *need_this;
int hextype;
- if (current_language->la_language == language_cplus ||
- current_language->la_language == language_objc)
+ if (parse_language->la_language == language_cplus ||
+ parse_language->la_language == language_objc)
need_this = &is_a_field_of_this;
else
need_this = (int *) NULL;
@@ -1736,8 +1738,8 @@ yylex ()
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch, tmp);
if (yylval.tsym.type != NULL)
return TYPENAME;
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -1027,6 +1027,7 @@ parse_exp_in_context (char **stringptr,
expout = (struct expression *)
xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
expout->language_defn = current_language;
+ expout->gdbarch = current_gdbarch;
TRY_CATCH (except, RETURN_MASK_ALL)
{
Index: gdb-head/gdb/parser-defs.h
===================================================================
--- gdb-head.orig/gdb/parser-defs.h
+++ gdb-head/gdb/parser-defs.h
@@ -32,6 +32,9 @@ extern struct expression *expout;
extern int expout_size;
extern int expout_ptr;
+#define parse_gdbarch (expout->gdbarch)
+#define parse_language (expout->language_defn)
+
/* If this is nonzero, this block is used as the lexical context
for symbol names. */
Index: gdb-head/gdb/p-exp.y
===================================================================
--- gdb-head.orig/gdb/p-exp.y
+++ gdb-head/gdb/p-exp.y
@@ -58,6 +58,8 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h"
+#define parse_type builtin_type (parse_gdbarch)
+
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
@@ -381,8 +383,8 @@ exp : exp '/' {
&& is_integral_type (current_type))
{
write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (builtin_type_long_double);
- current_type = builtin_type_long_double;
+ write_exp_elt_type (parse_type->builtin_long_double);
+ current_type = parse_type->builtin_long_double;
write_exp_elt_opcode (UNOP_CAST);
leftdiv_is_integer = 0;
}
@@ -417,37 +419,37 @@ exp : exp RSH exp
exp : exp '=' exp
{ write_exp_elt_opcode (BINOP_EQUAL);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
exp : exp NOTEQUAL exp
{ write_exp_elt_opcode (BINOP_NOTEQUAL);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
exp : exp LEQ exp
{ write_exp_elt_opcode (BINOP_LEQ);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
exp : exp GEQ exp
{ write_exp_elt_opcode (BINOP_GEQ);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
exp : exp '<' exp
{ write_exp_elt_opcode (BINOP_LESS);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
exp : exp '>' exp
{ write_exp_elt_opcode (BINOP_GTR);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
}
;
@@ -470,14 +472,14 @@ exp : exp ASSIGN exp
exp : TRUEKEYWORD
{ write_exp_elt_opcode (OP_BOOL);
write_exp_elt_longcst ((LONGEST) $1);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
write_exp_elt_opcode (OP_BOOL); }
;
exp : FALSEKEYWORD
{ write_exp_elt_opcode (OP_BOOL);
write_exp_elt_longcst ((LONGEST) $1);
- current_type = builtin_type_bool;
+ current_type = parse_type->builtin_bool;
write_exp_elt_opcode (OP_BOOL); }
;
@@ -518,7 +520,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
+ write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
@@ -534,12 +536,12 @@ exp : STRING
while (count-- > 0)
{
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG);
}
write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
+ write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY);
@@ -832,11 +834,11 @@ parse_number (p, len, parsed_float, puti
c = tolower (p[len - 1]);
if (c == 'f')
- putithere->typed_val_float.type = builtin_type_float;
+ putithere->typed_val_float.type = parse_type->builtin_float;
else if (c == 'l')
- putithere->typed_val_float.type = builtin_type_long_double;
+ putithere->typed_val_float.type = parse_type->builtin_long_double;
else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = builtin_type_double;
+ putithere->typed_val_float.type = parse_type->builtin_double;
else
return ERROR;
@@ -942,9 +944,9 @@ parse_number (p, len, parsed_float, puti
un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
+ high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -952,28 +954,28 @@ parse_number (p, len, parsed_float, puti
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = builtin_type_unsigned_int;
- signed_type = builtin_type_int;
+ unsigned_type = parse_type->builtin_unsigned_int;
+ signed_type = parse_type->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
- unsigned_type = builtin_type_unsigned_long;
- signed_type = builtin_type_long;
+ high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+ unsigned_type = parse_type->builtin_unsigned_long;
+ signed_type = parse_type->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (current_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch))
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
- shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
+ shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
high_bit = (ULONGEST) 1 << shift;
- unsigned_type = builtin_type_unsigned_long_long;
- signed_type = builtin_type_long_long;
+ unsigned_type = parse_type->builtin_unsigned_long_long;
+ signed_type = parse_type->builtin_long_long;
}
putithere->typed_val_int.val = n;
@@ -1142,7 +1144,7 @@ yylex ()
error ("Empty character constant.");
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = builtin_type_char;
+ yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++;
if (c != '\'')
@@ -1636,8 +1638,8 @@ yylex ()
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (current_language,
- current_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language,
+ parse_gdbarch, tmp);
if (yylval.tsym.type != NULL)
{
free (uptokstart);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (2 preceding siblings ...)
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-06 3:15 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture uweigand
` (35 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-neutral --]
[-- Type: text/plain, Size: 16677 bytes --]
Hello,
a number of places use "builtin_type_int" when they need some generic
integer type, e.g. as range type for some internal array, or as fall-back
default if the real type is unknown. This patch changes those places
to simply use builtin_type_int32 instead.
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_coerce_to_simple_array_type): Use builtin_type_int32
instead of builtin_type_int as default unspecified integral type.
(ada_index_type, ada_array_bound_from_type, ada_variant_discrim_type,
assign_component, to_fixed_range_type): Likewise.
* ada-typeprint.c (print_range, print_range_bound,
print_range_type_named): Likewise.
* ada-valprint.c (print_optional_low_bound, ada_val_print_1): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Likewise.
* gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset,
build_gdb_vtable_type): Likewise.
* jv-lang.c (java_array_type): Likewise.
* m2-typeprint.c (m2_print_bounds, m2_is_long_set_of_type): Likewise.
* m2-valprint.c (m2_print_long_set): Likewise.
* parse.c (follow_types): Likewise.
* p-typeprint.c (pascal_type_print_base): Likewise.
* valops.c (value_one, value_array, value_string,
value_bitstring): Likewise.
* value.c (allocate_repeat_value, value_from_string): Likewise.
* varobj.c (c_describe_child): Likewise.
* mt-tdep.c (mt_register_type): Likewise.
* sh-tdep.c (sh_sh4_build_float_register_type): Likewise.
* sh64-tdep.c (sh64_build_float_register_type): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -1768,7 +1768,7 @@ struct type *
ada_coerce_to_simple_array_type (struct type *type)
{
struct value *mark = value_mark ();
- struct value *dummy = value_from_longest (builtin_type_long, 0);
+ struct value *dummy = value_from_longest (builtin_type_int32, 0);
struct type *result;
deprecated_set_value_type (dummy, type);
result = ada_type_of_array (dummy, 0);
@@ -2509,7 +2509,7 @@ ada_index_type (struct type *type, int n
has a target type of TYPE_CODE_UNDEF. We compensate here, but
perhaps stabsread.c would make more sense. */
if (result_type == NULL || TYPE_CODE (result_type) == TYPE_CODE_UNDEF)
- result_type = builtin_type_int;
+ result_type = builtin_type_int32;
return result_type;
}
@@ -2537,7 +2537,7 @@ ada_array_bound_from_type (struct type *
if (arr_type == NULL || !ada_is_simple_array_type (arr_type))
{
if (typep != NULL)
- *typep = builtin_type_int;
+ *typep = builtin_type_int32;
return (LONGEST) - which;
}
@@ -5905,7 +5905,7 @@ ada_variant_discrim_type (struct type *v
struct type *type =
ada_lookup_struct_elt_type (outer_type, name, 1, 1, NULL);
if (type == NULL)
- return builtin_type_int;
+ return builtin_type_int32;
else
return type;
}
@@ -8117,7 +8117,7 @@ assign_component (struct value *containe
struct value *elt;
if (TYPE_CODE (value_type (lhs)) == TYPE_CODE_ARRAY)
{
- struct value *index_val = value_from_longest (builtin_type_int, index);
+ struct value *index_val = value_from_longest (builtin_type_int32, index);
elt = unwrap_value (ada_value_subscript (lhs, 1, &index_val));
}
else
@@ -9546,7 +9546,7 @@ to_fixed_range_type (char *name, struct
char *subtype_info;
if (raw_type == NULL)
- base_type = builtin_type_int;
+ base_type = builtin_type_int32;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
Index: gdb-head/gdb/ada-typeprint.c
===================================================================
--- gdb-head.orig/gdb/ada-typeprint.c
+++ gdb-head/gdb/ada-typeprint.c
@@ -149,7 +149,7 @@ print_range (struct type *type, struct u
case TYPE_CODE_ENUM:
break;
default:
- target_type = builtin_type_int;
+ target_type = builtin_type_int32;
break;
}
@@ -197,11 +197,11 @@ print_range_bound (struct type *type, ch
the upper bound of the 0 .. -1 range types to be printed as
a very large unsigned number instead of -1.
To workaround this stabs deficiency, we replace the TYPE by
- builtin_type_long when we detect that the bound is negative,
+ builtin_type_int32 when we detect that the bound is negative,
and the type is a TYPE_CODE_INT. The bound is negative when
'm' is the last character of the number scanned in BOUNDS. */
if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT)
- type = builtin_type_long;
+ type = builtin_type_int32;
ada_print_scalar (type, B, stream);
if (bounds[*n] == '_')
*n += 2;
@@ -258,7 +258,7 @@ print_range_type_named (char *name, stru
char *subtype_info;
if (raw_type == NULL)
- base_type = builtin_type_int;
+ base_type = builtin_type_int32;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -122,7 +122,7 @@ print_optional_low_bound (struct ui_file
return 0;
break;
case TYPE_CODE_UNDEF:
- index_type = builtin_type_long;
+ index_type = builtin_type_int32;
/* FALL THROUGH */
default:
if (low_bound == 1)
@@ -753,7 +753,7 @@ ada_val_print_1 (struct type *type, cons
make_pointer_type
(create_array_type
(NULL, builtin_type_true_char,
- create_range_type (NULL, builtin_type_int, 0, 32)), NULL);
+ create_range_type (NULL, builtin_type_int32, 0, 32)), NULL);
printable_val =
value_ind (value_cast (parray_of_char,
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -2028,7 +2028,7 @@ evaluate_subexp_standard (struct type *e
/* Construct a value node with the value of the offset */
- arg2 = value_from_longest (builtin_type_f_integer, offset_item);
+ arg2 = value_from_longest (builtin_type_int32, offset_item);
/* Let us now play a dirty trick: we will take arg1
which is a value node pointing to the topmost level
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -132,7 +132,7 @@ build_gdb_vtable_type (struct gdbarch *a
FIELD_NAME (*field) = "vcall_and_vbase_offsets";
FIELD_TYPE (*field)
= create_array_type (0, ptrdiff_type,
- create_range_type (0, builtin_type_int, 0, -1));
+ create_range_type (0, builtin_type_int32, 0, -1));
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
@@ -155,7 +155,7 @@ build_gdb_vtable_type (struct gdbarch *a
FIELD_NAME (*field) = "virtual_functions";
FIELD_TYPE (*field)
= create_array_type (0, ptr_to_void_fn_type,
- create_range_type (0, builtin_type_int, 0, -1));
+ create_range_type (0, builtin_type_int32, 0, -1));
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
@@ -326,7 +326,7 @@ gnuv3_get_virtual_fn (struct value *cont
/* Fetch the appropriate function pointer from the vtable. */
vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions),
- value_from_longest (builtin_type_int, vtable_index));
+ value_from_longest (builtin_type_int32, vtable_index));
/* If this architecture uses function descriptors directly in the vtable,
then the address of the vtable entry is actually a "function pointer"
@@ -429,7 +429,7 @@ gnuv3_baseclass_offset (struct type *typ
address));
vtable = value_at_lazy (vtable_type,
vtable_address - vtable_address_point_offset ());
- offset_val = value_from_longest(builtin_type_int, cur_base_offset);
+ offset_val = value_from_longest(builtin_type_int32, cur_base_offset);
vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
base_offset = value_as_long (value_subscript (vbase_array, offset_val));
return base_offset;
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -775,7 +775,7 @@ java_array_type (struct type *type, int
while (dims-- > 0)
{
- range_type = create_range_type (NULL, builtin_type_int, 0, 0);
+ range_type = create_range_type (NULL, builtin_type_int32, 0, 0);
/* FIXME This is bogus! Java arrays are not gdb arrays! */
type = create_array_type (NULL, type, range_type);
}
Index: gdb-head/gdb/m2-typeprint.c
===================================================================
--- gdb-head.orig/gdb/m2-typeprint.c
+++ gdb-head/gdb/m2-typeprint.c
@@ -287,7 +287,7 @@ m2_print_bounds (struct type *type,
struct type *target = TYPE_TARGET_TYPE (type);
if (target == NULL)
- target = builtin_type_int;
+ target = builtin_type_int32;
if (TYPE_NFIELDS(type) == 0)
return;
@@ -394,7 +394,7 @@ m2_is_long_set_of_type (struct type *typ
range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i));
target = TYPE_TARGET_TYPE (range);
if (target == NULL)
- target = builtin_type_int;
+ target = builtin_type_int32;
l1 = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i)));
h1 = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, len-1)));
Index: gdb-head/gdb/m2-valprint.c
===================================================================
--- gdb-head.orig/gdb/m2-valprint.c
+++ gdb-head/gdb/m2-valprint.c
@@ -119,7 +119,7 @@ m2_print_long_set (struct type *type, co
target = TYPE_TARGET_TYPE (range);
if (target == NULL)
- target = builtin_type_int;
+ target = builtin_type_int32;
if (get_discrete_bounds (range, &field_low, &field_high) >= 0)
{
@@ -165,7 +165,7 @@ m2_print_long_set (struct type *type, co
break;
target = TYPE_TARGET_TYPE (range);
if (target == NULL)
- target = builtin_type_int;
+ target = builtin_type_int32;
}
}
if (element_seen)
Index: gdb-head/gdb/mt-tdep.c
===================================================================
--- gdb-head.orig/gdb/mt-tdep.c
+++ gdb-head/gdb/mt-tdep.c
@@ -258,7 +258,7 @@ mt_register_type (struct gdbarch *arch,
if (copro_type == NULL)
{
struct type *temp;
- temp = create_range_type (NULL, builtin_type_unsigned_int, 0, 1);
+ temp = create_range_type (NULL, builtin_type_int32, 0, 1);
copro_type = create_array_type (NULL, builtin_type_int16, temp);
}
switch (regnum)
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -1262,7 +1262,7 @@ follow_types (struct type *follow_type)
done with it. */
range_type =
create_range_type ((struct type *) NULL,
- builtin_type_int, 0,
+ builtin_type_int32, 0,
array_size >= 0 ? array_size - 1 : 0);
follow_type =
create_array_type ((struct type *) NULL,
Index: gdb-head/gdb/p-typeprint.c
===================================================================
--- gdb-head.orig/gdb/p-typeprint.c
+++ gdb-head/gdb/p-typeprint.c
@@ -756,7 +756,7 @@ pascal_type_print_base (struct type *typ
{
struct type *target = TYPE_TARGET_TYPE (type);
if (target == NULL)
- target = builtin_type_long;
+ target = builtin_type_int32;
print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
fputs_filtered ("..", stream);
print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
Index: gdb-head/gdb/sh64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh64-tdep.c
+++ gdb-head/gdb/sh64-tdep.c
@@ -1507,7 +1507,7 @@ sh64_build_float_register_type (int high
{
struct type *temp;
- temp = create_range_type (NULL, builtin_type_int, 0, high);
+ temp = create_range_type (NULL, builtin_type_int32, 0, high);
return create_array_type (NULL, builtin_type_float, temp);
}
Index: gdb-head/gdb/sh-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh-tdep.c
+++ gdb-head/gdb/sh-tdep.c
@@ -2156,7 +2156,7 @@ sh_sh4_build_float_register_type (int hi
{
struct type *temp;
- temp = create_range_type (NULL, builtin_type_int, 0, high);
+ temp = create_range_type (NULL, builtin_type_int32, 0, high);
return create_array_type (NULL, builtin_type_float, temp);
}
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -522,11 +522,11 @@ value_one (struct type *type, enum lval_
if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
{
- struct value *int_one = value_from_longest (builtin_type_int, 1);
+ struct value *int_one = value_from_longest (builtin_type_int32, 1);
struct value *val;
gdb_byte v[16];
- decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int));
+ decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int32));
val = value_from_decfloat (type, v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
@@ -1241,7 +1241,7 @@ value_array (int lowbound, int highbound
}
rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int,
+ builtin_type_int32,
lowbound, highbound);
arraytype = create_array_type ((struct type *) NULL,
value_enclosing_type (elemvec[0]),
@@ -1285,7 +1285,7 @@ value_string (char *ptr, int len)
struct value *val;
int lowbound = current_language->string_lower_bound;
struct type *rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int,
+ builtin_type_int32,
lowbound,
len + lowbound - 1);
struct type *stringtype
@@ -1315,7 +1315,7 @@ value_bitstring (char *ptr, int len)
{
struct value *val;
struct type *domain_type = create_range_type (NULL,
- builtin_type_int,
+ builtin_type_int32,
0, len - 1);
struct type *type = create_set_type ((struct type *) NULL,
domain_type);
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -249,7 +249,7 @@ allocate_repeat_value (struct type *type
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
struct type *range_type
- = create_range_type ((struct type *) NULL, builtin_type_int,
+ = create_range_type ((struct type *) NULL, builtin_type_int32,
low_bound, count + low_bound - 1);
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
@@ -1638,7 +1638,7 @@ value_from_string (char *ptr)
struct type *stringtype;
rangetype = create_range_type ((struct type *) NULL,
- builtin_type_int,
+ builtin_type_int32,
lowbound, len + lowbound - 1);
string_char_type = language_string_char_type (current_language,
current_gdbarch);
Index: gdb-head/gdb/varobj.c
===================================================================
--- gdb-head.orig/gdb/varobj.c
+++ gdb-head/gdb/varobj.c
@@ -2072,7 +2072,7 @@ c_describe_child (struct varobj *parent,
{
int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
struct value *indval =
- value_from_longest (builtin_type_int, (LONGEST) real_index);
+ value_from_longest (builtin_type_int32, (LONGEST) real_index);
gdb_value_subscript (value, indval, cvalue);
}
Index: gdb-head/gdb/gnu-v2-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v2-abi.c
+++ gdb-head/gdb/gnu-v2-abi.c
@@ -97,7 +97,7 @@ gnuv2_virtual_fn_field (struct value **a
struct value *entry;
struct value *vfn;
struct value *vtbl;
- struct value *vi = value_from_longest (builtin_type_int,
+ struct value *vi = value_from_longest (builtin_type_int32,
(LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j);
struct type *context;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (14 preceding siblings ...)
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-05 18:08 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
` (23 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-langbool --]
[-- Type: text/plain, Size: 18222 bytes --]
Hello,
this replaces the LA_BOOL_TYPE macro (which calls lang_bool_type, which
uses current_gdbarch and current_language to determine what type to use
for "boolean" values) by a new language_bool_type function with explicit
language/gdbarch parameters. This new function is implemented by two new
members of the struct language_arch_info. All XXX_language_arch_info
functions are updated to set those values; the overall effect should be
no user-visible changes.
Bye,
Ulrich
ChangeLog:
* language.h (struct language_arch_info): New members
bool_type_default and bool_type_symbol.
(lang_bool_type): Remove prototype.
(LA_BOOL_TYPE): Remove macro.
(language_bool_type): Add prototype.
* language.c (lang_bool_type): Remove.
(language_bool_type): New function.
* value.h (value_in): Change return value to int.
* value.c (value_in): Return int instead of struct value *.
* eval.c (evaluate_subexp_standard): Call language_bool_type instead
of using LA_BOOL_TYPE. Update call to value_in.
* ada-lang.c (ada_evaluate_subexp): Call language_bool_type instead
of using LA_BOOL_TYPE or builtin_type_int for boolean values.
* language.c (unknown_language_arch_info): Set bool_type_default member
of struct language_arch_info.
* ada-lang.c (ada_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* c-lang.c (c_language_arch_info): Set bool_type_default member
of struct language_arch_info.
(cplus_language_arch_info): Set bool_type_symbol and bool_type_default
members of struct language_arch_info.
* f-lang.c (f_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* jv-lang.c (java_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* m2-lang.c (m2_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* p-lang.c (p_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -8579,7 +8579,8 @@ ada_evaluate_subexp (struct type *expect
tem = ada_value_equal (arg1, arg2);
if (op == BINOP_NOTEQUAL)
tem = !tem;
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
case UNOP_NEG:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -8598,7 +8599,8 @@ ada_evaluate_subexp (struct type *expect
*pos -= 1;
val = evaluate_subexp_standard (expect_type, exp, pos, noside);
- return value_cast (LA_BOOL_TYPE, val);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_cast (type, val);
}
case BINOP_BITWISE_AND:
@@ -8850,14 +8852,16 @@ ada_evaluate_subexp (struct type *expect
default:
lim_warning (_("Membership test incompletely implemented; "
"always returns true"));
- return value_from_longest (builtin_type_int, (LONGEST) 1);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
arg3 = value_from_longest (builtin_type_int,
TYPE_HIGH_BOUND (type));
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
return
- value_from_longest (builtin_type_int,
+ value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@@ -8873,7 +8877,10 @@ ada_evaluate_subexp (struct type *expect
goto nosideret;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_int, not_lval);
+ {
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_zero (type, not_lval);
+ }
tem = longest_to_int (exp->elts[pc + 1].longconst);
@@ -8883,8 +8890,9 @@ ada_evaluate_subexp (struct type *expect
arg3 = ada_array_bound (arg2, tem, 1);
arg2 = ada_array_bound (arg2, tem, 0);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
return
- value_from_longest (builtin_type_int,
+ value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@@ -8898,8 +8906,9 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
return
- value_from_longest (builtin_type_int,
+ value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@@ -10911,6 +10920,9 @@ ada_language_arch_info (struct gdbarch *
(struct objfile *) NULL));
TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
= "system__address";
+
+ lai->bool_type_symbol = "boolean";
+ lai->bool_type_default = builtin->builtin_bool;
}
\f
/* Language vector */
Index: gdb-head/gdb/c-lang.c
===================================================================
--- gdb-head.orig/gdb/c-lang.c
+++ gdb-head/gdb/c-lang.c
@@ -380,6 +380,8 @@ c_language_arch_info (struct gdbarch *gd
lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
+
+ lai->bool_type_default = builtin->builtin_int;
}
const struct language_defn c_language_defn =
@@ -493,6 +495,9 @@ cplus_language_arch_info (struct gdbarch
= builtin->builtin_decdouble;
lai->primitive_type_vector [cplus_primitive_type_declong]
= builtin->builtin_declong;
+
+ lai->bool_type_symbol = "bool";
+ lai->bool_type_default = builtin->builtin_bool;
}
const struct language_defn cplus_language_defn =
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -562,8 +562,8 @@ evaluate_subexp_standard (struct type *e
}
case OP_BOOL:
(*pos) += 2;
- return value_from_longest (LA_BOOL_TYPE,
- exp->elts[pc + 1].longconst);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, exp->elts[pc + 1].longconst);
case OP_INTERNALVAR:
(*pos) += 2;
@@ -1618,7 +1618,8 @@ evaluate_subexp_standard (struct type *e
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- return value_in (arg1, arg2);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) value_in (arg1, arg2));
case MULTI_SUBSCRIPT:
(*pos) += 2;
@@ -1678,7 +1679,8 @@ evaluate_subexp_standard (struct type *e
break;
case TYPE_CODE_BITSTRING:
- arg1 = value_bitstring_subscript (LA_BOOL_TYPE, arg1, arg2);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ arg1 = value_bitstring_subscript (type, arg1, arg2);
break;
default:
@@ -1798,7 +1800,8 @@ evaluate_subexp_standard (struct type *e
tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(tem ? EVAL_SKIP : noside));
- return value_from_longest (LA_BOOL_TYPE,
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type,
(LONGEST) (!tem && !value_logical_not (arg2)));
}
@@ -1824,7 +1827,8 @@ evaluate_subexp_standard (struct type *e
tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(!tem ? EVAL_SKIP : noside));
- return value_from_longest (LA_BOOL_TYPE,
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type,
(LONGEST) (!tem || !value_logical_not (arg2)));
}
@@ -1840,7 +1844,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_equal (arg1, arg2);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
}
case BINOP_NOTEQUAL:
@@ -1855,7 +1860,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_equal (arg1, arg2);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) ! tem);
}
case BINOP_LESS:
@@ -1870,7 +1876,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_less (arg1, arg2);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
}
case BINOP_GTR:
@@ -1885,7 +1892,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_less (arg2, arg1);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
}
case BINOP_GEQ:
@@ -1900,7 +1908,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
}
case BINOP_LEQ:
@@ -1915,7 +1924,8 @@ evaluate_subexp_standard (struct type *e
else
{
tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
- return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) tem);
}
case BINOP_REPEAT:
@@ -1975,8 +1985,10 @@ evaluate_subexp_standard (struct type *e
if (unop_user_defined_p (op, arg1))
return value_x_unop (arg1, op, noside);
else
- return value_from_longest (LA_BOOL_TYPE,
- (LONGEST) value_logical_not (arg1));
+ {
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, (LONGEST) value_logical_not (arg1));
+ }
case UNOP_IND:
if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
Index: gdb-head/gdb/f-lang.c
===================================================================
--- gdb-head.orig/gdb/f-lang.c
+++ gdb-head/gdb/f-lang.c
@@ -298,6 +298,9 @@ f_language_arch_info (struct gdbarch *gd
= builtin->builtin_complex_s16;
lai->primitive_type_vector [f_primitive_type_void]
= builtin->builtin_void;
+
+ lai->bool_type_symbol = "logical";
+ lai->bool_type_default = builtin->builtin_logical_s2;
}
/* This is declared in c-lang.h but it is silly to import that file for what
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -1080,6 +1080,9 @@ java_language_arch_info (struct gdbarch
= java_double_type;
lai->primitive_type_vector [java_primitive_type_void]
= java_void_type;
+
+ lai->bool_type_symbol = "boolean";
+ lai->bool_type_default = java_boolean_type;
}
const struct exp_descriptor exp_descriptor_java =
Index: gdb-head/gdb/language.c
===================================================================
--- gdb-head.orig/gdb/language.c
+++ gdb-head/gdb/language.c
@@ -787,51 +787,6 @@ structured_type (struct type *type)
}
#endif
\f
-struct type *
-lang_bool_type (void)
-{
- struct symbol *sym;
- struct type *type;
- switch (current_language->la_language)
- {
- case language_fortran:
- sym = lookup_symbol ("logical", NULL, VAR_DOMAIN, NULL);
- if (sym)
- {
- type = SYMBOL_TYPE (sym);
- if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
- return type;
- }
- return builtin_type_f_logical_s2;
- case language_cplus:
- case language_pascal:
- case language_ada:
- if (current_language->la_language==language_cplus)
- {sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL);}
- else
- {sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);}
- if (sym)
- {
- type = SYMBOL_TYPE (sym);
- if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
- return type;
- }
- return builtin_type_bool;
- case language_java:
- sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);
- if (sym)
- {
- type = SYMBOL_TYPE (sym);
- if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
- return type;
- }
- return java_boolean_type;
-
- default:
- return builtin_type_int;
- }
-}
-\f
/* This page contains functions that return info about
(struct value) values used in GDB. */
@@ -1169,6 +1124,7 @@ unknown_language_arch_info (struct gdbar
struct language_arch_info *lai)
{
lai->string_char_type = builtin_type (gdbarch)->builtin_char;
+ lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
struct type *);
}
@@ -1317,6 +1273,29 @@ language_string_char_type (const struct
}
struct type *
+language_bool_type (const struct language_defn *la,
+ struct gdbarch *gdbarch)
+{
+ struct language_gdbarch *ld = gdbarch_data (gdbarch,
+ language_gdbarch_data);
+
+ if (ld->arch_info[la->la_language].bool_type_symbol)
+ {
+ struct symbol *sym;
+ sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
+ NULL, VAR_DOMAIN, NULL);
+ if (sym)
+ {
+ struct type *type = SYMBOL_TYPE (sym);
+ if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
+ return type;
+ }
+ }
+
+ return ld->arch_info[la->la_language].bool_type_default;
+}
+
+struct type *
language_lookup_primitive_type_by_name (const struct language_defn *la,
struct gdbarch *gdbarch,
const char *name)
Index: gdb-head/gdb/language.h
===================================================================
--- gdb-head.orig/gdb/language.h
+++ gdb-head/gdb/language.h
@@ -125,6 +125,11 @@ struct language_arch_info
struct type **primitive_type_vector;
/* Type of elements of strings. */
struct type *string_char_type;
+
+ /* Symbol name of type to use as boolean type, if defined. */
+ const char *bool_type_symbol;
+ /* Otherwise, this is the default boolean builtin type. */
+ struct type *bool_type_default;
};
/* Structure tying together assorted information about a language. */
@@ -306,6 +311,9 @@ extern enum language_mode
}
language_mode;
+struct type *language_bool_type (const struct language_defn *l,
+ struct gdbarch *gdbarch);
+
struct type *language_string_char_type (const struct language_defn *l,
struct gdbarch *gdbarch);
@@ -416,11 +424,6 @@ extern void range_error (const char *, .
extern int value_true (struct value *);
-extern struct type *lang_bool_type (void);
-
-/* The type used for Boolean values in the current language. */
-#define LA_BOOL_TYPE lang_bool_type ()
-
/* Misc: The string representing a particular enum language. */
extern enum language language_enum (char *str);
Index: gdb-head/gdb/m2-lang.c
===================================================================
--- gdb-head.orig/gdb/m2-lang.c
+++ gdb-head/gdb/m2-lang.c
@@ -345,6 +345,9 @@ m2_language_arch_info (struct gdbarch *g
= builtin->builtin_real;
lai->primitive_type_vector [m2_primitive_type_bool]
= builtin->builtin_bool;
+
+ lai->bool_type_symbol = "BOOLEAN";
+ lai->bool_type_default = builtin->builtin_bool;
}
const struct exp_descriptor exp_descriptor_modula2 =
Index: gdb-head/gdb/p-lang.c
===================================================================
--- gdb-head.orig/gdb/p-lang.c
+++ gdb-head/gdb/p-lang.c
@@ -393,6 +393,9 @@ pascal_language_arch_info (struct gdbarc
= builtin->builtin_complex;
lai->primitive_type_vector [pascal_primitive_type_double_complex]
= builtin->builtin_double_complex;
+
+ lai->bool_type_symbol = "boolean";
+ lai->bool_type_default = builtin->builtin_bool;
}
const struct language_defn pascal_language_defn =
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -1846,7 +1846,7 @@ value_bit_index (struct type *type, cons
return (word >> rel_index) & 1;
}
-struct value *
+int
value_in (struct value *element, struct value *set)
{
int member;
@@ -1865,7 +1865,7 @@ value_in (struct value *element, struct
value_as_long (element));
if (member < 0)
error (_("First argument of 'IN' not in range"));
- return value_from_longest (LA_BOOL_TYPE, member);
+ return member;
}
void
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -412,7 +412,7 @@ extern struct value *value_bitstring_sub
extern struct value *register_value_being_returned (struct type *valtype,
struct regcache *retbuf);
-extern struct value *value_in (struct value *element, struct value *set);
+extern int value_in (struct value *element, struct value *set);
extern int value_bit_index (struct type *type, const gdb_byte *addr,
int index);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][33/37] Eliminate builtin_type_ macros: Default target word size
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (4 preceding siblings ...)
2008-08-31 17:52 ` [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator uweigand
` (33 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-wordsize --]
[-- Type: text/plain, Size: 1463 bytes --]
Hello,
default_auxv_parse and default_region_ok_for_hw_watchpoint used
TYPE_LENGTH (builtin_type_void_data_ptr) to determine the default
target word size.
This patch changes them to use target_gdbarch instead.
Bye,
Ulrich
ChangeLog:
* auxv.c (default_auxv_parse): Use gdbarch_ptr_bit (target_gdbarch)
instead of builtin_type_void_data_ptr.
* target.c (default_region_ok_for_hw_watchpoint): Likewise.
Index: gdb-head/gdb/auxv.c
===================================================================
--- gdb-head.orig/gdb/auxv.c
+++ gdb-head/gdb/auxv.c
@@ -82,7 +82,8 @@ int
default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
{
- const int sizeof_auxv_field = TYPE_LENGTH (builtin_type_void_data_ptr);
+ const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
+ / TARGET_CHAR_BIT;
gdb_byte *ptr = *readptr;
if (endptr == ptr)
Index: gdb-head/gdb/target.c
===================================================================
--- gdb-head.orig/gdb/target.c
+++ gdb-head/gdb/target.c
@@ -2152,7 +2152,7 @@ target_supports_non_stop ()
static int
default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{
- return (len <= TYPE_LENGTH (builtin_type_void_data_ptr));
+ return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT);
}
static int
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (7 preceding siblings ...)
2008-08-31 17:52 ` [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-05 22:56 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
` (30 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-evalskip --]
[-- Type: text/plain, Size: 2843 bytes --]
Hello,
when calling evaluate_subexp with the EVAL_SKIP option, a dummy
value is returned; this is currently constructed using the
builtin_type_long macro.
As the actual type doesn't really matter, this patch changes that
to use builtin_type_int8 instead.
Bye,
Ulrich
ChangeLog:
* eval.c (evaluate_subexp_standard): Use builtin_type_int8
to construct the EVAL_SKIP dummy return value.
* ada-lang.c (ada_evaluate_subexp): Likewise.
* jv-lang.c (evaluate_subexp_java): Likewise.
* m2-lang.c (evaluate_subexp_modula2): Likewise.
* scm-lang.c (evaluate_exp): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -9277,7 +9277,7 @@ ada_evaluate_subexp (struct type *expect
}
nosideret:
- return value_from_longest (builtin_type_long, (LONGEST) 1);
+ return value_from_longest (builtin_type_int8, (LONGEST) 1);
}
\f
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -2482,7 +2482,7 @@ GDB does not (yet) know how to evaluate
}
nosideret:
- return value_from_longest (builtin_type_long, (LONGEST) 1);
+ return value_from_longest (builtin_type_int8, (LONGEST) 1);
}
\f
/* Evaluate a subexpression of EXP, at index *POS,
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -938,7 +938,7 @@ evaluate_subexp_java (struct type *expec
standard:
return evaluate_subexp_standard (expect_type, exp, pos, noside);
nosideret:
- return value_from_longest (builtin_type_long, (LONGEST) 1);
+ return value_from_longest (builtin_type_int8, (LONGEST) 1);
}
static char *java_demangle (const char *mangled, int options)
Index: gdb-head/gdb/m2-lang.c
===================================================================
--- gdb-head.orig/gdb/m2-lang.c
+++ gdb-head/gdb/m2-lang.c
@@ -273,7 +273,7 @@ evaluate_subexp_modula2 (struct type *ex
}
nosideret:
- return value_from_longest (builtin_type_long, (LONGEST) 1);
+ return value_from_longest (builtin_type_int8, (LONGEST) 1);
}
\f
Index: gdb-head/gdb/scm-lang.c
===================================================================
--- gdb-head.orig/gdb/scm-lang.c
+++ gdb-head/gdb/scm-lang.c
@@ -220,7 +220,7 @@ evaluate_exp (struct type *expect_type,
}
return evaluate_subexp_standard (expect_type, exp, pos, noside);
nosideret:
- return value_from_longest (builtin_type_long, (LONGEST) 1);
+ return value_from_longest (builtin_type_int8, (LONGEST) 1);
}
const struct exp_descriptor exp_descriptor_scm =
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
2008-08-31 17:52 ` [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-05 23:13 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
` (36 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-adadouble --]
[-- Type: text/plain, Size: 2719 bytes --]
Hello,
ada-lang.c uses builtin_type_double as intermediate type in some
type conversions. This doesn't seem to be necessary, as the
value_as_double and value_from_double routines should be able
to handle the same types directly ...
Bye,
Ulrich
ChangeLog:
* ada-lang.c (cast_to_fixed): Do not cast to builtin_type_double.
(cast_from_fixed_to_double): Rename to ...
(cast_from_fixed): ... this. Add TYPE parameter. Use it instead
of builtin_type_double.
(ada_value_cast): Use cast_from_fixed instead of casting result
of cast_from_fixed_to_double.
(ada_evaluate_subexp): Update calls to cast_from_fixed_to_double.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -7944,8 +7944,7 @@ cast_to_fixed (struct type *type, struct
value_as_long (arg)));
else
{
- DOUBLEST argd =
- value_as_double (value_cast (builtin_type_double, value_copy (arg)));
+ DOUBLEST argd = value_as_double (arg);
val = ada_float_to_fixed (type, argd);
}
@@ -7953,11 +7952,11 @@ cast_to_fixed (struct type *type, struct
}
static struct value *
-cast_from_fixed_to_double (struct value *arg)
+cast_from_fixed (struct type *type, struct value *arg)
{
DOUBLEST val = ada_fixed_to_float (value_type (arg),
value_as_long (arg));
- return value_from_double (builtin_type_double, val);
+ return value_from_double (type, val);
}
/* Coerce VAL as necessary for assignment to an lval of type TYPE, and
@@ -8411,7 +8410,7 @@ ada_value_cast (struct type *type, struc
return (cast_to_fixed (type, arg2));
if (ada_is_fixed_point_type (value_type (arg2)))
- return value_cast (type, cast_from_fixed_to_double (arg2));
+ return cast_from_fixed (type, arg2);
return value_cast (type, arg2);
}
@@ -8553,10 +8552,11 @@ ada_evaluate_subexp (struct type *expect
return value_zero (value_type (arg1), not_lval);
else
{
+ type = builtin_type (exp->gdbarch)->builtin_double;
if (ada_is_fixed_point_type (value_type (arg1)))
- arg1 = cast_from_fixed_to_double (arg1);
+ arg1 = cast_from_fixed (type, arg1);
if (ada_is_fixed_point_type (value_type (arg2)))
- arg2 = cast_from_fixed_to_double (arg2);
+ arg2 = cast_from_fixed (type, arg2);
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
return ada_value_binop (arg1, arg2, op);
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (15 preceding siblings ...)
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
@ 2008-08-31 17:52 ` uweigand
2008-09-06 0:24 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture uweigand
` (22 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-adaarray --]
[-- Type: text/plain, Size: 2320 bytes --]
Hello,
two more small changes to ada-lang.c: ada_array_length would simply use
builtin_type_int as type of its return value, even though it should probably
better use the type of the array bounds.
Similarly, ada_evaluate_subexp at one place uses a builtin_type_int to hold
bounds of a range type, instead of using the underlying scalar type.
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_array_length): Use type of array bounds instead
of builtin_type_int.
(ada_evaluate_subexp): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -2633,12 +2633,13 @@ ada_array_length (struct value *arr, int
return value_from_longest (type, v);
}
else
- return
- value_from_longest (builtin_type_int,
- value_as_long (desc_one_bound (desc_bounds (arr),
- n, 1))
- - value_as_long (desc_one_bound (desc_bounds (arr),
- n, 0)) + 1);
+ {
+ struct value *high = desc_one_bound (desc_bounds (arr), n, 1);
+ struct value *low = desc_one_bound (desc_bounds (arr), n, 0);
+ return value_from_longest (value_type (high),
+ value_as_long (high)
+ - value_as_long (low) + 1);
+ }
}
/* An empty array whose type is that of ARR_TYPE (an array type),
@@ -8871,9 +8872,10 @@ ada_evaluate_subexp (struct type *expect
return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
- arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
- arg3 = value_from_longest (builtin_type_int,
- TYPE_HIGH_BOUND (type));
+ arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
+ TYPE_LOW_BOUND (type));
+ arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
+ TYPE_HIGH_BOUND (type));
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
` (37 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-malloc --]
[-- Type: text/plain, Size: 6531 bytes --]
Hello,
value_allocate_space_in_inferior needs current_gdbarch in order to find
the name of the "malloc" function. However, no gdbarch actually even
implement any non-default gdbarch_name_of_malloc routine, so this patch
simply removes that infrastructure.
Bye,
Ulrich
ChangeLog:
* gdbarch.sh (name_of_malloc): Remove.
* gdbarch.c, gdbarch.h: Re-generate.
* valops.c (value_allocate_space_in_inferior): Do not call
gdbarch_name_of_malloc.
doc/ChangeLog:
* gdbint.texinfo (Target Conditionals): Remove documentation
for gdbarch_name_of_malloc.
Index: gdb-head/gdb/doc/gdbint.texinfo
===================================================================
--- gdb-head.orig/gdb/doc/gdbint.texinfo
+++ gdb-head/gdb/doc/gdbint.texinfo
@@ -4114,11 +4114,6 @@ not defined, it will default to @code{0x
@item REMOTE_BPT_VECTOR
Defaults to @code{1}.
-@item const char *gdbarch_name_of_malloc (@var{gdbarch})
-@findex gdbarch_name_of_malloc
-A string containing the name of the function to call in order to
-allocate some memory in the inferior. The default value is "malloc".
-
@end ftable
@node Adding a New Target
Index: gdb-head/gdb/gdbarch.c
===================================================================
--- gdb-head.orig/gdb/gdbarch.c
+++ gdb-head/gdb/gdbarch.c
@@ -215,7 +215,6 @@ struct gdbarch
gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments;
gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special;
gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special;
- const char * name_of_malloc;
int cannot_step_breakpoint;
int have_nonsteppable_watchpoint;
gdbarch_address_class_type_flags_ftype *address_class_type_flags;
@@ -347,7 +346,6 @@ struct gdbarch startup_gdbarch =
construct_inferior_arguments, /* construct_inferior_arguments */
0, /* elf_make_msymbol_special */
0, /* coff_make_msymbol_special */
- "malloc", /* name_of_malloc */
0, /* cannot_step_breakpoint */
0, /* have_nonsteppable_watchpoint */
0, /* address_class_type_flags */
@@ -451,7 +449,6 @@ gdbarch_alloc (const struct gdbarch_info
gdbarch->construct_inferior_arguments = construct_inferior_arguments;
gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
- gdbarch->name_of_malloc = "malloc";
gdbarch->register_reggroup_p = default_register_reggroup_p;
gdbarch->displaced_step_fixup = NULL;
gdbarch->displaced_step_free_closure = NULL;
@@ -600,7 +597,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of construct_inferior_arguments, invalid_p == 0 */
/* Skip verify of elf_make_msymbol_special, invalid_p == 0 */
/* Skip verify of coff_make_msymbol_special, invalid_p == 0 */
- /* Skip verify of name_of_malloc, invalid_p == 0 */
/* Skip verify of cannot_step_breakpoint, invalid_p == 0 */
/* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0 */
/* Skip verify of address_class_type_flags, has predicate */
@@ -881,9 +877,6 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
(long) gdbarch->memory_remove_breakpoint);
fprintf_unfiltered (file,
- "gdbarch_dump: name_of_malloc = %s\n",
- gdbarch->name_of_malloc);
- fprintf_unfiltered (file,
"gdbarch_dump: num_pseudo_regs = %s\n",
paddr_d (gdbarch->num_pseudo_regs));
fprintf_unfiltered (file,
@@ -2720,23 +2713,6 @@ set_gdbarch_coff_make_msymbol_special (s
gdbarch->coff_make_msymbol_special = coff_make_msymbol_special;
}
-const char *
-gdbarch_name_of_malloc (struct gdbarch *gdbarch)
-{
- gdb_assert (gdbarch != NULL);
- /* Skip verify of name_of_malloc, invalid_p == 0 */
- if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_name_of_malloc called\n");
- return gdbarch->name_of_malloc;
-}
-
-void
-set_gdbarch_name_of_malloc (struct gdbarch *gdbarch,
- const char * name_of_malloc)
-{
- gdbarch->name_of_malloc = name_of_malloc;
-}
-
int
gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch)
{
Index: gdb-head/gdb/gdbarch.h
===================================================================
--- gdb-head.orig/gdb/gdbarch.h
+++ gdb-head/gdb/gdbarch.h
@@ -591,9 +591,6 @@ typedef void (gdbarch_coff_make_msymbol_
extern void gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym);
extern void set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special);
-extern const char * gdbarch_name_of_malloc (struct gdbarch *gdbarch);
-extern void set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, const char * name_of_malloc);
-
extern int gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch);
extern void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, int cannot_step_breakpoint);
Index: gdb-head/gdb/gdbarch.sh
===================================================================
--- gdb-head.orig/gdb/gdbarch.sh
+++ gdb-head/gdb/gdbarch.sh
@@ -586,7 +586,6 @@ m:int:in_function_epilogue_p:CORE_ADDR a
m:char *:construct_inferior_arguments:int argc, char **argv:argc, argv::construct_inferior_arguments::0
f:void:elf_make_msymbol_special:asymbol *sym, struct minimal_symbol *msym:sym, msym::default_elf_make_msymbol_special::0
f:void:coff_make_msymbol_special:int val, struct minimal_symbol *msym:val, msym::default_coff_make_msymbol_special::0
-v:const char *:name_of_malloc:::"malloc":"malloc"::0:gdbarch->name_of_malloc
v:int:cannot_step_breakpoint:::0:0::0
v:int:have_nonsteppable_watchpoint:::0:0::0
F:int:address_class_type_flags:int byte_size, int dwarf2_addr_class:byte_size, dwarf2_addr_class
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -170,8 +170,7 @@ struct value *
value_allocate_space_in_inferior (int len)
{
struct value *blocklen;
- struct value *val =
- find_function_in_inferior (gdbarch_name_of_malloc (current_gdbarch));
+ struct value *val = find_function_in_inferior ("malloc");
blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
val = call_function_by_hand (val, 1, &blocklen);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (11 preceding siblings ...)
2008-08-31 17:52 ` [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines uweigand
@ 2008-08-31 17:52 ` uweigand
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
` (26 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-promote1 --]
[-- Type: text/plain, Size: 25270 bytes --]
Hello,
this is the first of two patches to disentangle use of current_gdbarch,
builtin_type_ macros, and current_language from value_binop and the
unary operations in valarith.c.
These are used to implement argument promotion before performing the
requested unary or binary operation. However, this promotion really
ought to be done earlier as part of expression evaluation (or even as
part of expression parsing).
This patch removes the parts of unop_result_type and binop_result_type
that handle argument promotion, and moves them into two new functions
unop_promote and binop_promote. These functions actually perform the
argument promotion; this patch adds a call to them at the start of
value_binop and the unary operations (value_pos, value_neg, and
value_complement).
When those calls are pushed up into the respective callers, the unary
operations will always retain the type of their argument, while the
binary operations will choose one of the two input types, depending
on simple preference rules (decimal float over binary float over integer;
the longer type over the shorter; unsigned type over signed type).
Bye,
Ulrich
ChangeLog:
* value.h (unop_promote, binop_promote): Add prototypes.
* eval.c (unop_promote, binop_promote): New functions.
* valarith.c (unop_result_type, binop_result_type): Remove.
(value_binop): Call binop_promote or unop_promote.
Inline remaining parts of binop_result_type. Remove special
code to truncate integer values for unsigned operations.
(value_pos): Call unop_promote. Inline remaining parts of
unop_result_type.
(value_neg, value_complement): Likewise.
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -439,6 +439,199 @@ value_f90_subarray (struct value *array,
return value_slice (array, low_bound, high_bound - low_bound + 1);
}
+
+/* Promote value ARG1 as appropriate before performing a unary operation
+ on this argument.
+ If the result is not appropriate for any particular language then it
+ needs to patch this function. */
+
+void
+unop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
+ struct value **arg1)
+{
+ struct type *type1;
+
+ *arg1 = coerce_ref (*arg1);
+ type1 = check_typedef (value_type (*arg1));
+
+ if (is_integral_type (type1))
+ {
+ switch (language->la_language)
+ {
+ default:
+ /* Perform integral promotion for ANSI C/C++.
+ If not appropropriate for any particular language
+ it needs to modify this function. */
+ {
+ struct type *builtin_int = builtin_type (gdbarch)->builtin_int;
+ if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_int))
+ *arg1 = value_cast (builtin_int, *arg1);
+ }
+ break;
+ }
+ }
+}
+
+/* Promote values ARG1 and ARG2 as appropriate before performing a binary
+ operation on those two operands.
+ If the result is not appropriate for any particular language then it
+ needs to patch this function. */
+
+void
+binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
+ struct value **arg1, struct value **arg2)
+{
+ struct type *promoted_type = NULL;
+ struct type *type1;
+ struct type *type2;
+
+ *arg1 = coerce_ref (*arg1);
+ *arg2 = coerce_ref (*arg2);
+
+ type1 = check_typedef (value_type (*arg1));
+ type2 = check_typedef (value_type (*arg2));
+
+ if ((TYPE_CODE (type1) != TYPE_CODE_FLT
+ && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
+ && !is_integral_type (type1))
+ || (TYPE_CODE (type2) != TYPE_CODE_FLT
+ && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
+ && !is_integral_type (type2)))
+ return;
+
+ if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
+ || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
+ {
+ /* No promotion required. */
+ }
+ else if (TYPE_CODE (type1) == TYPE_CODE_FLT
+ || TYPE_CODE (type2) == TYPE_CODE_FLT)
+ {
+ switch (language->la_language)
+ {
+ case language_c:
+ case language_cplus:
+ case language_asm:
+ case language_objc:
+ /* No promotion required. */
+ break;
+
+ default:
+ /* For other languages the result type is unchanged from gdb
+ version 6.7 for backward compatibility.
+ If either arg was long double, make sure that value is also long
+ double. Otherwise use double. */
+ if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (gdbarch)
+ || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (gdbarch))
+ promoted_type = builtin_type (gdbarch)->builtin_long_double;
+ else
+ promoted_type = builtin_type (gdbarch)->builtin_double;
+ break;
+ }
+ }
+ else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
+ && TYPE_CODE (type2) == TYPE_CODE_BOOL)
+ {
+ /* No promotion required. */
+ }
+ else
+ /* Integral operations here. */
+ /* FIXME: Also mixed integral/booleans, with result an integer. */
+ {
+ const struct builtin_type *builtin = builtin_type (gdbarch);
+ unsigned int promoted_len1 = TYPE_LENGTH (type1);
+ unsigned int promoted_len2 = TYPE_LENGTH (type2);
+ int is_unsigned1 = TYPE_UNSIGNED (type1);
+ int is_unsigned2 = TYPE_UNSIGNED (type2);
+ unsigned int result_len;
+ int unsigned_operation;
+
+ /* Determine type length and signedness after promotion for
+ both operands. */
+ if (promoted_len1 < TYPE_LENGTH (builtin->builtin_int))
+ {
+ is_unsigned1 = 0;
+ promoted_len1 = TYPE_LENGTH (builtin->builtin_int);
+ }
+ if (promoted_len2 < TYPE_LENGTH (builtin->builtin_int))
+ {
+ is_unsigned2 = 0;
+ promoted_len2 = TYPE_LENGTH (builtin->builtin_int);
+ }
+
+ if (promoted_len1 > promoted_len2)
+ {
+ unsigned_operation = is_unsigned1;
+ result_len = promoted_len1;
+ }
+ else if (promoted_len2 > promoted_len1)
+ {
+ unsigned_operation = is_unsigned2;
+ result_len = promoted_len2;
+ }
+ else
+ {
+ unsigned_operation = is_unsigned1 || is_unsigned2;
+ result_len = promoted_len1;
+ }
+
+ switch (language->la_language)
+ {
+ case language_c:
+ case language_cplus:
+ case language_asm:
+ case language_objc:
+ if (result_len <= TYPE_LENGTH (builtin->builtin_int))
+ {
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_int
+ : builtin->builtin_int);
+ }
+ else if (result_len <= TYPE_LENGTH (builtin->builtin_long))
+ {
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_long
+ : builtin->builtin_long);
+ }
+ else
+ {
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_long_long
+ : builtin->builtin_long_long);
+ }
+ break;
+
+ default:
+ /* For other languages the result type is unchanged from gdb
+ version 6.7 for backward compatibility.
+ If either arg was long long, make sure that value is also long
+ long. Otherwise use long. */
+ if (unsigned_operation)
+ {
+ if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
+ promoted_type = builtin->builtin_unsigned_long_long;
+ else
+ promoted_type = builtin->builtin_unsigned_long;
+ }
+ else
+ {
+ if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
+ promoted_type = builtin->builtin_long_long;
+ else
+ promoted_type = builtin->builtin_long;
+ }
+ break;
+ }
+ }
+
+ if (promoted_type)
+ {
+ /* Promote both operands to common type. */
+ *arg1 = value_cast (promoted_type, *arg1);
+ *arg2 = value_cast (promoted_type, *arg2);
+ }
+}
+
static int
ptrmath_type_p (struct type *type)
{
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -39,10 +39,6 @@
#define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
#endif
-static struct type *unop_result_type (enum exp_opcode op, struct type *type1);
-static struct type *binop_result_type (enum exp_opcode op, struct type *type1,
- struct type *type2);
-
void _initialize_valarith (void);
\f
@@ -746,294 +742,6 @@ value_concat (struct value *arg1, struct
return (outval);
}
\f
-/* Return result type of OP performed on TYPE1.
- The result type follows ANSI C rules.
- If the result is not appropropriate for any particular language then it
- needs to patch this function to return the correct type. */
-
-static struct type *
-unop_result_type (enum exp_opcode op, struct type *type1)
-{
- struct type *result_type;
-
- type1 = check_typedef (type1);
- result_type = type1;
-
- switch (op)
- {
- case UNOP_PLUS:
- case UNOP_NEG:
- break;
- case UNOP_COMPLEMENT:
- /* Reject floats and decimal floats. */
- if (!is_integral_type (type1))
- error (_("Argument to complement operation not an integer or boolean."));
- break;
- default:
- error (_("Invalid unary operation on numbers."));
- }
-
- if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
- || TYPE_CODE (type1) == TYPE_CODE_FLT)
- {
- return result_type;
- }
- else if (is_integral_type (type1))
- {
- /* Perform integral promotion for ANSI C/C++.
- If not appropropriate for any particular language it needs to
- modify this function to return the correct result for it. */
- if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_type_int))
- result_type = builtin_type_int;
-
- return result_type;
- }
- else
- {
- error (_("Argument to unary operation not a number."));
- return 0; /* For lint -- never reached */
- }
-}
-
-/* Return result type of OP performed on TYPE1, TYPE2.
- If the result is not appropropriate for any particular language then it
- needs to patch this function to return the correct type. */
-
-static struct type *
-binop_result_type (enum exp_opcode op, struct type *type1, struct type *type2)
-{
- type1 = check_typedef (type1);
- type2 = check_typedef (type2);
-
- if ((TYPE_CODE (type1) != TYPE_CODE_FLT
- && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
- && !is_integral_type (type1))
- ||
- (TYPE_CODE (type2) != TYPE_CODE_FLT
- && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
- && !is_integral_type (type2)))
- error (_("Argument to arithmetic operation not a number or boolean."));
-
- if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
- || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
- {
- switch (op)
- {
- case BINOP_ADD:
- case BINOP_SUB:
- case BINOP_MUL:
- case BINOP_DIV:
- case BINOP_EXP:
- break;
- default:
- error (_("Operation not valid for decimal floating point number."));
- }
-
- if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
- /* If type1 is not a decimal float, the type of the result is the type
- of the decimal float argument, type2. */
- return type2;
- else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
- /* Same logic, for the case where type2 is not a decimal float. */
- return type1;
- else
- /* Both are decimal floats, the type of the result is the bigger
- of the two. */
- return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) ? type1 : type2;
- }
- else if (TYPE_CODE (type1) == TYPE_CODE_FLT
- || TYPE_CODE (type2) == TYPE_CODE_FLT)
- {
- switch (op)
- {
- case BINOP_ADD:
- case BINOP_SUB:
- case BINOP_MUL:
- case BINOP_DIV:
- case BINOP_EXP:
- case BINOP_MIN:
- case BINOP_MAX:
- break;
- default:
- error (_("Integer-only operation on floating point number."));
- }
-
- switch (current_language->la_language)
- {
- case language_c:
- case language_cplus:
- case language_asm:
- case language_objc:
- /* Perform ANSI/ISO-C promotions.
- If only one type is float, use its type.
- Otherwise use the bigger type. */
- if (TYPE_CODE (type1) != TYPE_CODE_FLT)
- return type2;
- else if (TYPE_CODE (type2) != TYPE_CODE_FLT)
- return type1;
- else
- return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) ? type1 : type2;
-
- default:
- /* For other languages the result type is unchanged from gdb
- version 6.7 for backward compatibility.
- If either arg was long double, make sure that value is also long
- double. Otherwise use double. */
- if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (current_gdbarch)
- || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (current_gdbarch))
- return builtin_type_long_double;
- else
- return builtin_type_double;
- }
- }
- else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
- && TYPE_CODE (type2) == TYPE_CODE_BOOL)
- {
- switch (op)
- {
- case BINOP_BITWISE_AND:
- case BINOP_BITWISE_IOR:
- case BINOP_BITWISE_XOR:
- case BINOP_EQUAL:
- case BINOP_NOTEQUAL:
- break;
- default:
- error (_("Invalid operation on booleans."));
- }
-
- return type1;
- }
- else
- /* Integral operations here. */
- /* FIXME: Also mixed integral/booleans, with result an integer. */
- {
- unsigned int promoted_len1 = TYPE_LENGTH (type1);
- unsigned int promoted_len2 = TYPE_LENGTH (type2);
- int is_unsigned1 = TYPE_UNSIGNED (type1);
- int is_unsigned2 = TYPE_UNSIGNED (type2);
- unsigned int result_len;
- int unsigned_operation;
-
- /* Determine type length and signedness after promotion for
- both operands. */
- if (promoted_len1 < TYPE_LENGTH (builtin_type_int))
- {
- is_unsigned1 = 0;
- promoted_len1 = TYPE_LENGTH (builtin_type_int);
- }
- if (promoted_len2 < TYPE_LENGTH (builtin_type_int))
- {
- is_unsigned2 = 0;
- promoted_len2 = TYPE_LENGTH (builtin_type_int);
- }
-
- /* Determine type length of the result, and if the operation should
- be done unsigned. For exponentiation and shift operators,
- use the length and type of the left operand. Otherwise,
- use the signedness of the operand with the greater length.
- If both operands are of equal length, use unsigned operation
- if one of the operands is unsigned. */
- if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
- {
- /* In case of the shift operators and exponentiation the type of
- the result only depends on the type of the left operand. */
- unsigned_operation = is_unsigned1;
- result_len = promoted_len1;
- }
- else if (promoted_len1 > promoted_len2)
- {
- unsigned_operation = is_unsigned1;
- result_len = promoted_len1;
- }
- else if (promoted_len2 > promoted_len1)
- {
- unsigned_operation = is_unsigned2;
- result_len = promoted_len2;
- }
- else
- {
- unsigned_operation = is_unsigned1 || is_unsigned2;
- result_len = promoted_len1;
- }
-
- switch (op)
- {
- case BINOP_ADD:
- case BINOP_SUB:
- case BINOP_MUL:
- case BINOP_DIV:
- case BINOP_INTDIV:
- case BINOP_EXP:
- case BINOP_REM:
- case BINOP_MOD:
- case BINOP_LSH:
- case BINOP_RSH:
- case BINOP_BITWISE_AND:
- case BINOP_BITWISE_IOR:
- case BINOP_BITWISE_XOR:
- case BINOP_LOGICAL_AND:
- case BINOP_LOGICAL_OR:
- case BINOP_MIN:
- case BINOP_MAX:
- case BINOP_EQUAL:
- case BINOP_NOTEQUAL:
- case BINOP_LESS:
- break;
-
- default:
- error (_("Invalid binary operation on numbers."));
- }
-
- switch (current_language->la_language)
- {
- case language_c:
- case language_cplus:
- case language_asm:
- case language_objc:
- if (result_len <= TYPE_LENGTH (builtin_type_int))
- {
- return (unsigned_operation
- ? builtin_type_unsigned_int
- : builtin_type_int);
- }
- else if (result_len <= TYPE_LENGTH (builtin_type_long))
- {
- return (unsigned_operation
- ? builtin_type_unsigned_long
- : builtin_type_long);
- }
- else
- {
- return (unsigned_operation
- ? builtin_type_unsigned_long_long
- : builtin_type_long_long);
- }
-
- default:
- /* For other languages the result type is unchanged from gdb
- version 6.7 for backward compatibility.
- If either arg was long long, make sure that value is also long
- long. Otherwise use long. */
- if (unsigned_operation)
- {
- if (result_len > gdbarch_long_bit (current_gdbarch) / HOST_CHAR_BIT)
- return builtin_type_unsigned_long_long;
- else
- return builtin_type_unsigned_long;
- }
- else
- {
- if (result_len > gdbarch_long_bit (current_gdbarch) / HOST_CHAR_BIT)
- return builtin_type_long_long;
- else
- return builtin_type_long;
- }
- }
- }
-
- return NULL; /* avoid -Wall warning */
-}
-
/* Integer exponentiation: V1**V2, where both arguments are
integers. Requires V1 != 0 if V2 < 0. Returns 1 for 0 ** 0. */
static LONGEST
@@ -1161,14 +869,32 @@ struct value *
value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
{
struct value *val;
- struct type *result_type;
+ struct type *type1, *type2, *result_type;
+
+ /* For shift and integer exponentiation operations,
+ only promote the first argument. */
+ if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
+ && is_integral_type (value_type (arg2)))
+ unop_promote (current_language, current_gdbarch, &arg1);
+ else
+ binop_promote (current_language, current_gdbarch, &arg1, &arg2);
arg1 = coerce_ref (arg1);
arg2 = coerce_ref (arg2);
- result_type = binop_result_type (op, value_type (arg1), value_type (arg2));
+ type1 = check_typedef (value_type (arg1));
+ type2 = check_typedef (value_type (arg2));
+
+ if ((TYPE_CODE (type1) != TYPE_CODE_FLT
+ && TYPE_CODE (type1) != TYPE_CODE_DECFLOAT
+ && !is_integral_type (type1))
+ || (TYPE_CODE (type2) != TYPE_CODE_FLT
+ && TYPE_CODE (type2) != TYPE_CODE_DECFLOAT
+ && !is_integral_type (type2)))
+ error (_("Argument to arithmetic operation not a number or boolean."));
- if (TYPE_CODE (result_type) == TYPE_CODE_DECFLOAT)
+ if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
+ || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
{
struct type *v_type;
int len_v1, len_v2, len_v;
@@ -1191,9 +917,21 @@ value_binop (struct value *arg1, struct
error (_("Operation not valid for decimal floating point number."));
}
+ /* If only one type is decimal float, use its type.
+ Otherwise use the bigger type. */
+ if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
+ result_type = type2;
+ else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
+ result_type = type1;
+ else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+ result_type = type2;
+ else
+ result_type = type1;
+
val = value_from_decfloat (result_type, v);
}
- else if (TYPE_CODE (result_type) == TYPE_CODE_FLT)
+ else if (TYPE_CODE (type1) == TYPE_CODE_FLT
+ || TYPE_CODE (type2) == TYPE_CODE_FLT)
{
/* FIXME-if-picky-about-floating-accuracy: Should be doing this
in target format. real.c in GCC probably has the necessary
@@ -1239,10 +977,22 @@ value_binop (struct value *arg1, struct
error (_("Integer-only operation on floating point number."));
}
+ /* If only one type is float, use its type.
+ Otherwise use the bigger type. */
+ if (TYPE_CODE (type1) != TYPE_CODE_FLT)
+ result_type = type2;
+ else if (TYPE_CODE (type2) != TYPE_CODE_FLT)
+ result_type = type1;
+ else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+ result_type = type2;
+ else
+ result_type = type1;
+
val = allocate_value (result_type);
store_typed_floating (value_contents_raw (val), value_type (val), v);
}
- else if (TYPE_CODE (result_type) == TYPE_CODE_BOOL)
+ else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
+ || TYPE_CODE (type2) == TYPE_CODE_BOOL)
{
LONGEST v1, v2, v = 0;
v1 = value_as_long (arg1);
@@ -1274,6 +1024,8 @@ value_binop (struct value *arg1, struct
error (_("Invalid operation on booleans."));
}
+ result_type = type1;
+
val = allocate_value (result_type);
store_signed_integer (value_contents_raw (val),
TYPE_LENGTH (result_type),
@@ -1282,31 +1034,32 @@ value_binop (struct value *arg1, struct
else
/* Integral operations here. */
{
- int unsigned_operation = TYPE_UNSIGNED (result_type);
+ /* Determine type length of the result, and if the operation should
+ be done unsigned. For exponentiation and shift operators,
+ use the length and type of the left operand. Otherwise,
+ use the signedness of the operand with the greater length.
+ If both operands are of equal length, use unsigned operation
+ if one of the operands is unsigned. */
+ if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
+ result_type = type1;
+ else if (TYPE_LENGTH (type1) > TYPE_LENGTH (type2))
+ result_type = type1;
+ else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+ result_type = type2;
+ else if (TYPE_UNSIGNED (type1))
+ result_type = type1;
+ else if (TYPE_UNSIGNED (type2))
+ result_type = type2;
+ else
+ result_type = type1;
- if (unsigned_operation)
+ if (TYPE_UNSIGNED (result_type))
{
- unsigned int len1, len2, result_len;
LONGEST v2_signed = value_as_long (arg2);
ULONGEST v1, v2, v = 0;
v1 = (ULONGEST) value_as_long (arg1);
v2 = (ULONGEST) v2_signed;
- /* Truncate values to the type length of the result.
- Things are mildly tricky because binop_result_type may
- return a long which on amd64 is 8 bytes, and that's a problem if
- ARG1, ARG2 are both <= 4 bytes: we need to truncate the values
- at 4 bytes not 8. So fetch the lengths of the original types
- and truncate at the larger of the two. */
- len1 = TYPE_LENGTH (value_type (arg1));
- len2 = TYPE_LENGTH (value_type (arg1));
- result_len = len1 > len2 ? len1 : len2;
- if (result_len < sizeof (ULONGEST))
- {
- v1 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
- v2 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
- }
-
switch (op)
{
case BINOP_ADD:
@@ -1730,19 +1483,19 @@ struct value *
value_pos (struct value *arg1)
{
struct type *type;
- struct type *result_type;
+
+ unop_promote (current_language, current_gdbarch, &arg1);
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
- result_type = unop_result_type (UNOP_PLUS, value_type (arg1));
if (TYPE_CODE (type) == TYPE_CODE_FLT)
- return value_from_double (result_type, value_as_double (arg1));
+ return value_from_double (type, value_as_double (arg1));
else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
- return value_from_decfloat (result_type, value_contents (arg1));
+ return value_from_decfloat (type, value_contents (arg1));
else if (is_integral_type (type))
{
- return value_from_longest (result_type, value_as_long (arg1));
+ return value_from_longest (type, value_as_long (arg1));
}
else
{
@@ -1755,15 +1508,15 @@ struct value *
value_neg (struct value *arg1)
{
struct type *type;
- struct type *result_type;
+
+ unop_promote (current_language, current_gdbarch, &arg1);
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
- result_type = unop_result_type (UNOP_NEG, value_type (arg1));
if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
{
- struct value *val = allocate_value (result_type);
+ struct value *val = allocate_value (type);
int len = TYPE_LENGTH (type);
gdb_byte decbytes[16]; /* a decfloat is at most 128 bits long */
@@ -1778,10 +1531,10 @@ value_neg (struct value *arg1)
return val;
}
else if (TYPE_CODE (type) == TYPE_CODE_FLT)
- return value_from_double (result_type, -value_as_double (arg1));
+ return value_from_double (type, -value_as_double (arg1));
else if (is_integral_type (type))
{
- return value_from_longest (result_type, -value_as_long (arg1));
+ return value_from_longest (type, -value_as_long (arg1));
}
else
{
@@ -1794,16 +1547,16 @@ struct value *
value_complement (struct value *arg1)
{
struct type *type;
- struct type *result_type;
+
+ unop_promote (current_language, current_gdbarch, &arg1);
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
- result_type = unop_result_type (UNOP_COMPLEMENT, value_type (arg1));
if (!is_integral_type (type))
error (_("Argument to complement operation not an integer or boolean."));
- return value_from_longest (result_type, ~value_as_long (arg1));
+ return value_from_longest (type, ~value_as_long (arg1));
}
\f
/* The INDEX'th bit of SET value whose value_type is TYPE,
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -446,6 +446,14 @@ extern CORE_ADDR parse_and_eval_address_
extern LONGEST parse_and_eval_long (char *exp);
+extern void unop_promote (const struct language_defn *language,
+ struct gdbarch *gdbarch,
+ struct value **arg1);
+
+extern void binop_promote (const struct language_defn *language,
+ struct gdbarch *gdbarch,
+ struct value **arg1, struct value **arg2);
+
extern struct value *access_value_history (int num);
extern struct value *value_of_internalvar (struct internalvar *var);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (23 preceding siblings ...)
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types uweigand
` (14 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-deref --]
[-- Type: text/plain, Size: 4076 bytes --]
Hello,
when implicitly dereferencing a reference, the valprint routines
manually construct a pointer type. This is superfluous, as the
unpack_pointer routine already handles references fine.
Bye,
Ulrich
ChangeLog:
* ada-valprint.c (ada_val_print_1): When implicitly dereferencing
a reference type, pass the reference type directly to unpack_pointer.
* c-valprint.c (c_val_print): Likewise.
* f-valprint.c (f_val_print): Likewise.
* m2-valprint.c (print_variable_at_address, m2_val_print): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -891,9 +891,7 @@ ada_val_print_1 (struct type *type, cons
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
- LONGEST deref_val_int = (LONGEST)
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr);
+ LONGEST deref_val_int = (LONGEST) unpack_pointer (type, valaddr);
if (deref_val_int != 0)
{
struct value *deref_val =
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -310,8 +310,7 @@ c_val_print (struct type *type, const gd
struct value *deref_val =
value_at
(TYPE_TARGET_TYPE (type),
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr + embedded_offset));
+ unpack_pointer (type, valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
recurse, pretty, current_language);
}
Index: gdb-head/gdb/f-valprint.c
===================================================================
--- gdb-head.orig/gdb/f-valprint.c
+++ gdb-head/gdb/f-valprint.c
@@ -444,8 +444,7 @@ f_val_print (struct type *type, const gd
struct value *deref_val =
value_at
(TYPE_TARGET_TYPE (type),
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr + embedded_offset));
+ unpack_pointer (type, valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref, recurse,
pretty, current_language);
}
Index: gdb-head/gdb/m2-valprint.c
===================================================================
--- gdb-head.orig/gdb/m2-valprint.c
+++ gdb-head/gdb/m2-valprint.c
@@ -258,10 +258,7 @@ print_variable_at_address (struct type *
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
struct value *deref_val =
- value_at
- (TYPE_TARGET_TYPE (type),
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr));
+ value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
common_val_print (deref_val, stream, format, deref_ref,
recurse, pretty, current_language);
}
@@ -420,8 +417,7 @@ m2_val_print (struct type *type, const g
struct value *deref_val =
value_at
(TYPE_TARGET_TYPE (type),
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr + embedded_offset));
+ unpack_pointer (type, valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
recurse, pretty, current_language);
}
Index: gdb-head/gdb/p-valprint.c
===================================================================
--- gdb-head.orig/gdb/p-valprint.c
+++ gdb-head/gdb/p-valprint.c
@@ -267,8 +267,7 @@ pascal_val_print (struct type *type, con
struct value *deref_val =
value_at
(TYPE_TARGET_TYPE (type),
- unpack_pointer (lookup_pointer_type (builtin_type_void),
- valaddr + embedded_offset));
+ unpack_pointer (type, valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
recurse + 1, pretty, current_language);
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (18 preceding siblings ...)
2008-08-31 17:53 ` [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
` (19 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-complex --]
[-- Type: text/plain, Size: 3037 bytes --]
Hello,
the OP_COMPLEX expression type was hard-coded to generate a result of
type "builtin_type_f_complex_s16". This should really be determined
by the front-end. The following patch adds the desired result type
as parameter to the OP_COMPLEX expression.
Bye,
Ulrich
ChangeLog:
* expression.h (enum exp_opcode): Document OP_COMPLEX to take
a type parameter as expression element.
* eval.c (evaluate_subexp_standard) [OP_COMPLEX]: Retrieve result
type as expression element.
* f-exp.y: Pass in type when buildin OP_COMPLEX expression.
* parse.c (operator_length_standard): Update length of OP_COMPLEX.
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -1369,10 +1369,11 @@ evaluate_subexp_standard (struct type *e
case OP_COMPLEX:
/* We have a complex number, There should be 2 floating
point numbers that compose it */
+ (*pos) += 2;
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- return value_literal_complex (arg1, arg2, builtin_type_f_complex_s16);
+ return value_literal_complex (arg1, arg2, exp->elts[pc + 1].type);
case STRUCTOP_STRUCT:
tem = longest_to_int (exp->elts[pc + 1].longconst);
Index: gdb-head/gdb/expression.h
===================================================================
--- gdb-head.orig/gdb/expression.h
+++ gdb-head/gdb/expression.h
@@ -193,8 +193,9 @@ enum exp_opcode
indicates that we have found something of the form <name> ( <stuff> ) */
OP_F77_UNDETERMINED_ARGLIST,
- /* The following OP is a special one, it introduces a F77 complex
- literal. It is followed by exactly two args that are doubles. */
+ /* OP_COMPLEX takes a type in the following element, followed by another
+ OP_COMPLEX, making three exp_elements. It is followed by two double
+ args, and converts them into a complex number of the given type. */
OP_COMPLEX,
/* OP_STRING represents a string constant.
Index: gdb-head/gdb/f-exp.y
===================================================================
--- gdb-head.orig/gdb/f-exp.y
+++ gdb-head/gdb/f-exp.y
@@ -328,7 +328,9 @@ complexnum: exp ',' exp
;
exp : '(' complexnum ')'
- { write_exp_elt_opcode(OP_COMPLEX); }
+ { write_exp_elt_opcode(OP_COMPLEX);
+ write_exp_elt_type (parse_f_type->builtin_complex_s16);
+ write_exp_elt_opcode(OP_COMPLEX); }
;
exp : '(' type ')' exp %prec UNARY
Index: gdb-head/gdb/parse.c
===================================================================
--- gdb-head.orig/gdb/parse.c
+++ gdb-head/gdb/parse.c
@@ -767,7 +767,7 @@ operator_length_standard (struct express
break;
case OP_COMPLEX:
- oplen = 1;
+ oplen = 3;
args = 2;
break;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (28 preceding siblings ...)
2008-08-31 17:53 ` [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number uweigand
@ 2008-08-31 17:53 ` uweigand
2008-09-02 12:38 ` Daniel Jacobowitz
2008-08-31 17:53 ` [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info uweigand
` (9 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-ptrmath --]
[-- Type: text/plain, Size: 16178 bytes --]
Hello,
this patch removes the functions value_add and value_sub which handle
both integer and pointer arithmetic, and replaces them by functions
value_ptradd, value_ptrsub, and value_ptrdiff that solely take care
of C-style pointer arithmetic. (For integer arithmetic, value_binop
can be used.)
This moves the type to be used for pointer difference operations up
eval.c (this should at some point be replaces by a per-gdbarch
"ptrdiff_t" type). It also makes the subsequent patches to remove
current_gdbarch references from value_binop simpler.
Bye,
Ulrich
ChangeLog:
* value.h (value_add, value_sub): Remove.
(value_ptradd, value_ptrsub, value_ptrdiff): Add prototypes.
* valarith.c (value_add, value_sub): Remove.
(value_ptradd, value_ptrsub, value_ptrdiff): New functions.
(find_size_for_pointer_math): Add assertion. Update comment.
(value_binop): Update comment.
* eval.c (ptrmath_type_p): New function.
(evaluate_subexp_standard): Replace value_add and value_sub
by value_ptradd, value_ptrsub, value_ptrdiff or value_binop.
Use builtin_type_uint8 instead of builtin_type_char to hold
the increment for BINOP_{PRE,POST}{IN,DE}CREMENT operations.
* valarith.c (value_subscript): Replace value_add by
value_ptradd. Replace value_sub by value_binop.
* ada-lang.c (ada_value_ptr_subscript): Likewise.
(ada_tag_name_2): Replace value_add by value_ptradd.
(ada_evaluate_subexp): Replace value_add and value_sub by
value_binop.
* m2-lang.c (evaluate_subexp_modula2): Replace value_add
by value_ptradd.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Likewise.
* gnu-v3-abi.c (gnuv3_method_ptr_to_value): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -2371,8 +2371,10 @@ ada_value_ptr_subscript (struct value *a
get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
idx = value_pos_atr (ind[k]);
if (lwb != 0)
- idx = value_sub (idx, value_from_longest (builtin_type_int, lwb));
- arr = value_add (arr, idx);
+ idx = value_binop (idx, value_from_longest (value_type (idx), lwb),
+ BINOP_SUB);
+
+ arr = value_ptradd (arr, idx);
type = TYPE_TARGET_TYPE (type);
}
@@ -5798,7 +5800,8 @@ ada_tag_name_2 (struct tag_args *args)
valp = value_cast (info_type, args->tag);
if (valp == NULL)
return 0;
- val = value_ind (value_add (valp, value_from_longest (builtin_type_int, -1)));
+ val = value_ind (value_ptradd (valp,
+ value_from_longest (builtin_type_int8, -1)));
if (val == NULL)
return 0;
val = ada_value_struct_elt (val, "expanded_name", 1);
@@ -8518,7 +8521,7 @@ ada_evaluate_subexp (struct type *expect
type = value_type (arg1);
while (TYPE_CODE (type) == TYPE_CODE_REF)
type = TYPE_TARGET_TYPE (type);
- return value_cast (type, value_add (arg1, arg2));
+ return value_cast (type, value_binop (arg1, arg2, BINOP_ADD));
case BINOP_SUB:
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -8535,7 +8538,7 @@ ada_evaluate_subexp (struct type *expect
type = value_type (arg1);
while (TYPE_CODE (type) == TYPE_CODE_REF)
type = TYPE_TARGET_TYPE (type);
- return value_cast (type, value_sub (arg1, arg2));
+ return value_cast (type, value_binop (arg1, arg2, BINOP_SUB));
case BINOP_MUL:
case BINOP_DIV:
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -439,6 +439,27 @@ value_f90_subarray (struct value *array,
return value_slice (array, low_bound, high_bound - low_bound + 1);
}
+static int
+ptrmath_type_p (struct type *type)
+{
+ type = check_typedef (type);
+ if (TYPE_CODE (type) == TYPE_CODE_REF)
+ type = TYPE_TARGET_TYPE (type);
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_FUNC:
+ return 1;
+
+ case TYPE_CODE_ARRAY:
+ return current_language->c_style_arrays;
+
+ default:
+ return 0;
+ }
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1506,10 +1527,10 @@ evaluate_subexp_standard (struct type *e
op = exp->elts[pc + 1].opcode;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
- else if (op == BINOP_ADD)
- arg2 = value_add (arg1, arg2);
- else if (op == BINOP_SUB)
- arg2 = value_sub (arg1, arg2);
+ else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptradd (arg1, arg2);
+ else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptrsub (arg1, arg2);
else
arg2 = value_binop (arg1, arg2, op);
return value_assign (arg1, arg2);
@@ -1521,8 +1542,12 @@ evaluate_subexp_standard (struct type *e
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+ else if (ptrmath_type_p (value_type (arg1)))
+ return value_ptradd (arg1, arg2);
+ else if (ptrmath_type_p (value_type (arg2)))
+ return value_ptradd (arg2, arg1);
else
- return value_add (arg1, arg2);
+ return value_binop (arg1, arg2, BINOP_ADD);
case BINOP_SUB:
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1531,8 +1556,19 @@ evaluate_subexp_standard (struct type *e
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+ else if (ptrmath_type_p (value_type (arg1))
+ && ptrmath_type_p (value_type (arg2)))
+ {
+ /* FIXME -- should be ptrdiff_t */
+ type = builtin_type (exp->gdbarch)->builtin_long;
+ return value_from_longest (type, value_ptrdiff (arg1, arg2));
+ }
+ else if (ptrmath_type_p (value_type (arg1)))
+ return value_ptrsub (arg1, arg2);
+ else if (ptrmath_type_p (value_type (arg2)))
+ return value_ptrsub (arg2, arg1);
else
- return value_sub (arg1, arg2);
+ return value_binop (arg1, arg2, BINOP_SUB);
case BINOP_EXP:
case BINOP_MUL:
@@ -2091,8 +2127,12 @@ evaluate_subexp_standard (struct type *e
}
else
{
- arg2 = value_add (arg1, value_from_longest (builtin_type_char,
- (LONGEST) 1));
+ arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+ if (ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptradd (arg1, arg2);
+ else
+ arg2 = value_binop (arg1, arg2, BINOP_ADD);
+
return value_assign (arg1, arg2);
}
@@ -2106,8 +2146,12 @@ evaluate_subexp_standard (struct type *e
}
else
{
- arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
- (LONGEST) 1));
+ arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+ if (ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptrsub (arg1, arg2);
+ else
+ arg2 = value_binop (arg1, arg2, BINOP_SUB);
+
return value_assign (arg1, arg2);
}
@@ -2121,8 +2165,12 @@ evaluate_subexp_standard (struct type *e
}
else
{
- arg2 = value_add (arg1, value_from_longest (builtin_type_char,
- (LONGEST) 1));
+ arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+ if (ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptradd (arg1, arg2);
+ else
+ arg2 = value_binop (arg1, arg2, BINOP_ADD);
+
value_assign (arg1, arg2);
return arg1;
}
@@ -2137,8 +2185,12 @@ evaluate_subexp_standard (struct type *e
}
else
{
- arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
- (LONGEST) 1));
+ arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
+ if (ptrmath_type_p (value_type (arg1)))
+ arg2 = value_ptrsub (arg1, arg2);
+ else
+ arg2 = value_binop (arg1, arg2, BINOP_SUB);
+
value_assign (arg1, arg2);
return arg1;
}
Index: gdb-head/gdb/gnu-v2-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v2-abi.c
+++ gdb-head/gdb/gnu-v2-abi.c
@@ -151,7 +151,7 @@ gnuv2_virtual_fn_field (struct value **a
else
{
/* Handle the case where the vtbl field points directly to a structure. */
- vtbl = value_add (vtbl, vi);
+ vtbl = value_ptradd (vtbl, vi);
entry = value_ind (vtbl);
}
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -662,7 +662,7 @@ gnuv3_method_ptr_to_value (struct value
instance. */
*this_p = value_cast (builtin_type_void_data_ptr, *this_p);
adjval = value_from_longest (builtin_type_long, adjustment);
- *this_p = value_add (*this_p, adjval);
+ *this_p = value_ptradd (*this_p, adjval);
*this_p = value_cast (final_type, *this_p);
if (vbit)
Index: gdb-head/gdb/m2-lang.c
===================================================================
--- gdb-head.orig/gdb/m2-lang.c
+++ gdb-head/gdb/m2-lang.c
@@ -251,7 +251,7 @@ evaluate_subexp_modula2 (struct type *ex
arg1 = value_cast (type, arg1);
type = check_typedef (value_type (arg1));
- return value_ind (value_add (arg1, arg2));
+ return value_ind (value_ptradd (arg1, arg2));
}
else
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -50,7 +50,7 @@ void _initialize_valarith (void);
If the pointer type is void *, then return 1.
If the target type is incomplete, then error out.
This isn't a general purpose function, but just a
- helper for value_sub & value_add.
+ helper for value_ptrsub & value_ptradd.
*/
static LONGEST
@@ -59,6 +59,7 @@ find_size_for_pointer_math (struct type
LONGEST sz = -1;
struct type *ptr_target;
+ gdb_assert (TYPE_CODE (ptr_type) == TYPE_CODE_PTR);
ptr_target = check_typedef (TYPE_TARGET_TYPE (ptr_type));
sz = TYPE_LENGTH (ptr_target);
@@ -84,90 +85,73 @@ find_size_for_pointer_math (struct type
return sz;
}
+/* Given a pointer ARG1 and an integral value ARG2, return the
+ result of C-style pointer arithmetic ARG1 + ARG2. */
+
struct value *
-value_add (struct value *arg1, struct value *arg2)
+value_ptradd (struct value *arg1, struct value *arg2)
{
- struct value *valint;
- struct value *valptr;
+ struct type *valptrtype;
LONGEST sz;
- struct type *type1, *type2, *valptrtype;
arg1 = coerce_array (arg1);
- arg2 = coerce_array (arg2);
- type1 = check_typedef (value_type (arg1));
- type2 = check_typedef (value_type (arg2));
+ valptrtype = check_typedef (value_type (arg1));
+ sz = find_size_for_pointer_math (valptrtype);
- if ((TYPE_CODE (type1) == TYPE_CODE_PTR
- || TYPE_CODE (type2) == TYPE_CODE_PTR)
- &&
- (is_integral_type (type1) || is_integral_type (type2)))
- /* Exactly one argument is a pointer, and one is an integer. */
- {
- struct value *retval;
-
- if (TYPE_CODE (type1) == TYPE_CODE_PTR)
- {
- valptr = arg1;
- valint = arg2;
- valptrtype = type1;
- }
- else
- {
- valptr = arg2;
- valint = arg1;
- valptrtype = type2;
- }
+ if (!is_integral_type (value_type (arg2)))
+ error (_("Argument to arithmetic operation not a number or boolean."));
+
+ return value_from_pointer (valptrtype,
+ value_as_address (arg1)
+ + (sz * value_as_long (arg2)));
+}
- sz = find_size_for_pointer_math (valptrtype);
+/* Given a pointer ARG1 and an integral value ARG2, return the
+ result of C-style pointer arithmetic ARG1 - ARG2. */
- retval = value_from_pointer (valptrtype,
- value_as_address (valptr)
- + (sz * value_as_long (valint)));
- return retval;
- }
+struct value *
+value_ptrsub (struct value *arg1, struct value *arg2)
+{
+ struct type *valptrtype;
+ LONGEST sz;
- return value_binop (arg1, arg2, BINOP_ADD);
+ arg1 = coerce_array (arg1);
+ valptrtype = check_typedef (value_type (arg1));
+ sz = find_size_for_pointer_math (valptrtype);
+
+ if (!is_integral_type (value_type (arg2)))
+ error (_("Argument to arithmetic operation not a number or boolean."));
+
+ return value_from_pointer (valptrtype,
+ value_as_address (arg1)
+ - (sz * value_as_long (arg2)));
}
-struct value *
-value_sub (struct value *arg1, struct value *arg2)
+/* Given two compatible pointer values ARG1 and ARG2, return the
+ result of C-style pointer arithmetic ARG1 - ARG2. */
+
+LONGEST
+value_ptrdiff (struct value *arg1, struct value *arg2)
{
struct type *type1, *type2;
+ LONGEST sz;
+
arg1 = coerce_array (arg1);
arg2 = coerce_array (arg2);
type1 = check_typedef (value_type (arg1));
type2 = check_typedef (value_type (arg2));
- if (TYPE_CODE (type1) == TYPE_CODE_PTR)
- {
- if (is_integral_type (type2))
- {
- /* pointer - integer. */
- LONGEST sz = find_size_for_pointer_math (type1);
+ gdb_assert (TYPE_CODE (type1) == TYPE_CODE_PTR);
+ gdb_assert (TYPE_CODE (type2) == TYPE_CODE_PTR);
- return value_from_pointer (type1,
- (value_as_address (arg1)
- - (sz * value_as_long (arg2))));
- }
- else if (TYPE_CODE (type2) == TYPE_CODE_PTR
- && TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
- == TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
- {
- /* pointer to <type x> - pointer to <type x>. */
- LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
- return value_from_longest
- (builtin_type_long, /* FIXME -- should be ptrdiff_t */
- (value_as_long (arg1) - value_as_long (arg2)) / sz);
- }
- else
- {
- error (_("\
+ if (TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
+ != TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
+ error (_("\
First argument of `-' is a pointer and second argument is neither\n\
an integer nor a pointer of the same type."));
- }
- }
- return value_binop (arg1, arg2, BINOP_SUB);
+ sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+ return (value_as_long (arg1) - value_as_long (arg2)) / sz;
}
/* Return the value of ARRAY[IDX].
@@ -211,15 +195,15 @@ value_subscript (struct value *array, st
if (lowerbound != 0)
{
- bound = value_from_longest (builtin_type_int, (LONGEST) lowerbound);
- idx = value_sub (idx, bound);
+ bound = value_from_longest (value_type (idx), (LONGEST) lowerbound);
+ idx = value_binop (idx, bound, BINOP_SUB);
}
array = value_coerce_array (array);
}
if (c_style)
- return value_ind (value_add (array, idx));
+ return value_ind (value_ptradd (array, idx));
else
error (_("not an array or string"));
}
@@ -1171,7 +1155,7 @@ value_args_as_decimal (struct value *arg
representations as integers or floats. This includes booleans,
characters, integers, or floats.
Does not support addition and subtraction on pointers;
- use value_add or value_sub if you want to handle those possibilities. */
+ use value_ptradd, value_ptrsub or value_ptrdiff for those operations. */
struct value *
value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -331,9 +331,11 @@ extern struct value *value_concat (struc
extern struct value *value_binop (struct value *arg1, struct value *arg2,
enum exp_opcode op);
-extern struct value *value_add (struct value *arg1, struct value *arg2);
+extern struct value *value_ptradd (struct value *arg1, struct value *arg2);
-extern struct value *value_sub (struct value *arg1, struct value *arg2);
+extern struct value *value_ptrsub (struct value *arg1, struct value *arg2);
+
+extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
extern int value_must_coerce_to_target (struct value *arg1);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (26 preceding siblings ...)
2008-08-31 17:53 ` [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number uweigand
` (11 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-adapos --]
[-- Type: text/plain, Size: 3792 bytes --]
Hello,
the value_pos_atr uses a hard-coded builtin_type_int as the type
of its result value. This patch adds a TYPE parameter instead
and pushes the choice of result type up to the callers.
Bye,
Ulrich
ChangeLog:
* ada-lang.c (value_pos_atr): Add TYPE argument. Use it as
result type instead of builtin_type_int.
(value_subscript_packed): Use pos_atr instead of value_pos_atr.
(ada_value_subscript): Update call to value_pos_atr.
(ada_value_ptr_subscript): Likewise.
(ada_evaluate_subexp): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -212,7 +212,7 @@ static struct value *ada_coerce_ref (str
static LONGEST pos_atr (struct value *);
-static struct value *value_pos_atr (struct value *);
+static struct value *value_pos_atr (struct type *, struct value *);
static struct value *value_val_atr (struct type *, struct value *);
@@ -1968,7 +1968,7 @@ value_subscript_packed (struct value *ar
lowerbound = upperbound = 0;
}
- idx = value_as_long (value_pos_atr (ind[i]));
+ idx = pos_atr (ind[i]);
if (idx < lowerbound || idx > upperbound)
lim_warning (_("packed array index %ld out of bounds"), (long) idx);
bits = TYPE_FIELD_BITSIZE (elt_type, 0);
@@ -2344,7 +2344,7 @@ ada_value_subscript (struct value *arr,
{
if (TYPE_CODE (elt_type) != TYPE_CODE_ARRAY)
error (_("too many subscripts (%d expected)"), k);
- elt = value_subscript (elt, value_pos_atr (ind[k]));
+ elt = value_subscript (elt, value_pos_atr (builtin_type_int32, ind[k]));
}
return elt;
}
@@ -2369,7 +2369,7 @@ ada_value_ptr_subscript (struct value *a
arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
value_copy (arr));
get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
- idx = value_pos_atr (ind[k]);
+ idx = value_pos_atr (builtin_type_int32, ind[k]);
if (lwb != 0)
idx = value_binop (idx, value_from_longest (value_type (idx), lwb),
BINOP_SUB);
@@ -7660,9 +7660,9 @@ pos_atr (struct value *arg)
}
static struct value *
-value_pos_atr (struct value *arg)
+value_pos_atr (struct type *type, struct value *arg)
{
- return value_from_longest (builtin_type_int, pos_atr (arg));
+ return value_from_longest (type, pos_atr (arg));
}
/* Evaluate the TYPE'VAL attribute applied to ARG. */
@@ -9101,19 +9101,21 @@ ada_evaluate_subexp (struct type *expect
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_int, not_lval);
+ type = builtin_type (exp->gdbarch)->builtin_int;
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (type, not_lval);
else
- return value_pos_atr (arg1);
+ return value_pos_atr (type, arg1);
case OP_ATR_SIZE:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_int, not_lval);
+ type = builtin_type (exp->gdbarch)->builtin_int;
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (type, not_lval);
else
- return value_from_longest (builtin_type_int,
+ return value_from_longest (type,
TARGET_CHAR_BIT
* TYPE_LENGTH (value_type (arg1)));
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (22 preceding siblings ...)
2008-08-31 17:53 ` [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling uweigand
@ 2008-08-31 17:53 ` uweigand
2008-09-05 18:16 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references uweigand
` (15 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-bitstring --]
[-- Type: text/plain, Size: 5316 bytes --]
Hello,
in preparation to removing use of the LA_BOOL_TYPE macro, this patch
moves handling of TYPE_CODE_BITSTRING subscripts out of value_subscript
into a new function value_bitstring_subscript that gets the boolean
type requested by the caller as argument.
Bye,
Ulrich
ChangeLog:
* value.h (value_bitstring_subscript): New prototype.
* valarith.h (value_bitstring_subscript): New function.
(value_subscript): No longer handle TYPE_CODE_BITSTRING.
* eval.c (evaluate_subexp_standard): Call value_bitstring_subscript
instead of value_subscript to handle TYPE_CODE_BITSTRING.
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -1666,7 +1666,28 @@ evaluate_subexp_standard (struct type *e
}
else
{
- arg1 = value_subscript (arg1, arg2);
+ arg1 = coerce_ref (arg1);
+ type = check_typedef (value_type (arg1));
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
+ arg1 = value_subscript (arg1, arg2);
+ break;
+
+ case TYPE_CODE_BITSTRING:
+ arg1 = value_bitstring_subscript (LA_BOOL_TYPE, arg1, arg2);
+ break;
+
+ default:
+ if (TYPE_NAME (type))
+ error (_("cannot subscript something of type `%s'"),
+ TYPE_NAME (type));
+ else
+ error (_("cannot subscript requested type"));
+ }
}
}
return (arg1);
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -218,34 +218,6 @@ value_subscript (struct value *array, st
array = value_coerce_array (array);
}
- if (TYPE_CODE (tarray) == TYPE_CODE_BITSTRING)
- {
- struct type *range_type = TYPE_INDEX_TYPE (tarray);
- LONGEST index = value_as_long (idx);
- struct value *v;
- int offset, byte, bit_index;
- LONGEST lowerbound, upperbound;
- get_discrete_bounds (range_type, &lowerbound, &upperbound);
- if (index < lowerbound || index > upperbound)
- error (_("bitstring index out of range"));
- index -= lowerbound;
- offset = index / TARGET_CHAR_BIT;
- byte = *((char *) value_contents (array) + offset);
- bit_index = index % TARGET_CHAR_BIT;
- byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
- TARGET_CHAR_BIT - 1 - bit_index : bit_index);
- v = value_from_longest (LA_BOOL_TYPE, byte & 1);
- set_value_bitpos (v, bit_index);
- set_value_bitsize (v, 1);
- VALUE_LVAL (v) = VALUE_LVAL (array);
- if (VALUE_LVAL (array) == lval_internalvar)
- VALUE_LVAL (v) = lval_internalvar_component;
- VALUE_ADDRESS (v) = VALUE_ADDRESS (array);
- VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
- set_value_offset (v, offset + value_offset (array));
- return v;
- }
-
if (c_style)
return value_ind (value_add (array, idx));
else
@@ -286,6 +258,52 @@ value_subscripted_rvalue (struct value *
set_value_offset (v, value_offset (array) + elt_offs);
return v;
}
+
+/* Return the value of BITSTRING[IDX] as (boolean) type TYPE. */
+
+struct value *
+value_bitstring_subscript (struct type *type,
+ struct value *bitstring, struct value *idx)
+{
+
+ struct type *bitstring_type, *range_type;
+ LONGEST index = value_as_long (idx);
+ struct value *v;
+ int offset, byte, bit_index;
+ LONGEST lowerbound, upperbound;
+
+ bitstring_type = check_typedef (value_type (bitstring));
+ gdb_assert (TYPE_CODE (bitstring_type) == TYPE_CODE_BITSTRING);
+
+ range_type = TYPE_INDEX_TYPE (bitstring_type);
+ get_discrete_bounds (range_type, &lowerbound, &upperbound);
+ if (index < lowerbound || index > upperbound)
+ error (_("bitstring index out of range"));
+
+ index -= lowerbound;
+ offset = index / TARGET_CHAR_BIT;
+ byte = *((char *) value_contents (bitstring) + offset);
+
+ bit_index = index % TARGET_CHAR_BIT;
+ byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
+ TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+
+ v = value_from_longest (type, byte & 1);
+
+ set_value_bitpos (v, bit_index);
+ set_value_bitsize (v, 1);
+
+ VALUE_LVAL (v) = VALUE_LVAL (bitstring);
+ if (VALUE_LVAL (bitstring) == lval_internalvar)
+ VALUE_LVAL (v) = lval_internalvar_component;
+ VALUE_ADDRESS (v) = VALUE_ADDRESS (bitstring);
+ VALUE_FRAME_ID (v) = VALUE_FRAME_ID (bitstring);
+
+ set_value_offset (v, offset + value_offset (bitstring));
+
+ return v;
+}
+
\f
/* Check to see if either argument is a structure, or a reference to
one. This is called so we know whether to go ahead with the normal
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -405,6 +405,10 @@ extern struct value *value_repeat (struc
extern struct value *value_subscript (struct value *array, struct value *idx);
+extern struct value *value_bitstring_subscript (struct type *type,
+ struct value *bitstring,
+ struct value *idx);
+
extern struct value *register_value_being_returned (struct type *valtype,
struct regcache *retbuf);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (30 preceding siblings ...)
2008-08-31 17:53 ` [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation uweigand
` (7 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-bsduthread --]
[-- Type: text/plain, Size: 3151 bytes --]
Hello,
bsd-uthread.c uses builtin_type_void_data_ptr to access target pointers.
As the thread layers (like shared library layers) should now be using
per-target architecture, this patch changes every such use to refer to
the builtin types defined by target_gdbarch instead.
Bye,
Ulrich
ChangeLog:
* bsd-uthread.c (bsd_uthread_read_memory_address): New function.
(bsd_uthread_fetch_registers, bsd_uthread_store_registers,
bsd_uthread_wait, bsd_uthread_find_new_threads): Use it.
Index: gdb-head/gdb/bsd-uthread.c
===================================================================
--- gdb-head.orig/gdb/bsd-uthread.c
+++ gdb-head/gdb/bsd-uthread.c
@@ -145,6 +145,13 @@ bsd_uthread_lookup_offset (const char *n
return read_memory_unsigned_integer (addr, 4);
}
+static CORE_ADDR
+bsd_uthread_read_memory_address (CORE_ADDR addr)
+{
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ return read_memory_typed_address (addr, ptr_type);
+}
+
/* If OBJFILE contains the symbols corresponding to one of the
supported user-level threads libraries, activate the thread stratum
implemented by this module. */
@@ -285,8 +292,7 @@ bsd_uthread_fetch_registers (struct regc
thread structure. This can go once we fix the underlying target. */
regnum = -1;
- active_addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
- builtin_type_void_data_ptr);
+ active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
if (addr != 0 && addr != active_addr)
{
bsd_uthread_check_magic (addr);
@@ -303,8 +309,7 @@ bsd_uthread_store_registers (struct regc
CORE_ADDR addr = ptid_get_tid (inferior_ptid);
CORE_ADDR active_addr;
- active_addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
- builtin_type_void_data_ptr);
+ active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
if (addr != 0 && addr != active_addr)
{
bsd_uthread_check_magic (addr);
@@ -349,8 +354,7 @@ bsd_uthread_wait (ptid_t ptid, struct ta
/* Fetch the corresponding thread ID, and augment the returned
process ID with it. */
- addr = read_memory_typed_address (bsd_uthread_thread_run_addr,
- builtin_type_void_data_ptr);
+ addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
if (addr != 0)
{
gdb_byte buf[4];
@@ -413,8 +417,7 @@ bsd_uthread_find_new_threads (void)
int offset = bsd_uthread_thread_next_offset;
CORE_ADDR addr;
- addr = read_memory_typed_address (bsd_uthread_thread_list_addr,
- builtin_type_void_data_ptr);
+ addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr);
while (addr != 0)
{
ptid_t ptid = ptid_build (pid, 0, addr);
@@ -422,8 +425,7 @@ bsd_uthread_find_new_threads (void)
if (!in_thread_list (ptid))
add_thread (ptid);
- addr = read_memory_typed_address (addr + offset,
- builtin_type_void_data_ptr);
+ addr = bsd_uthread_read_memory_address (addr + offset);
}
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (24 preceding siblings ...)
2008-08-31 17:53 ` [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code uweigand
` (13 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-truechar --]
[-- Type: text/plain, Size: 5723 bytes --]
Hello,
similarly to the preceding builtin_type_void patch, this patch converts
builtin_type_true_char and builtin_type_true_unsigned_char into global
platform-neutral variables. These types are only used for GDB-internal
platform-neutral purposes.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (struct builtin_type): Remove builtin_true_char
and builtin_true_unsigned_char.
(builtin_type_true_char): Remove macro, add extern declaration.
(builtin_type_true_unsigned_char): Add extern declaration.
* gdbtypes.c (builtin_type_true_char): New global variable.
(builtin_type_true_unsigned_char): Likewise.
(_initialize_gdbtypes): Initialize them.
(gdbtypes_post_init): Do not initialize builtin_true_char
and builtin_true_unsigned_char members of struct builtin_type.
* printcmd.c (print_scalar_formatted): Do not use builtin_type;
use builtin_type_true_unsigned_char instead.
* ada-valprint.c (ada_val_print_1): Use builtin_type_true_char
instead of builtin_type_char for internal string.
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -111,6 +111,10 @@ struct type *builtin_type_ia64_quad;
/* Platform-neutral void type. */
struct type *builtin_type_void;
+/* Platform-neutral character types. */
+struct type *builtin_type_true_char;
+struct type *builtin_type_true_unsigned_char;
+
int opaque_type_resolution = 1;
static void
@@ -3109,14 +3113,6 @@ gdbtypes_post_init (struct gdbarch *gdba
(TYPE_FLAG_NOSIGN
| (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
"char", (struct objfile *) NULL);
- 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);
builtin_type->builtin_signed_char =
init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0,
@@ -3337,6 +3333,14 @@ _initialize_gdbtypes (void)
init_type (TYPE_CODE_VOID, 1,
0,
"void", (struct objfile *) NULL);
+ 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."), _("\
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -977,12 +977,6 @@ struct builtin_type
/* Integral 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;
-
/* Implicit size/sign (based on the the architecture's ABI). */
struct type *builtin_void;
struct type *builtin_char;
@@ -1018,8 +1012,6 @@ extern const struct builtin_type *builti
(builtin_type (current_gdbarch)->builtin_func_ptr)
#define builtin_type_CORE_ADDR \
(builtin_type (current_gdbarch)->builtin_core_addr)
-#define builtin_type_true_char \
- (builtin_type (current_gdbarch)->builtin_true_char)
#define builtin_type_char \
(builtin_type (current_gdbarch)->builtin_char)
#define builtin_type_short \
@@ -1099,6 +1091,14 @@ extern struct type *builtin_type_ia64_qu
You must use builtin_type (...)->builtin_void in those cases. */
extern struct type *builtin_type_void;
+/* 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;
+
+
/* This type represents a type that was unrecognized in symbol
read-in. */
extern struct type *builtin_type_error;
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -425,13 +425,9 @@ print_scalar_formatted (const void *vala
case 'c':
if (TYPE_UNSIGNED (type))
- {
- struct type *utype;
-
- utype = builtin_type (current_gdbarch)->builtin_true_unsigned_char;
- value_print (value_from_longest (utype, val_long),
- stream, 0, Val_pretty_default);
- }
+ value_print (value_from_longest (builtin_type_true_unsigned_char,
+ val_long),
+ stream, 0, Val_pretty_default);
else
value_print (value_from_longest (builtin_type_true_char, val_long),
stream, 0, Val_pretty_default);
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -752,7 +752,7 @@ ada_val_print_1 (struct type *type, cons
parray_of_char =
make_pointer_type
(create_array_type
- (NULL, builtin_type_char,
+ (NULL, builtin_type_true_char,
create_range_type (NULL, builtin_type_int, 0, 32)), NULL);
printable_val =
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (20 preceding siblings ...)
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
@ 2008-08-31 17:53 ` uweigand
2008-09-05 22:39 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling uweigand
` (17 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-promote2 --]
[-- Type: text/plain, Size: 15120 bytes --]
Hello,
this patch now moves the calls to unop_promote and binop_promote up
to the respective callers. Note that a number of GDB-internal call
sites not involved with expression parsing do not need to perform
any argument promotion; they're happy with the new default behaviour
of value_binop et. al.
Note also that value_equal and value_less call value_binop; this patch
pushes the binop_promote call right through to *their* callers.
This patch adds a number of _promote calls to ada-lang.c; while these
should simply preserve the status quo, someone familiar with the Ada
type promotion rules should probably have a look at those, maybe this
code can now be simplified a bit ...
Bye,
Ulrich
ChangeLog:
* eval.c (evaluate_subexp_standard): Add calls to binop_promote
and unop_promote before calling value_binop et. al.
* ada-lang.c (ada_evaluate_subexp): Add calls to binop_promote
and unop_promote before calling value_binop et. al.
* valarith.c (value_binop): Do not call binop_promote or unop_promote.
(value_pos): Do not call unop_promote.
(value_neg, value_complement): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -8521,6 +8521,7 @@ ada_evaluate_subexp (struct type *expect
type = value_type (arg1);
while (TYPE_CODE (type) == TYPE_CODE_REF)
type = TYPE_TARGET_TYPE (type);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
return value_cast (type, value_binop (arg1, arg2, BINOP_ADD));
case BINOP_SUB:
@@ -8538,6 +8539,7 @@ ada_evaluate_subexp (struct type *expect
type = value_type (arg1);
while (TYPE_CODE (type) == TYPE_CODE_REF)
type = TYPE_TARGET_TYPE (type);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
return value_cast (type, value_binop (arg1, arg2, BINOP_SUB));
case BINOP_MUL:
@@ -8555,6 +8557,7 @@ ada_evaluate_subexp (struct type *expect
arg1 = cast_from_fixed_to_double (arg1);
if (ada_is_fixed_point_type (value_type (arg2)))
arg2 = cast_from_fixed_to_double (arg2);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
return ada_value_binop (arg1, arg2, op);
}
@@ -8568,7 +8571,10 @@ ada_evaluate_subexp (struct type *expect
&& (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD))
return value_zero (value_type (arg1), not_lval);
else
- return ada_value_binop (arg1, arg2, op);
+ {
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ return ada_value_binop (arg1, arg2, op);
+ }
case BINOP_EQUAL:
case BINOP_NOTEQUAL:
@@ -8579,7 +8585,10 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_AVOID_SIDE_EFFECTS)
tem = 0;
else
- tem = ada_value_equal (arg1, arg2);
+ {
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ tem = ada_value_equal (arg1, arg2);
+ }
if (op == BINOP_NOTEQUAL)
tem = !tem;
type = language_bool_type (exp->language_defn, exp->gdbarch);
@@ -8592,7 +8601,10 @@ ada_evaluate_subexp (struct type *expect
else if (ada_is_fixed_point_type (value_type (arg1)))
return value_cast (value_type (arg1), value_neg (arg1));
else
- return value_neg (arg1);
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_neg (arg1);
+ }
case BINOP_LOGICAL_AND:
case BINOP_LOGICAL_OR:
@@ -8862,6 +8874,8 @@ ada_evaluate_subexp (struct type *expect
arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
arg3 = value_from_longest (builtin_type_int,
TYPE_HIGH_BOUND (type));
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (type,
@@ -8893,6 +8907,8 @@ ada_evaluate_subexp (struct type *expect
arg3 = ada_array_bound (arg2, tem, 1);
arg2 = ada_array_bound (arg2, tem, 0);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (type,
@@ -8909,6 +8925,8 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (type,
@@ -9056,8 +9074,11 @@ ada_evaluate_subexp (struct type *expect
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (value_type (arg1), not_lval);
else
- return value_binop (arg1, arg2,
- op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
+ {
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ return value_binop (arg1, arg2,
+ op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
+ }
case OP_ATR_MODULUS:
{
@@ -9115,7 +9136,16 @@ ada_evaluate_subexp (struct type *expect
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (value_type (arg1), not_lval);
else
- return value_binop (arg1, arg2, op);
+ {
+ /* For integer exponentiation operations,
+ only promote the first argument. */
+ if (is_integral_type (value_type (arg2)))
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ else
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+
+ return value_binop (arg1, arg2, op);
+ }
case UNOP_PLUS:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -9128,6 +9158,7 @@ ada_evaluate_subexp (struct type *expect
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
if (value_less (arg1, value_zero (value_type (arg1), not_lval)))
return value_neg (arg1);
else
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -1725,7 +1725,19 @@ evaluate_subexp_standard (struct type *e
else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)))
arg2 = value_ptrsub (arg1, arg2);
else
- arg2 = value_binop (arg1, arg2, op);
+ {
+ struct value *tmp = arg1;
+
+ /* For shift and integer exponentiation operations,
+ only promote the first argument. */
+ if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
+ && is_integral_type (value_type (arg2)))
+ unop_promote (exp->language_defn, exp->gdbarch, &tmp);
+ else
+ binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+
+ arg2 = value_binop (tmp, arg2, op);
+ }
return value_assign (arg1, arg2);
case BINOP_ADD:
@@ -1740,7 +1752,10 @@ evaluate_subexp_standard (struct type *e
else if (ptrmath_type_p (value_type (arg2)))
return value_ptradd (arg2, arg1);
else
- return value_binop (arg1, arg2, BINOP_ADD);
+ {
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ return value_binop (arg1, arg2, BINOP_ADD);
+ }
case BINOP_SUB:
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1761,7 +1776,10 @@ evaluate_subexp_standard (struct type *e
else if (ptrmath_type_p (value_type (arg2)))
return value_ptrsub (arg2, arg1);
else
- return value_binop (arg1, arg2, BINOP_SUB);
+ {
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+ return value_binop (arg1, arg2, BINOP_SUB);
+ }
case BINOP_EXP:
case BINOP_MUL:
@@ -1798,11 +1816,22 @@ evaluate_subexp_standard (struct type *e
struct value *v_one, *retval;
v_one = value_one (value_type (arg2), not_lval);
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &v_one);
retval = value_binop (arg1, v_one, op);
return retval;
}
else
- return value_binop (arg1, arg2, op);
+ {
+ /* For shift and integer exponentiation operations,
+ only promote the first argument. */
+ if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
+ && is_integral_type (value_type (arg2)))
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ else
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+
+ return value_binop (arg1, arg2, op);
+ }
}
case BINOP_RANGE:
@@ -2073,6 +2102,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_equal (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
@@ -2089,6 +2119,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_equal (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) ! tem);
@@ -2105,6 +2136,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_less (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
@@ -2121,6 +2153,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_less (arg2, arg1);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
@@ -2137,6 +2170,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
@@ -2153,6 +2187,7 @@ evaluate_subexp_standard (struct type *e
}
else
{
+ binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
@@ -2185,7 +2220,10 @@ evaluate_subexp_standard (struct type *e
if (unop_user_defined_p (op, arg1))
return value_x_unop (arg1, op, noside);
else
- return value_pos (arg1);
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_pos (arg1);
+ }
case UNOP_NEG:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -2194,7 +2232,10 @@ evaluate_subexp_standard (struct type *e
if (unop_user_defined_p (op, arg1))
return value_x_unop (arg1, op, noside);
else
- return value_neg (arg1);
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_neg (arg1);
+ }
case UNOP_COMPLEMENT:
/* C++: check for and handle destructor names. */
@@ -2206,7 +2247,10 @@ evaluate_subexp_standard (struct type *e
if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
return value_x_unop (arg1, UNOP_COMPLEMENT, noside);
else
- return value_complement (arg1);
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_complement (arg1);
+ }
case UNOP_LOGICAL_NOT:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -2324,7 +2368,11 @@ evaluate_subexp_standard (struct type *e
if (ptrmath_type_p (value_type (arg1)))
arg2 = value_ptradd (arg1, arg2);
else
- arg2 = value_binop (arg1, arg2, BINOP_ADD);
+ {
+ struct value *tmp = arg1;
+ binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+ arg2 = value_binop (tmp, arg2, BINOP_ADD);
+ }
return value_assign (arg1, arg2);
}
@@ -2343,7 +2391,11 @@ evaluate_subexp_standard (struct type *e
if (ptrmath_type_p (value_type (arg1)))
arg2 = value_ptrsub (arg1, arg2);
else
- arg2 = value_binop (arg1, arg2, BINOP_SUB);
+ {
+ struct value *tmp = arg1;
+ binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+ arg2 = value_binop (tmp, arg2, BINOP_SUB);
+ }
return value_assign (arg1, arg2);
}
@@ -2362,7 +2414,11 @@ evaluate_subexp_standard (struct type *e
if (ptrmath_type_p (value_type (arg1)))
arg2 = value_ptradd (arg1, arg2);
else
- arg2 = value_binop (arg1, arg2, BINOP_ADD);
+ {
+ struct value *tmp = arg1;
+ binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+ arg2 = value_binop (tmp, arg2, BINOP_ADD);
+ }
value_assign (arg1, arg2);
return arg1;
@@ -2382,7 +2438,11 @@ evaluate_subexp_standard (struct type *e
if (ptrmath_type_p (value_type (arg1)))
arg2 = value_ptrsub (arg1, arg2);
else
- arg2 = value_binop (arg1, arg2, BINOP_SUB);
+ {
+ struct value *tmp = arg1;
+ binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
+ arg2 = value_binop (tmp, arg2, BINOP_SUB);
+ }
value_assign (arg1, arg2);
return arg1;
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -871,14 +871,6 @@ value_binop (struct value *arg1, struct
struct value *val;
struct type *type1, *type2, *result_type;
- /* For shift and integer exponentiation operations,
- only promote the first argument. */
- if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP)
- && is_integral_type (value_type (arg2)))
- unop_promote (current_language, current_gdbarch, &arg1);
- else
- binop_promote (current_language, current_gdbarch, &arg1, &arg2);
-
arg1 = coerce_ref (arg1);
arg2 = coerce_ref (arg2);
@@ -1484,8 +1476,6 @@ value_pos (struct value *arg1)
{
struct type *type;
- unop_promote (current_language, current_gdbarch, &arg1);
-
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
@@ -1509,8 +1499,6 @@ value_neg (struct value *arg1)
{
struct type *type;
- unop_promote (current_language, current_gdbarch, &arg1);
-
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
@@ -1548,8 +1536,6 @@ value_complement (struct value *arg1)
{
struct type *type;
- unop_promote (current_language, current_gdbarch, &arg1);
-
arg1 = coerce_ref (arg1);
type = check_typedef (value_type (arg1));
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (19 preceding siblings ...)
2008-08-31 17:53 ` [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit uweigand
@ 2008-08-31 17:53 ` uweigand
2008-09-05 20:18 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
` (18 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-cpgnu --]
[-- Type: text/plain, Size: 23710 bytes --]
Hello,
gnu-v3-abi.c uses current_gdbarch and builtin_type_ macros to determine
ABI properties of the C++ class implementation. The following patch
removes the dependency on the current_gdbarch variable by using the
architecture associated with the objfile where the class type is defined.
Note that this assumes every C++ class type GDB handles is in fact
defined in an objfile, i.e. there are no GDB internal class types.
This is in fact the case (except for some Java "class" definitions,
which are not handled by gnu-v3-abi.c anyway).
Nearly all functions in gnu-v3-abi.c already operate on a class type.
The only exceptions are the cplus_method_ptr_size and cplus_make_method_ptr
callbacks; to handle those, I've updated their callers to pass in the
appropriate method (or method pointer) type.
As another C++-related change, I've removed the assumption in
cp_print_class_member that member pointer types have the same length
as a "long" on the target. If the caller simply passes in the pointer
type itself instead of only the associated domain type, that routine
can just use the actual length of the pointer type itself.
Bye,
Ulrich
* cp-abi.h (cplus_method_ptr_size): Add TO_TYPE parameter.
(cplus_make_method_ptr): Add TYPE parameter.
* cp-abi.c (cplus_method_ptr_size): Add TO_TYPE parameter. Pass it
on to current_cp_abi.method_ptr_size callback.
(cplus_make_method_ptr): Add TYPE parameter. Pass it on to
current_cp_abi.make_method_ptr callback.
* gdbtypes.c (lookup_methodptr_type): Pass target type
argument to cplus_method_ptr_size.
* valops.c (value_cast): Pass type argument to cplus_make_method_ptr.
(value_struct_elt_for_reference): Likewise.
* gnu-v3-abi.c (get_class_arch): New function.
(vtable_address_point_offset): Add GDBARCH parameter. Use it
instead of current_gdbarch. Update all callers.
(gnuv3_get_vtable): Likewise.
(gnuv3_get_virtual_fn): Likewise.
(gnuv3_rtti_type): Call get_class_arch to determine architecture.
Use it instead of current_gdbarch.
(gnuv3_virtual_fn_field): Likewise.
(gnuv3_baseclass_offset): Likewise.
(gnuv3_print_method_ptr): Likewise.
(gnuv3_method_ptr_to_value): Likewise.
(gnuv3_method_ptr_size): Add TYPE parameter. Use it to determine
class architecture. Use architecture types instead of builtin types.
(gnuv3_make_method_ptr): Likewise.
* cp-valprint.c (cp_print_class_member): Expect pointer type
instead of class type. Use its length when extracting value.
* c-valprint.c (c_val_print): Update call to cp_print_class_member.
Index: gdb-head/gdb/cp-abi.c
===================================================================
--- gdb-head.orig/gdb/cp-abi.c
+++ gdb-head/gdb/cp-abi.c
@@ -113,19 +113,20 @@ cplus_print_method_ptr (const gdb_byte *
}
int
-cplus_method_ptr_size (void)
+cplus_method_ptr_size (struct type *to_type)
{
if (current_cp_abi.method_ptr_size == NULL)
error (_("GDB does not support pointers to methods on this target"));
- return (*current_cp_abi.method_ptr_size) ();
+ return (*current_cp_abi.method_ptr_size) (to_type);
}
void
-cplus_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+cplus_make_method_ptr (struct type *type, gdb_byte *contents,
+ CORE_ADDR value, int is_virtual)
{
if (current_cp_abi.make_method_ptr == NULL)
error (_("GDB does not support pointers to methods on this target"));
- (*current_cp_abi.make_method_ptr) (contents, value, is_virtual);
+ (*current_cp_abi.make_method_ptr) (type, contents, value, is_virtual);
}
CORE_ADDR
Index: gdb-head/gdb/cp-abi.h
===================================================================
--- gdb-head.orig/gdb/cp-abi.h
+++ gdb-head/gdb/cp-abi.h
@@ -151,21 +151,20 @@ extern int baseclass_offset (struct type
void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
struct ui_file *stream);
-/* Return the size of a pointer to member function for the current
- architecture. */
-int cplus_method_ptr_size (void);
+/* Return the size of a pointer to member function of type TO_TYPE. */
+int cplus_method_ptr_size (struct type *to_type);
/* Return the method which should be called by applying METHOD_PTR
to *THIS_P, and adjust *THIS_P if necessary. */
struct value *cplus_method_ptr_to_value (struct value **this_p,
struct value *method_ptr);
-/* Create the byte pattern in CONTENTS representing a pointer to
- member function at ADDRESS (if IS_VIRTUAL is 0) or with virtual
- table offset ADDRESS (if IS_VIRTUAL is 1). This is the opposite
- of cplus_method_ptr_to_value. */
-void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
- int is_virtual);
+/* Create the byte pattern in CONTENTS representing a pointer of
+ type TYPE to member function at ADDRESS (if IS_VIRTUAL is 0)
+ or with virtual table offset ADDRESS (if IS_VIRTUAL is 1).
+ This is the opposite of cplus_method_ptr_to_value. */
+void cplus_make_method_ptr (struct type *type, gdb_byte *CONTENTS,
+ CORE_ADDR address, int is_virtual);
/* Determine if we are currently in a C++ thunk. If so, get the address
of the routine we are thunking to and continue to there instead. */
@@ -195,8 +194,8 @@ struct cp_abi_ops
const bfd_byte *valaddr, CORE_ADDR address);
void (*print_method_ptr) (const gdb_byte *contents, struct type *type,
struct ui_file *stream);
- int (*method_ptr_size) (void);
- void (*make_method_ptr) (gdb_byte *, CORE_ADDR, int);
+ int (*method_ptr_size) (struct type *);
+ void (*make_method_ptr) (struct type *, gdb_byte *, CORE_ADDR, int);
struct value * (*method_ptr_to_value) (struct value **, struct value *);
CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
int (*pass_by_reference) (struct type *type);
Index: gdb-head/gdb/cp-valprint.c
===================================================================
--- gdb-head.orig/gdb/cp-valprint.c
+++ gdb-head/gdb/cp-valprint.c
@@ -538,16 +538,16 @@ cp_find_class_member (struct type **doma
}
void
-cp_print_class_member (const gdb_byte *valaddr, struct type *domain,
+cp_print_class_member (const gdb_byte *valaddr, struct type *type,
struct ui_file *stream, char *prefix)
{
/* VAL is a byte offset into the structure type DOMAIN.
Find the name of the field for that offset and
print it. */
+ struct type *domain = TYPE_DOMAIN_TYPE (type);
+ LONGEST val = extract_signed_integer (valaddr, TYPE_LENGTH (type));
unsigned int fieldno;
- LONGEST val = unpack_long (builtin_type_long, valaddr);
-
/* Pointers to data members are usually byte offsets into an object.
Because a data member can have offset zero, and a NULL pointer to
member must be distinct from any valid non-NULL pointer to
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -189,9 +189,7 @@ c_val_print (struct type *type, const gd
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
break;
}
- cp_print_class_member (valaddr + embedded_offset,
- TYPE_DOMAIN_TYPE (type),
- stream, "&");
+ cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
break;
case TYPE_CODE_METHODPTR:
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -666,7 +666,7 @@ lookup_methodptr_type (struct type *to_t
mtype = alloc_type (TYPE_OBJFILE (to_type));
TYPE_TARGET_TYPE (mtype) = to_type;
TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
- TYPE_LENGTH (mtype) = cplus_method_ptr_size ();
+ TYPE_LENGTH (mtype) = cplus_method_ptr_size (to_type);
TYPE_CODE (mtype) = TYPE_CODE_METHODPTR;
return mtype;
}
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -45,6 +45,21 @@ gnuv3_is_operator_name (const char *name
}
+/* Determine architecture of class DOMAIN. This architecture is used
+ to query C++ ABI details (types, method pointer layout, etc.).
+
+ Note that we assume DOMAIN must have been allocated with an OBJFILE;
+ GDB does not provide any built-in class types. Thus we use the
+ architecture of that OBJFILE to define the C++ ABI. */
+
+static struct gdbarch *
+get_class_arch (struct type *domain)
+{
+ gdb_assert (TYPE_CODE (domain) == TYPE_CODE_CLASS);
+ gdb_assert (TYPE_OBJFILE (domain) != NULL);
+ return get_objfile_arch (TYPE_OBJFILE (domain));
+}
+
/* To help us find the components of a vtable, we build ourselves a
GDB type object representing the vtable structure. Following the
V3 ABI, it goes something like this:
@@ -176,10 +191,9 @@ build_gdb_vtable_type (struct gdbarch *a
gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
(i.e., where objects' virtual table pointers point). */
static int
-vtable_address_point_offset (void)
+vtable_address_point_offset (struct gdbarch *gdbarch)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
/ TARGET_CHAR_BIT);
@@ -190,8 +204,8 @@ static struct type *
gnuv3_rtti_type (struct value *value,
int *full_p, int *top_p, int *using_enc_p)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct gdbarch *gdbarch;
+ struct type *vtable_type;
struct type *values_type = check_typedef (value_type (value));
CORE_ADDR vtable_address;
struct value *vtable;
@@ -208,6 +222,16 @@ gnuv3_rtti_type (struct value *value,
if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
return NULL;
+ /* This routine may be called for Java types that do not have
+ a proper objfile. Just return NULL for those. */
+ if (!TYPE_OBJFILE (values_type)
+ || !TYPE_OBJFILE (values_type)->obfd)
+ return NULL;
+
+ /* Determine architecture. */
+ gdbarch = get_class_arch (values_type);
+ vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+
/* If we can't find the virtual table pointer for values_type, we
can't find the RTTI. */
values_type_vptr_fieldno = get_vptr_fieldno (values_type,
@@ -229,8 +253,9 @@ gnuv3_rtti_type (struct value *value,
}
vtable_address
= value_as_address (value_field (value, values_type_vptr_fieldno));
- vtable = value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
+ vtable
+ = value_at_lazy (vtable_type,
+ vtable_address - vtable_address_point_offset (gdbarch));
/* Find the linker symbol for this vtable. */
vtable_symbol
@@ -282,10 +307,9 @@ gnuv3_rtti_type (struct value *value,
vtable type for this architecture. */
static struct value *
-gnuv3_get_vtable (struct value *container)
+gnuv3_get_vtable (struct gdbarch *gdbarch, struct value *container)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
struct type *vtable_pointer_type;
struct value *vtable_pointer;
CORE_ADDR vtable_pointer_address, vtable_address;
@@ -311,17 +335,17 @@ gnuv3_get_vtable (struct value *containe
/* Correct it to point at the start of the virtual table, rather
than the address point. */
return value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
+ vtable_address - vtable_address_point_offset (gdbarch));
}
/* Return a function pointer for CONTAINER's VTABLE_INDEX'th virtual
function, of type FNTYPE. */
static struct value *
-gnuv3_get_virtual_fn (struct value *container, struct type *fntype,
- int vtable_index)
+gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
+ struct type *fntype, int vtable_index)
{
- struct value *vtable = gnuv3_get_vtable (container);
+ struct value *vtable = gnuv3_get_vtable (gdbarch, container);
struct value *vfn;
/* Fetch the appropriate function pointer from the vtable. */
@@ -333,7 +357,7 @@ gnuv3_get_virtual_fn (struct value *cont
(i.e. points to the descriptor). We don't need to scale the index
by the size of a function descriptor; GCC does that before outputing
debug information. */
- if (gdbarch_vtable_function_descriptors (current_gdbarch))
+ if (gdbarch_vtable_function_descriptors (gdbarch))
vfn = value_addr (vfn);
/* Cast the function pointer to the appropriate type. */
@@ -351,18 +375,22 @@ gnuv3_virtual_fn_field (struct value **v
struct type *vfn_base, int offset)
{
struct type *values_type = check_typedef (value_type (*value_p));
+ struct gdbarch *gdbarch;
/* Some simple sanity checks. */
if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
error (_("Only classes can have virtual functions."));
+ /* Determine architecture. */
+ gdbarch = get_class_arch (values_type);
+
/* Cast our value to the base class which defines this virtual
function. This takes care of any necessary `this'
adjustments. */
if (vfn_base != values_type)
*value_p = value_cast (vfn_base, *value_p);
- return gnuv3_get_virtual_fn (*value_p, TYPE_FN_FIELD_TYPE (f, j),
+ return gnuv3_get_virtual_fn (gdbarch, *value_p, TYPE_FN_FIELD_TYPE (f, j),
TYPE_FN_FIELD_VOFFSET (f, j));
}
@@ -377,8 +405,9 @@ static int
gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
CORE_ADDR address)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct gdbarch *gdbarch;
+ struct type *vtable_type;
+ struct type *ptr_type;
struct value *vtable;
struct type *vbasetype;
struct value *offset_val, *vbase_array;
@@ -386,6 +415,11 @@ gnuv3_baseclass_offset (struct type *typ
long int cur_base_offset, base_offset;
int vbasetype_vptr_fieldno;
+ /* Determine architecture. */
+ gdbarch = get_class_arch (type);
+ vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+ ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
/* If it isn't a virtual base, this is easy. The offset is in the
type definition. */
if (!BASETYPE_VIA_VIRTUAL (type, index))
@@ -397,14 +431,13 @@ gnuv3_baseclass_offset (struct type *typ
complete inheritance graph based on the debug info. Neither is
worthwhile. */
cur_base_offset = TYPE_BASECLASS_BITPOS (type, index) / 8;
- if (cur_base_offset >= - vtable_address_point_offset ())
+ if (cur_base_offset >= - vtable_address_point_offset (gdbarch))
error (_("Expected a negative vbase offset (old compiler?)"));
- cur_base_offset = cur_base_offset + vtable_address_point_offset ();
- if ((- cur_base_offset) % TYPE_LENGTH (builtin_type_void_data_ptr) != 0)
+ cur_base_offset = cur_base_offset + vtable_address_point_offset (gdbarch);
+ if ((- cur_base_offset) % TYPE_LENGTH (ptr_type) != 0)
error (_("Misaligned vbase offset."));
- cur_base_offset = cur_base_offset
- / ((int) TYPE_LENGTH (builtin_type_void_data_ptr));
+ cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type));
/* We're now looking for the cur_base_offset'th entry (negative index)
in the vcall_and_vbase_offsets array. We used to cast the object to
@@ -425,11 +458,11 @@ gnuv3_baseclass_offset (struct type *typ
error (_("Illegal vptr offset in class %s"),
TYPE_NAME (vbasetype) ? TYPE_NAME (vbasetype) : "<unknown>");
- vtable_address = value_as_address (value_at_lazy (builtin_type_void_data_ptr,
- address));
- vtable = value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
- offset_val = value_from_longest(builtin_type_int32, cur_base_offset);
+ vtable_address = value_as_address (value_at_lazy (ptr_type, address));
+ vtable
+ = value_at_lazy (vtable_type,
+ vtable_address - vtable_address_point_offset (gdbarch));
+ offset_val = value_from_longest (builtin_type_int32, cur_base_offset);
vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
base_offset = value_as_long (value_subscript (vbase_array, offset_val));
return base_offset;
@@ -496,6 +529,9 @@ gnuv3_print_method_ptr (const gdb_byte *
struct type *type,
struct ui_file *stream)
{
+ struct gdbarch *gdbarch;
+ struct type *funcptr_type;
+ struct type *offset_type;
CORE_ADDR ptr_value;
LONGEST adjustment;
struct type *domain;
@@ -503,13 +539,17 @@ gnuv3_print_method_ptr (const gdb_byte *
domain = TYPE_DOMAIN_TYPE (type);
+ /* Determine architecture. */
+ gdbarch = get_class_arch (domain);
+ funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+ offset_type = builtin_type (gdbarch)->builtin_long;
+
/* Extract the pointer to member. */
- ptr_value = extract_typed_address (contents, builtin_type_void_func_ptr);
- contents += TYPE_LENGTH (builtin_type_void_func_ptr);
- adjustment = extract_signed_integer (contents,
- TYPE_LENGTH (builtin_type_long));
+ ptr_value = extract_typed_address (contents, funcptr_type);
+ contents += TYPE_LENGTH (funcptr_type);
+ adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
- if (!gdbarch_vbit_in_delta (current_gdbarch))
+ if (!gdbarch_vbit_in_delta (gdbarch))
{
vbit = ptr_value & 1;
ptr_value = ptr_value ^ vbit;
@@ -536,7 +576,7 @@ gnuv3_print_method_ptr (const gdb_byte *
/* It's a virtual table offset, maybe in this class. Search
for a field with the correct vtable offset. First convert it
to an index, as used in TYPE_FN_FIELD_VOFFSET. */
- voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
+ voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
physname = gnuv3_find_method_in (domain, voffset, adjustment);
@@ -575,17 +615,22 @@ gnuv3_print_method_ptr (const gdb_byte *
/* GNU v3 implementation of cplus_method_ptr_size. */
static int
-gnuv3_method_ptr_size (void)
+gnuv3_method_ptr_size (struct type *type)
{
- return 2 * TYPE_LENGTH (builtin_type_void_data_ptr);
+ struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+ struct gdbarch *gdbarch = get_class_arch (domain_type);
+ return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
}
/* GNU v3 implementation of cplus_make_method_ptr. */
static void
-gnuv3_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
+ CORE_ADDR value, int is_virtual)
{
- int size = TYPE_LENGTH (builtin_type_void_data_ptr);
+ struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+ struct gdbarch *gdbarch = get_class_arch (domain_type);
+ int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
/* FIXME drow/2006-12-24: The adjustment of "this" is currently
always zero, since the method pointer is of the correct type.
@@ -596,7 +641,7 @@ gnuv3_make_method_ptr (gdb_byte *content
support for adjusting pointers to members when casting them -
not currently supported by GDB. */
- if (!gdbarch_vbit_in_delta (current_gdbarch))
+ if (!gdbarch_vbit_in_delta (gdbarch))
{
store_unsigned_integer (contents, size, value | is_virtual);
store_unsigned_integer (contents + size, size, 0);
@@ -613,24 +658,30 @@ gnuv3_make_method_ptr (gdb_byte *content
static struct value *
gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
{
+ struct gdbarch *gdbarch;
const gdb_byte *contents = value_contents (method_ptr);
CORE_ADDR ptr_value;
- struct type *final_type, *method_type;
+ struct type *domain_type, *final_type, *method_type;
+ struct type *funcptr_type, *offset_type;
LONGEST adjustment;
struct value *adjval;
int vbit;
- final_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
- final_type = lookup_pointer_type (final_type);
+ domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
+ final_type = lookup_pointer_type (domain_type);
method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));
- ptr_value = extract_typed_address (contents, builtin_type_void_func_ptr);
- contents += TYPE_LENGTH (builtin_type_void_func_ptr);
- adjustment = extract_signed_integer (contents,
- TYPE_LENGTH (builtin_type_long));
+ /* Determine architecture. */
+ gdbarch = get_class_arch (domain_type);
+ funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+ offset_type = builtin_type (gdbarch)->builtin_long;
+
+ ptr_value = extract_typed_address (contents, funcptr_type);
+ contents += TYPE_LENGTH (funcptr_type);
+ adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
- if (!gdbarch_vbit_in_delta (current_gdbarch))
+ if (!gdbarch_vbit_in_delta (gdbarch))
{
vbit = ptr_value & 1;
ptr_value = ptr_value ^ vbit;
@@ -660,15 +711,17 @@ gnuv3_method_ptr_to_value (struct value
You can provoke this case by casting a Base::* to a Derived::*, for
instance. */
- *this_p = value_cast (builtin_type_void_data_ptr, *this_p);
- adjval = value_from_longest (builtin_type_long, adjustment);
+ *this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);
+ adjval = value_from_longest (offset_type, adjustment);
*this_p = value_ptradd (*this_p, adjval);
*this_p = value_cast (final_type, *this_p);
if (vbit)
{
- LONGEST voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
- return gnuv3_get_virtual_fn (value_ind (*this_p), method_type, voffset);
+ LONGEST voffset;
+ voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
+ return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p),
+ method_type, voffset);
}
else
return value_from_pointer (lookup_pointer_type (method_type), ptr_value);
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -466,7 +466,7 @@ value_cast (struct type *type, struct va
&& value_as_long (arg2) == 0)
{
struct value *result = allocate_value (type);
- cplus_make_method_ptr (value_contents_writeable (result), 0, 0);
+ cplus_make_method_ptr (type, value_contents_writeable (result), 0, 0);
return result;
}
else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT
@@ -2612,7 +2612,8 @@ value_struct_elt_for_reference (struct t
{
result = allocate_value
(lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
- cplus_make_method_ptr (value_contents_writeable (result),
+ cplus_make_method_ptr (value_type (result),
+ value_contents_writeable (result),
TYPE_FN_FIELD_VOFFSET (f, j), 1);
}
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -2635,7 +2636,8 @@ value_struct_elt_for_reference (struct t
else
{
result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
- cplus_make_method_ptr (value_contents_writeable (result),
+ cplus_make_method_ptr (value_type (result),
+ value_contents_writeable (result),
VALUE_ADDRESS (v), 0);
}
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (21 preceding siblings ...)
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
` (16 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-adaaddr --]
[-- Type: text/plain, Size: 2591 bytes --]
Hello,
this eliminates a hard-coded use of builtin_type_void_data_ptr in
ada_val_print_1.
This use occurs in code to work around some GNAT versions that encode
System.Address as an integer instead of pointer type. The following
patch uses the gdbarch associates with the objfile where the type was
defined to determine the pointer type to use for this work around.
This is possible since for all types without objfile (i.e. builtin
types), the work-around is not required as GDB installs them as
pointer types to start with.
Bye,
Ulrich
ChangeLog:
* ada-valprint.c: Include "objfiles.h".
(ada_val_print_1): Use the gdbarch associated with the objfile whether
a System.Address type is defined to retrieve the proper pointer type
to use to print it.
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -33,6 +33,7 @@
#include "c-lang.h"
#include "infcall.h"
#include "exceptions.h"
+#include "objfiles.h"
/* Encapsulates arguments to ada_val_print. */
struct ada_val_print_args
@@ -792,18 +793,27 @@ ada_val_print_1 (struct type *type, cons
{
print_scalar_formatted (valaddr, type, format, 0, stream);
}
- else if (ada_is_system_address_type (type))
+ else if (ada_is_system_address_type (type)
+ && TYPE_OBJFILE (type) != NULL)
{
/* FIXME: We want to print System.Address variables using
the same format as for any access type. But for some
reason GNAT encodes the System.Address type as an int,
so we have to work-around this deficiency by handling
- System.Address values as a special case. */
+ System.Address values as a special case.
+
+ We do this only for System.Address types defined in an
+ objfile. For the built-in version of System.Address we
+ have installed the proper type to begin with. */
+
+ struct gdbarch *gdbarch = get_objfile_arch (TYPE_OBJFILE (type));
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
fprintf_filtered (stream, "(");
type_print (type, "", stream, -1);
fprintf_filtered (stream, ") ");
fputs_filtered (paddress (extract_typed_address
- (valaddr, builtin_type_void_data_ptr)),
+ (valaddr, ptr_type)),
stream);
}
else
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (27 preceding siblings ...)
2008-08-31 17:53 ` [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
` (10 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-coerceenum --]
[-- Type: text/plain, Size: 3339 bytes --]
Hello,
this patch removes the coerce_enum and coerce_number routines.
coerce_number is used solely in value_logical_not; but the rest
of this routine already handles enum types correctly, so the
call to coerce_enum implicit in coerce_number is not required.
Similarly, the sole two remaining call sites of coerce_enum,
value_x_binop and value_x_unop pass their arguments to
call_function_by_hand, which likewise handles enums correctly.
Bye,
Ulrich
ChangeLog:
* value.h (coerce_enum, coerce_number): Remove prototypes.
* value.c (coerce_enum, coerce_number): Remove.
* valarith.c (value_x_binop): Do not call coerce_enum.
(value_x_unop): Likewise.
(value_logical_not): Call coerce_array instead of coerce_number.
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -354,8 +354,6 @@ value_x_binop (struct value *arg1, struc
arg1 = coerce_ref (arg1);
arg2 = coerce_ref (arg2);
- arg1 = coerce_enum (arg1);
- arg2 = coerce_enum (arg2);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
@@ -515,7 +513,6 @@ value_x_unop (struct value *arg1, enum e
int static_memfuncp, nargs;
arg1 = coerce_ref (arg1);
- arg1 = coerce_enum (arg1);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
@@ -1282,7 +1279,7 @@ value_logical_not (struct value *arg1)
const gdb_byte *p;
struct type *type1;
- arg1 = coerce_number (arg1);
+ arg1 = coerce_array (arg1);
type1 = check_typedef (value_type (arg1));
if (TYPE_CODE (type1) == TYPE_CODE_FLT)
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -1700,22 +1700,6 @@ coerce_array (struct value *arg)
arg = value_coerce_function (arg);
return arg;
}
-
-struct value *
-coerce_number (struct value *arg)
-{
- arg = coerce_array (arg);
- arg = coerce_enum (arg);
- return arg;
-}
-
-struct value *
-coerce_enum (struct value *arg)
-{
- if (TYPE_CODE (check_typedef (value_type (arg))) == TYPE_CODE_ENUM)
- arg = value_cast (builtin_type_unsigned_int, arg);
- return arg;
-}
\f
/* Return true if the function returning the specified type is using
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -230,17 +230,11 @@ extern short *deprecated_value_regnum_ha
extern struct value *coerce_ref (struct value *value);
/* If ARG is an array, convert it to a pointer.
- If ARG is an enum, convert it to an integer.
If ARG is a function, convert it to a function pointer.
References are dereferenced. */
extern struct value *coerce_array (struct value *value);
-extern struct value *coerce_number (struct value *value);
-
-/* If ARG is an enum, convert it to an integer. */
-
-extern struct value *coerce_enum (struct value *value);
/* Internal variables (variables for convenience of use of debugger)
are recorded as a chain of these structures. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (25 preceding siblings ...)
2008-08-31 17:53 ` [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type uweigand
` (12 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-solib --]
[-- Type: text/plain, Size: 7103 bytes --]
Hello,
just like the bsd-uthread patch, this patch changes every instance of
builtin_type_void_data_ptr in solib-related code to use target_gdbarch
associated builtin types instead.
Bye,
Ulrich
ChangeLog:
* solib-svr4.c (LM_ADDR_FROM_LINK_MAP): Use builtin types of
target_gdbarch instead of builtin_type_void_data_ptr.
(LM_DYNAMIC_FROM_LINK_MAP, LM_NEXT, LM_NAME,
IGNORE_FIRST_LINK_MAP_ENTRY, scan_dyntag, elf_locate_base,
solib_svr4_r_map, solib_svr4_r_brk, solib_svr4_r_ldsomap,
open_symbol_file_object): Likewise.
* nto-tdep.c (LM_ADDR): Likewise.
Index: gdb-head/gdb/nto-tdep.c
===================================================================
--- gdb-head.orig/gdb/nto-tdep.c
+++ gdb-head/gdb/nto-tdep.c
@@ -280,10 +280,10 @@ LM_ADDR (struct so_list *so)
if (so->lm_info->l_addr == (CORE_ADDR)-1)
{
struct link_map_offsets *lmo = nto_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
so->lm_info->l_addr =
- extract_typed_address (so->lm_info->lm + lmo->l_addr_offset,
- builtin_type_void_data_ptr);
+ extract_typed_address (so->lm_info->lm + lmo->l_addr_offset, ptr_type);
}
return so->lm_info->l_addr;
}
Index: gdb-head/gdb/solib-svr4.c
===================================================================
--- gdb-head.orig/gdb/solib-svr4.c
+++ gdb-head/gdb/solib-svr4.c
@@ -140,9 +140,10 @@ static CORE_ADDR
LM_ADDR_FROM_LINK_MAP (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
return extract_typed_address (so->lm_info->lm + lmo->l_addr_offset,
- builtin_type_void_data_ptr);
+ ptr_type);
}
static int
@@ -157,9 +158,10 @@ static CORE_ADDR
LM_DYNAMIC_FROM_LINK_MAP (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
return extract_typed_address (so->lm_info->lm + lmo->l_ld_offset,
- builtin_type_void_data_ptr);
+ ptr_type);
}
static CORE_ADDR
@@ -236,24 +238,27 @@ static CORE_ADDR
LM_NEXT (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
return extract_typed_address (so->lm_info->lm + lmo->l_next_offset,
- builtin_type_void_data_ptr);
+ ptr_type);
}
static CORE_ADDR
LM_NAME (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
return extract_typed_address (so->lm_info->lm + lmo->l_name_offset,
- builtin_type_void_data_ptr);
+ ptr_type);
}
static int
IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
@@ -261,7 +266,7 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_l
return 0;
return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
- builtin_type_void_data_ptr) == 0;
+ ptr_type) == 0;
}
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
@@ -566,13 +571,14 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
entry. */
if (ptr)
{
+ struct type *ptr_type;
gdb_byte ptr_buf[8];
CORE_ADDR ptr_addr;
+ ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
- dyn_ptr = extract_typed_address (ptr_buf,
- builtin_type_void_data_ptr);
+ dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
*ptr = dyn_ptr;
}
return 1;
@@ -672,14 +678,15 @@ elf_locate_base (void)
if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr))
{
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
gdb_byte *pbuf;
- int pbuf_size = TYPE_LENGTH (builtin_type_void_data_ptr);
+ int pbuf_size = TYPE_LENGTH (ptr_type);
pbuf = alloca (pbuf_size);
/* DT_MIPS_RLD_MAP contains a pointer to the address
of the dynamic link structure. */
if (target_read_memory (dyn_ptr, pbuf, pbuf_size))
return 0;
- return extract_typed_address (pbuf, builtin_type_void_data_ptr);
+ return extract_typed_address (pbuf, ptr_type);
}
/* Find DT_DEBUG. */
@@ -763,9 +770,9 @@ static CORE_ADDR
solib_svr4_r_map (void)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
- return read_memory_typed_address (debug_base + lmo->r_map_offset,
- builtin_type_void_data_ptr);
+ return read_memory_typed_address (debug_base + lmo->r_map_offset, ptr_type);
}
/* Find r_brk from the inferior's debug base. */
@@ -774,9 +781,9 @@ static CORE_ADDR
solib_svr4_r_brk (void)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
- return read_memory_typed_address (debug_base + lmo->r_brk_offset,
- builtin_type_void_data_ptr);
+ return read_memory_typed_address (debug_base + lmo->r_brk_offset, ptr_type);
}
/* Find the link map for the dynamic linker (if it is not in the
@@ -786,6 +793,7 @@ static CORE_ADDR
solib_svr4_r_ldsomap (void)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
ULONGEST version;
/* Check version, and return zero if `struct r_debug' doesn't have
@@ -796,7 +804,7 @@ solib_svr4_r_ldsomap (void)
return 0;
return read_memory_typed_address (debug_base + lmo->r_ldsomap_offset,
- builtin_type_void_data_ptr);
+ ptr_type);
}
/*
@@ -829,7 +837,8 @@ open_symbol_file_object (void *from_ttyp
int errcode;
int from_tty = *(int *)from_ttyp;
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- int l_name_size = TYPE_LENGTH (builtin_type_void_data_ptr);
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ int l_name_size = TYPE_LENGTH (ptr_type);
gdb_byte *l_name_buf = xmalloc (l_name_size);
struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
@@ -851,7 +860,7 @@ open_symbol_file_object (void *from_ttyp
read_memory (lm + lmo->l_name_offset, l_name_buf, l_name_size);
/* Convert the address to host format. */
- l_name = extract_typed_address (l_name_buf, builtin_type_void_data_ptr);
+ l_name = extract_typed_address (l_name_buf, ptr_type);
/* Free l_name_buf. */
do_cleanups (cleanups);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (29 preceding siblings ...)
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c uweigand
` (8 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-javabase --]
[-- Type: text/plain, Size: 2478 bytes --]
Hello,
another preparation to removing LA_BOOL_TYPE: the Java language did
not provide its own language_arch_info function (but was reusing the
C version). This patch provides a separate java_language_arch_info.
Bye,
Ulrich
ChangeLog:
* jv-lang.c (enum java_primitive_types): New type.
(java_language_arch_info): New function.
(java_language): Use it instead of c_language_arch_info.
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -1040,6 +1040,48 @@ const struct op_print java_op_print_tab[
{NULL, 0, 0, 0}
};
+enum java_primitive_types
+{
+ java_primitive_type_int,
+ java_primitive_type_short,
+ java_primitive_type_long,
+ java_primitive_type_byte,
+ java_primitive_type_boolean,
+ java_primitive_type_char,
+ java_primitive_type_float,
+ java_primitive_type_double,
+ java_primitive_type_void,
+ nr_java_primitive_types
+};
+
+void
+java_language_arch_info (struct gdbarch *gdbarch,
+ struct language_arch_info *lai)
+{
+ lai->string_char_type = java_char_type;
+ lai->primitive_type_vector
+ = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_java_primitive_types + 1,
+ struct type *);
+ lai->primitive_type_vector [java_primitive_type_int]
+ = java_int_type;
+ lai->primitive_type_vector [java_primitive_type_short]
+ = java_short_type;
+ lai->primitive_type_vector [java_primitive_type_long]
+ = java_long_type;
+ lai->primitive_type_vector [java_primitive_type_byte]
+ = java_byte_type;
+ lai->primitive_type_vector [java_primitive_type_boolean]
+ = java_boolean_type;
+ lai->primitive_type_vector [java_primitive_type_char]
+ = java_char_type;
+ lai->primitive_type_vector [java_primitive_type_float]
+ = java_float_type;
+ lai->primitive_type_vector [java_primitive_type_double]
+ = java_double_type;
+ lai->primitive_type_vector [java_primitive_type_void]
+ = java_void_type;
+}
+
const struct exp_descriptor exp_descriptor_java =
{
print_subexp_standard,
@@ -1078,7 +1120,7 @@ const struct language_defn java_language
0, /* String lower bound */
default_word_break_characters,
default_make_symbol_completion_list,
- c_language_arch_info,
+ java_language_arch_info,
default_print_array_index,
default_pass_by_reference,
LANG_MAGIC
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (17 preceding siblings ...)
2008-08-31 17:52 ` [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 17:53 ` [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit uweigand
` (20 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-final --]
[-- Type: text/plain, Size: 8684 bytes --]
Hello,
that's it -- after all preceding patches in this series are applied,
no further use of the builtin_type_ macros remains in GDB.
This patch finally deletes those macros.
Also, the builtin_f_type and builtin_m2_type types are now only used
in language-specific code, so this patch moves those to the appropriate
language-specific header files.
Bye,
Ulrich
ChangeLog:
* gdbtypes.h (builtin_type_void_data_ptr, builtin_type_void_func_ptr,
builtin_type_CORE_ADDR, builtin_type_char, builtin_type_short,
builtin_type_int, builtin_type_long, builtin_type_signed_char,
builtin_type_unsigned_char, builtin_type_unsigned_short,
builtin_type_unsigned_int, builtin_type_unsigned_long,
builtin_type_float, builtin_type_double, builtin_type_long_double,
builtin_type_complex, builtin_type_double_complex, builtin_type_string,
builtin_type_bool, builtin_type_long_long,
builtin_type_unsigned_long_long): Remove macros.
(builtin_type_f_character, builtin_type_f_integer,
builtin_type_f_integer_s2, builtin_type_f_logical,
builtin_type_f_logical_s1, builtin_type_f_logical_s2,
builtin_type_f_real, builtin_type_f_real_s8, builtin_type_f_real_s16,
builtin_type_f_complex_s8, builtin_type_f_complex_s16,
builtin_type_f_complex_s32): Likewise.
(builtin_type_m2_char, builtin_type_m2_int, builtin_type_m2_card,
builtin_type_m2_real, builtin_type_m2_bool): Likewise.
(struct builtin_f_type, builtin_f_type): Move to f-lang.h.
(struct builtin_m2_type, builtin_m2_type): Move to m2-lang.h.
* f-lang.h (struct builtin_f_type, builtin_f_type): Move here.
* m2-lang.h (struct builtin_m2_type, builtin_m2_type): Move here.
Index: gdb-head/gdb/f-lang.h
===================================================================
--- gdb-head.orig/gdb/f-lang.h
+++ gdb-head/gdb/f-lang.h
@@ -104,3 +104,27 @@ extern int f77_get_dynamic_lowerbound (s
extern void f77_get_dynamic_array_length (struct type *);
extern int calc_f77_array_dims (struct type *);
+
+
+/* Fortran (F77) types */
+
+struct builtin_f_type
+{
+ struct type *builtin_character;
+ struct type *builtin_integer;
+ struct type *builtin_integer_s2;
+ struct type *builtin_logical;
+ struct type *builtin_logical_s1;
+ struct type *builtin_logical_s2;
+ struct type *builtin_real;
+ struct type *builtin_real_s8;
+ struct type *builtin_real_s16;
+ struct type *builtin_complex_s8;
+ struct type *builtin_complex_s16;
+ struct type *builtin_complex_s32;
+ struct type *builtin_void;
+};
+
+/* Return the Fortran type table for the specified architecture. */
+extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch);
+
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -1005,50 +1005,6 @@ struct builtin_type
/* Return the type table for the specified architecture. */
extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
-/* Compatibility macros to access types for the current architecture. */
-#define builtin_type_void_data_ptr \
- (builtin_type (current_gdbarch)->builtin_data_ptr)
-#define builtin_type_void_func_ptr \
- (builtin_type (current_gdbarch)->builtin_func_ptr)
-#define builtin_type_CORE_ADDR \
- (builtin_type (current_gdbarch)->builtin_core_addr)
-#define builtin_type_char \
- (builtin_type (current_gdbarch)->builtin_char)
-#define builtin_type_short \
- (builtin_type (current_gdbarch)->builtin_short)
-#define builtin_type_int \
- (builtin_type (current_gdbarch)->builtin_int)
-#define builtin_type_long \
- (builtin_type (current_gdbarch)->builtin_long)
-#define builtin_type_signed_char \
- (builtin_type (current_gdbarch)->builtin_signed_char)
-#define builtin_type_unsigned_char \
- (builtin_type (current_gdbarch)->builtin_unsigned_char)
-#define builtin_type_unsigned_short \
- (builtin_type (current_gdbarch)->builtin_unsigned_short)
-#define builtin_type_unsigned_int \
- (builtin_type (current_gdbarch)->builtin_unsigned_int)
-#define builtin_type_unsigned_long \
- (builtin_type (current_gdbarch)->builtin_unsigned_long)
-#define builtin_type_float \
- (builtin_type (current_gdbarch)->builtin_float)
-#define builtin_type_double \
- (builtin_type (current_gdbarch)->builtin_double)
-#define builtin_type_long_double \
- (builtin_type (current_gdbarch)->builtin_long_double)
-#define builtin_type_complex \
- (builtin_type (current_gdbarch)->builtin_complex)
-#define builtin_type_double_complex \
- (builtin_type (current_gdbarch)->builtin_double_complex)
-#define builtin_type_string \
- (builtin_type (current_gdbarch)->builtin_string)
-#define builtin_type_bool \
- (builtin_type (current_gdbarch)->builtin_bool)
-#define builtin_type_long_long \
- (builtin_type (current_gdbarch)->builtin_long_long)
-#define builtin_type_unsigned_long_long \
- (builtin_type (current_gdbarch)->builtin_unsigned_long_long)
-
/* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
is for when an architecture needs to describe a register that has
@@ -1108,82 +1064,6 @@ extern struct type *builtin_type_true_un
extern struct type *builtin_type_error;
-/* Modula-2 types */
-
-struct builtin_m2_type
-{
- struct type *builtin_char;
- struct type *builtin_int;
- struct type *builtin_card;
- struct type *builtin_real;
- struct type *builtin_bool;
-};
-
-/* Return the Modula-2 type table for the specified architecture. */
-extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture. */
-#define builtin_type_m2_char \
- (builtin_m2_type (current_gdbarch)->builtin_char)
-#define builtin_type_m2_int \
- (builtin_m2_type (current_gdbarch)->builtin_int)
-#define builtin_type_m2_card \
- (builtin_m2_type (current_gdbarch)->builtin_card)
-#define builtin_type_m2_real \
- (builtin_m2_type (current_gdbarch)->builtin_real)
-#define builtin_type_m2_bool \
- (builtin_m2_type (current_gdbarch)->builtin_bool)
-
-
-/* Fortran (F77) types */
-
-struct builtin_f_type
-{
- struct type *builtin_character;
- struct type *builtin_integer;
- struct type *builtin_integer_s2;
- struct type *builtin_logical;
- struct type *builtin_logical_s1;
- struct type *builtin_logical_s2;
- struct type *builtin_real;
- struct type *builtin_real_s8;
- struct type *builtin_real_s16;
- struct type *builtin_complex_s8;
- struct type *builtin_complex_s16;
- struct type *builtin_complex_s32;
- struct type *builtin_void;
-};
-
-/* Return the Fortran type table for the specified architecture. */
-extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture. */
-#define builtin_type_f_character \
- (builtin_f_type (current_gdbarch)->builtin_character)
-#define builtin_type_f_integer \
- (builtin_f_type (current_gdbarch)->builtin_integer)
-#define builtin_type_f_integer_s2 \
- (builtin_f_type (current_gdbarch)->builtin_integer_s2)
-#define builtin_type_f_logical \
- (builtin_f_type (current_gdbarch)->builtin_logical)
-#define builtin_type_f_logical_s1 \
- (builtin_f_type (current_gdbarch)->builtin_logical_s1)
-#define builtin_type_f_logical_s2 \
- (builtin_f_type (current_gdbarch)->builtin_logical_s2)
-#define builtin_type_f_real \
- (builtin_f_type (current_gdbarch)->builtin_real)
-#define builtin_type_f_real_s8 \
- (builtin_f_type (current_gdbarch)->builtin_real_s8)
-#define builtin_type_f_real_s16 \
- (builtin_f_type (current_gdbarch)->builtin_real_s16)
-#define builtin_type_f_complex_s8 \
- (builtin_f_type (current_gdbarch)->builtin_complex_s8)
-#define builtin_type_f_complex_s16 \
- (builtin_f_type (current_gdbarch)->builtin_complex_s16)
-#define builtin_type_f_complex_s32 \
- (builtin_f_type (current_gdbarch)->builtin_complex_s32)
-
-
/* RTTI for C++ */
/* extern struct type *builtin_type_cxx_typeinfo; */
Index: gdb-head/gdb/m2-lang.h
===================================================================
--- gdb-head.orig/gdb/m2-lang.h
+++ gdb-head/gdb/m2-lang.h
@@ -35,3 +35,18 @@ extern int m2_val_print (struct type *,
extern int get_long_set_bounds (struct type *type, LONGEST *low,
LONGEST *high);
+
+/* Modula-2 types */
+
+struct builtin_m2_type
+{
+ struct type *builtin_char;
+ struct type *builtin_int;
+ struct type *builtin_card;
+ struct type *builtin_real;
+ struct type *builtin_bool;
+};
+
+/* Return the Modula-2 type table for the specified architecture. */
+extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
+
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][00/37] Eliminate builtin_type_ macros
@ 2008-08-31 17:53 uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
` (39 more replies)
0 siblings, 40 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
Hello,
one of the last remaining "implicit" uses of current_gdbarch is the
builtin_type_ macros. This patch set completely removes those macros.
I've attempted to not simply replace those types with explict uses of
current_gdbarch, but instead choose the proper architecture to use:
- I've added a gdbarch pointer to struct expression, and used this
per-expression arch throughout expression parsing and evaluation.
- I've converted some types (like builtin_void_type) back to be
platform-neutral, so they can be freely used throughout GDB.
- In many cases, an existing per-frame or per-objfile arch was available
(or could be made available) and should be used.
- Target-specific code should use target_gdbarch.
- In a very small number of case, current_gdbarch remains for now.
Each of the following patches contains a more specific explanation.
Combination of all 37 patches tested on amd64-linux, s390-ibm-linux,
s390x-ibm-linux, powerpc-linux, powerpc64-linux, and spu-elf with no
regressions. Also, compile-tested with --enable-targets=all (each
patch by itself).
I'd be interested in particular in feedback from the Ada maintainers
on the Ada-related changes in this patch-set.
What do you think?
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] 98+ messages in thread
* [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (31 preceding siblings ...)
2008-08-31 17:53 ` [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c uweigand
@ 2008-08-31 17:53 ` uweigand
2008-08-31 18:12 ` [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c uweigand
` (6 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 17:53 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-objc --]
[-- Type: text/plain, Size: 4360 bytes --]
Hello,
this replaces a couple of builtin_type_ uses in Objective-C expression
evaluation by types associated with the expresssion's architecture.
Bye,
Ulrich
ChangeLog:
* eval.c (evaluate_subexp_standard): Use exp->gdbarch types instead
of builtin_type_ macros when handling OP_OBJC_ operations.
* objc-lang.c (print_object_command): Likewise.
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -999,6 +999,7 @@ evaluate_subexp_standard (struct type *e
{ /* Objective C @selector operator. */
char *sel = &exp->elts[pc + 2].string;
int len = longest_to_int (exp->elts[pc + 1].longconst);
+ struct type *selector_type;
(*pos) += 3 + BYTES_TO_EXP_ELEM (len + 1);
if (noside == EVAL_SKIP)
@@ -1006,8 +1007,9 @@ evaluate_subexp_standard (struct type *e
if (sel[len] != 0)
sel[len] = 0; /* Make sure it's terminated. */
- return value_from_longest (lookup_pointer_type (builtin_type_void),
- lookup_child_selector (sel));
+
+ selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+ return value_from_longest (selector_type, lookup_child_selector (sel));
}
case OP_OBJC_MSGCALL:
@@ -1030,6 +1032,7 @@ evaluate_subexp_standard (struct type *e
struct value *called_method = NULL;
struct type *selector_type = NULL;
+ struct type *long_type;
struct value *ret = NULL;
CORE_ADDR addr = 0;
@@ -1041,7 +1044,9 @@ evaluate_subexp_standard (struct type *e
(*pos) += 3;
- selector_type = lookup_pointer_type (builtin_type_void);
+ long_type = builtin_type (exp->gdbarch)->builtin_long;
+ selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+
if (noside == EVAL_AVOID_SIDE_EFFECTS)
sub_no_side = EVAL_NORMAL;
else
@@ -1050,7 +1055,7 @@ evaluate_subexp_standard (struct type *e
target = evaluate_subexp (selector_type, exp, pos, sub_no_side);
if (value_as_long (target) == 0)
- return value_from_longest (builtin_type_long, 0);
+ return value_from_longest (long_type, 0);
if (lookup_minimal_symbol ("objc_msg_lookup", 0, 0))
gnu_runtime = 1;
@@ -1065,8 +1070,7 @@ evaluate_subexp_standard (struct type *e
only). */
if (gnu_runtime)
{
- struct type *type;
- type = lookup_pointer_type (builtin_type_void);
+ struct type *type = selector_type;
type = lookup_function_type (type);
type = lookup_pointer_type (type);
type = lookup_function_type (type);
@@ -1110,8 +1114,8 @@ evaluate_subexp_standard (struct type *e
argvec[0] = msg_send;
argvec[1] = target;
- argvec[2] = value_from_longest (builtin_type_long, responds_selector);
- argvec[3] = value_from_longest (builtin_type_long, selector);
+ argvec[2] = value_from_longest (long_type, responds_selector);
+ argvec[3] = value_from_longest (long_type, selector);
argvec[4] = 0;
ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -1132,8 +1136,8 @@ evaluate_subexp_standard (struct type *e
argvec[0] = msg_send;
argvec[1] = target;
- argvec[2] = value_from_longest (builtin_type_long, method_selector);
- argvec[3] = value_from_longest (builtin_type_long, selector);
+ argvec[2] = value_from_longest (long_type, method_selector);
+ argvec[3] = value_from_longest (long_type, selector);
argvec[4] = 0;
ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -1252,7 +1256,7 @@ evaluate_subexp_standard (struct type *e
argvec[0] = called_method;
argvec[1] = target;
- argvec[2] = value_from_longest (builtin_type_long, selector);
+ argvec[2] = value_from_longest (long_type, selector);
/* User-supplied arguments. */
for (tem = 0; tem < nargs; tem++)
argvec[tem + 3] = evaluate_subexp_with_coercion (exp, pos, noside);
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -1378,7 +1378,7 @@ print_object_command (char *args, int fr
int pc = 0;
object = expr->language_defn->la_exp_desc->evaluate_exp
- (builtin_type_void_data_ptr, expr, &pc, EVAL_NORMAL);
+ (builtin_type (expr->gdbarch)->builtin_data_ptr, expr, &pc, EVAL_NORMAL);
do_cleanups (old_chain);
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (32 preceding siblings ...)
2008-08-31 17:53 ` [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation uweigand
@ 2008-08-31 18:12 ` uweigand
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
` (5 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 18:12 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-procfs --]
[-- Type: text/plain, Size: 2176 bytes --]
Hello,
procfs.c uses gdbarch_address_to_pointer to convert a target address
into a host address to be passed to the OS when setting watchpoints.
This patch changes procfs_address_to_host_pointer to use the per-target
architecture and its associated pointer types to perform that conversion.
It also removes and unnecessary reference to builtin_type_void_data_ptr
in procfs_auxv_parse.
Bye,
Ulrich
ChangeLog:
* procfs.c (procfs_address_to_host_pointer): Use target_gdbarch
and its associated types to perform pointer conversion.
(procfs_can_use_hw_breakpoint): Likewise.
(procfs_auxv_parse): Remove unused variable.
Index: gdb-head/gdb/procfs.c
===================================================================
--- gdb-head.orig/gdb/procfs.c
+++ gdb-head/gdb/procfs.c
@@ -160,7 +160,6 @@ static int
procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
{
- const int pointer_size = TYPE_LENGTH (builtin_type_void_data_ptr);
gdb_byte *ptr = *readptr;
if (endptr == ptr)
@@ -2899,11 +2898,11 @@ proc_parent_pid (procinfo *pi)
static void *
procfs_address_to_host_pointer (CORE_ADDR addr)
{
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
void *ptr;
- gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
- gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
- &ptr, addr);
+ gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
+ gdbarch_address_to_pointer (target_gdbarch, ptr_type, &ptr, addr);
return ptr;
}
@@ -5361,7 +5360,8 @@ procfs_can_use_hw_breakpoint (int type,
procfs_address_to_host_pointer will reveal that an internal error
will be generated when the host and target pointer sizes are
different. */
- if (sizeof (void *) != TYPE_LENGTH (builtin_type_void_data_ptr))
+ struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ if (sizeof (void *) != TYPE_LENGTH (ptr_type))
return 0;
/* Other tests here??? */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (33 preceding siblings ...)
2008-08-31 18:12 ` [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c uweigand
@ 2008-08-31 18:13 ` uweigand
2008-09-06 1:37 ` Joel Brobecker
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
` (4 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 18:13 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-infsym --]
[-- Type: text/plain, Size: 15729 bytes --]
Hello,
a number of places use builtin_type_ macros to build up argument lists
for inferior function calls. However, they always use the routine
find_function_in_inferior first to find the function to be called.
This routine is able to determine the objfile that defines the function
to be called -- and the per-objfile architecture of that file should
be used to determine the default types for the inferior call.
Bye,
Ulrich
ChangeLog:
* valops.c: Include "objfiles.h" and "symtab.h".
(find_function_in_inferior): New argument OBJF_P. Use it to return
objfile where function is defined. Use per-objfile arch types
instead of builtin_type_ to define default return type.
* linux-fork.c (checkpoint_command): Update calls. Use per-objfile
architecture to define inferior call argument types.
* gcore.c (derive_heap_segment): Likewise.
* objc-lang.c (value_nsstring): Likewise.
* scm-lang.c (scm_lookup_name): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* valops.c (value_allocate_space_in_inferior): Likewise.
* eval.c (evaluate_subexp_standard): Update calls.
* objc-lang.c (lookup_objc_class, print_object_command): Likewise.
* linux-fork.c: Include "objfiles.h".
* scm-lang.c: Include "objfiles.h".
* scm-valprint.c: Include "objfiles.h".
Index: gdb-head/gdb/eval.c
===================================================================
--- gdb-head.orig/gdb/eval.c
+++ gdb-head/gdb/eval.c
@@ -1076,8 +1076,9 @@ evaluate_subexp_standard (struct type *e
type = lookup_function_type (type);
type = lookup_pointer_type (type);
- msg_send = find_function_in_inferior ("objc_msg_lookup");
- msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+ msg_send = find_function_in_inferior ("objc_msg_lookup", NULL);
+ msg_send_stret
+ = find_function_in_inferior ("objc_msg_lookup", NULL);
msg_send = value_from_pointer (type, value_as_address (msg_send));
msg_send_stret = value_from_pointer (type,
@@ -1085,9 +1086,10 @@ evaluate_subexp_standard (struct type *e
}
else
{
- msg_send = find_function_in_inferior ("objc_msgSend");
+ msg_send = find_function_in_inferior ("objc_msgSend", NULL);
/* Special dispatcher for methods returning structs */
- msg_send_stret = find_function_in_inferior ("objc_msgSend_stret");
+ msg_send_stret
+ = find_function_in_inferior ("objc_msgSend_stret", NULL);
}
/* Verify the target object responds to this method. The
Index: gdb-head/gdb/gcore.c
===================================================================
--- gdb-head.orig/gdb/gcore.c
+++ gdb-head/gdb/gcore.c
@@ -215,6 +215,8 @@ derive_stack_segment (bfd_vma *bottom, b
static int
derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
{
+ struct objfile *sbrk_objf;
+ struct gdbarch *gdbarch;
bfd_vma top_of_data_memory = 0;
bfd_vma top_of_heap = 0;
bfd_size_type sec_size;
@@ -256,20 +258,21 @@ derive_heap_segment (bfd *abfd, bfd_vma
/* Now get the top-of-heap by calling sbrk in the inferior. */
if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
{
- sbrk = find_function_in_inferior ("sbrk");
+ sbrk = find_function_in_inferior ("sbrk", &sbrk_objf);
if (sbrk == NULL)
return 0;
}
else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
{
- sbrk = find_function_in_inferior ("_sbrk");
+ sbrk = find_function_in_inferior ("_sbrk", &sbrk_objf);
if (sbrk == NULL)
return 0;
}
else
return 0;
- zero = value_from_longest (builtin_type_int, 0);
+ gdbarch = get_objfile_arch (sbrk_objf);
+ zero = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
gdb_assert (zero);
sbrk = call_function_by_hand (sbrk, 1, &zero);
if (sbrk == NULL)
Index: gdb-head/gdb/linux-fork.c
===================================================================
--- gdb-head.orig/gdb/linux-fork.c
+++ gdb-head/gdb/linux-fork.c
@@ -22,6 +22,7 @@
#include "regcache.h"
#include "gdbcmd.h"
#include "infcall.h"
+#include "objfiles.h"
#include "gdb_assert.h"
#include "gdb_string.h"
#include "linux-fork.h"
@@ -528,6 +529,8 @@ save_detach_fork (int *saved_val)
static void
checkpoint_command (char *args, int from_tty)
{
+ struct objfile *fork_objf;
+ struct gdbarch *gdbarch;
struct target_waitstatus last_target_waitstatus;
ptid_t last_target_ptid;
struct value *fork_fn = NULL, *ret;
@@ -545,14 +548,15 @@ checkpoint_command (char *args, int from
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
- fork_fn = find_function_in_inferior ("fork");
+ fork_fn = find_function_in_inferior ("fork", &fork_objf);
if (!fork_fn)
if (lookup_minimal_symbol ("_fork", NULL, NULL) != NULL)
- fork_fn = find_function_in_inferior ("fork");
+ fork_fn = find_function_in_inferior ("fork", &fork_objf);
if (!fork_fn)
error (_("checkpoint: can't find fork function in inferior."));
- ret = value_from_longest (builtin_type_int, 0);
+ gdbarch = get_objfile_arch (fork_objf);
+ ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
old_chain = save_detach_fork (&temp_detach_fork);
detach_fork = 0;
ret = call_function_by_hand (fork_fn, 0, &ret);
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -117,9 +117,9 @@ lookup_objc_class (char *classname)
}
if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
- function = find_function_in_inferior("objc_lookUpClass");
+ function = find_function_in_inferior("objc_lookUpClass", NULL);
else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
- function = find_function_in_inferior("objc_lookup_class");
+ function = find_function_in_inferior("objc_lookup_class", NULL);
else
{
complaint (&symfile_complaints, _("no way to lookup Objective-C classes"));
@@ -144,9 +144,9 @@ lookup_child_selector (char *selname)
}
if (lookup_minimal_symbol("sel_getUid", 0, 0))
- function = find_function_in_inferior("sel_getUid");
+ function = find_function_in_inferior("sel_getUid", NULL);
else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
- function = find_function_in_inferior("sel_get_any_uid");
+ function = find_function_in_inferior("sel_get_any_uid", NULL);
else
{
complaint (&symfile_complaints, _("no way to lookup Objective-C selectors"));
@@ -165,43 +165,50 @@ value_nsstring (char *ptr, int len)
struct value *function, *nsstringValue;
struct symbol *sym;
struct type *type;
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
if (!target_has_execution)
return 0; /* Can't call into inferior to create NSString. */
- sym = lookup_struct_typedef("NSString", 0, 1);
- if (sym == NULL)
- sym = lookup_struct_typedef("NXString", 0, 1);
- if (sym == NULL)
- type = builtin_type_void_data_ptr;
- else
- type = lookup_pointer_type(SYMBOL_TYPE (sym));
-
stringValue[2] = value_string(ptr, len);
stringValue[2] = value_coerce_array(stringValue[2]);
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
{
- function = find_function_in_inferior("_NSNewStringFromCString");
+ function = find_function_in_inferior("_NSNewStringFromCString", &objf);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("istr", 0, 0))
{
- function = find_function_in_inferior("istr");
+ function = find_function_in_inferior("istr", &objf);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0))
{
- function = find_function_in_inferior("+[NSString stringWithCString:]");
+ function
+ = find_function_in_inferior("+[NSString stringWithCString:]", &objf);
+ type = builtin_type (get_objfile_arch (objf))->builtin_long;
+
stringValue[0] = value_from_longest
- (builtin_type_long, lookup_objc_class ("NSString"));
+ (type, lookup_objc_class ("NSString"));
stringValue[1] = value_from_longest
- (builtin_type_long, lookup_child_selector ("stringWithCString:"));
+ (type, lookup_child_selector ("stringWithCString:"));
nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
}
else
error (_("NSString: internal error -- no way to create new NSString"));
+ gdbarch = get_objfile_arch (objf);
+
+ sym = lookup_struct_typedef("NSString", 0, 1);
+ if (sym == NULL)
+ sym = lookup_struct_typedef("NXString", 0, 1);
+ if (sym == NULL)
+ type = builtin_type (gdbarch)->builtin_data_ptr;
+ else
+ type = lookup_pointer_type(SYMBOL_TYPE (sym));
+
deprecated_set_value_type (nsstringValue, type);
return nsstringValue;
}
@@ -1386,7 +1393,7 @@ print_object_command (char *args, int fr
object_addr = value_as_long (object);
read_memory (object_addr, &c, 1);
- function = find_function_in_inferior ("_NSPrintForDebugger");
+ function = find_function_in_inferior ("_NSPrintForDebugger", NULL);
if (function == NULL)
error (_("Unable to locate _NSPrintForDebugger in child process"));
Index: gdb-head/gdb/scm-lang.c
===================================================================
--- gdb-head.orig/gdb/scm-lang.c
+++ gdb-head/gdb/scm-lang.c
@@ -32,6 +32,7 @@
#include "gdb_string.h"
#include "gdbcore.h"
#include "infcall.h"
+#include "objfiles.h"
extern void _initialize_scheme_language (void);
static struct value *evaluate_subexp_scm (struct type *, struct expression *,
@@ -147,13 +148,19 @@ in_eval_c (void)
static struct value *
scm_lookup_name (char *str)
{
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
struct value *args[3];
int len = strlen (str);
struct value *func;
struct value *val;
struct symbol *sym;
+
+ func = find_function_in_inferior ("scm_lookup_cstr", &objf);
+ gdbarch = get_objfile_arch (objf);
+
args[0] = value_allocate_space_in_inferior (len);
- args[1] = value_from_longest (builtin_type_int, len);
+ args[1] = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
write_memory (value_as_long (args[0]), (gdb_byte *) str, len);
if (in_eval_c ()
@@ -165,7 +172,6 @@ scm_lookup_name (char *str)
/* FIXME in this case, we should try lookup_symbol first */
args[2] = value_from_longest (builtin_type_scm, SCM_EOL);
- func = find_function_in_inferior ("scm_lookup_cstr");
val = call_function_by_hand (func, 3, args);
if (!value_logical_not (val))
return value_ind (val);
@@ -187,7 +193,7 @@ scm_evaluate_string (char *str, int len)
write_memory (iaddr, (gdb_byte *) str, len);
/* FIXME - should find and pass env */
write_memory (iaddr + len, (gdb_byte *) "", 1);
- func = find_function_in_inferior ("scm_evstr");
+ func = find_function_in_inferior ("scm_evstr", NULL);
return call_function_by_hand (func, 1, &addr);
}
Index: gdb-head/gdb/scm-valprint.c
===================================================================
--- gdb-head.orig/gdb/scm-valprint.c
+++ gdb-head/gdb/scm-valprint.c
@@ -30,6 +30,7 @@
#include "gdbcore.h"
#include "c-lang.h"
#include "infcall.h"
+#include "objfiles.h"
static void scm_ipruk (char *, LONGEST, struct ui_file *);
static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
@@ -45,13 +46,16 @@ static int
scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty)
{
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
struct value *func, *arg, *result;
struct symbol *gdb_output_sym, *gdb_output_len_sym;
char *output;
int ret, output_len;
- func = find_function_in_inferior ("gdb_print");
- arg = value_from_longest (builtin_type_CORE_ADDR, value);
+ func = find_function_in_inferior ("gdb_print", &objf);
+ gdbarch = get_objfile_arch (objf);
+ arg = value_from_longest (builtin_type (gdbarch)->builtin_core_addr, value);
result = call_function_by_hand (func, 1, &arg);
ret = (int) value_as_long (result);
@@ -73,7 +77,7 @@ scm_inferior_print (LONGEST value, struc
(char *) &output_len, sizeof (output_len));
output = (char *) alloca (output_len);
- remote_buffer = value_at (builtin_type_CORE_ADDR,
+ remote_buffer = value_at (builtin_type (gdbarch)->builtin_core_addr,
SYMBOL_VALUE_ADDRESS (gdb_output_sym));
read_memory (value_as_address (remote_buffer),
output, output_len);
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -44,6 +44,8 @@
#include "gdb_assert.h"
#include "cp-support.h"
#include "observer.h"
+#include "objfiles.h"
+#include "symtab.h"
extern int overload_debug;
/* Local functions. */
@@ -122,10 +124,12 @@ Overload resolution in evaluating C++ fu
value);
}
-/* Find the address of function name NAME in the inferior. */
+/* Find the address of function name NAME in the inferior. If OBJF_P
+ is non-NULL, *OBJF_P will be set to the OBJFILE where the function
+ is defined. */
struct value *
-find_function_in_inferior (const char *name)
+find_function_in_inferior (const char *name, struct objfile **objf_p)
{
struct symbol *sym;
sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
@@ -136,6 +140,10 @@ find_function_in_inferior (const char *n
error (_("\"%s\" exists in this program but is not a function."),
name);
}
+
+ if (objf_p)
+ *objf_p = SYMBOL_SYMTAB (sym)->objfile;
+
return value_of_variable (sym, NULL);
}
else
@@ -144,12 +152,19 @@ find_function_in_inferior (const char *n
lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
{
+ struct objfile *objfile = msymbol_objfile (msymbol);
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
struct type *type;
CORE_ADDR maddr;
- type = lookup_pointer_type (builtin_type_char);
+ type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
type = lookup_function_type (type);
type = lookup_pointer_type (type);
maddr = SYMBOL_VALUE_ADDRESS (msymbol);
+
+ if (objf_p)
+ *objf_p = objfile;
+
return value_from_pointer (type, maddr);
}
else
@@ -169,10 +184,12 @@ find_function_in_inferior (const char *n
struct value *
value_allocate_space_in_inferior (int len)
{
+ struct objfile *objf;
+ struct value *val = find_function_in_inferior ("malloc", &objf);
+ struct gdbarch *gdbarch = get_objfile_arch (objf);
struct value *blocklen;
- struct value *val = find_function_in_inferior ("malloc");
- blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
+ blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
val = call_function_by_hand (val, 1, &blocklen);
if (value_logical_not (val))
{
Index: gdb-head/gdb/value.h
===================================================================
--- gdb-head.orig/gdb/value.h
+++ gdb-head/gdb/value.h
@@ -571,7 +571,8 @@ extern struct value *value_slice (struct
extern struct value *value_literal_complex (struct value *, struct value *,
struct type *);
-extern struct value *find_function_in_inferior (const char *);
+extern struct value *find_function_in_inferior (const char *,
+ struct objfile **);
extern struct value *value_allocate_space_in_inferior (int);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (34 preceding siblings ...)
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
@ 2008-08-31 18:15 ` uweigand
2008-09-02 12:48 ` Daniel Jacobowitz
2008-08-31 18:16 ` [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files uweigand
` (3 subsequent siblings)
39 siblings, 1 reply; 98+ messages in thread
From: uweigand @ 2008-08-31 18:15 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-infcall --]
[-- Type: text/plain, Size: 4737 bytes --]
Hello,
this patch removes builtin_type_ macros from infcall.c. The instances
in value_arg_coerce are simply made per-arch by passing in the architecture
from the (sole) call site.
find_function_addr used to return a default "builtin_type_int" if the
actual function return type could not be detected from debug data.
However: most callers to not even look at the return type computed
by find_function_addr, and the call site in eval.c implements its own
unknown return type handling. Thus the patch moves the return type
default setting to the sole remaining caller, call_function_by_hand.
Bye,
Ulrich
ChangeLog:
* infcall.c (value_arg_coerce): Add GDBARCH parameter. Use its
associates types instead of builtin_type_ macros.
(find_function_addr): Leave output VALUE_TYPE NULL if unknown.
(call_function_by_hand): Use per-architecture "int" type as
fall-back if find_function_addr returns NULL VALUE_TYPE.
Update call to value_arg_coerce.
Index: gdb-head/gdb/infcall.c
===================================================================
--- gdb-head.orig/gdb/infcall.c
+++ gdb-head/gdb/infcall.c
@@ -100,9 +100,10 @@ Unwinding of stack if a signal is receiv
its value as needed). */
static struct value *
-value_arg_coerce (struct value *arg, struct type *param_type,
- int is_prototyped, CORE_ADDR *sp)
+value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
+ struct type *param_type, int is_prototyped, CORE_ADDR *sp)
{
+ const struct builtin_type *builtin = builtin_type (gdbarch);
struct type *arg_type = check_typedef (value_type (arg));
struct type *type
= param_type ? check_typedef (param_type) : arg_type;
@@ -141,22 +142,22 @@ value_arg_coerce (struct value *arg, str
/* If we don't have a prototype, coerce to integer type if necessary. */
if (!is_prototyped)
{
- if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
- type = builtin_type_int;
+ if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
+ type = builtin->builtin_int;
}
/* Currently all target ABIs require at least the width of an integer
type for an argument. We may have to conditionalize the following
type coercion for future targets. */
- if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
- type = builtin_type_int;
+ if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int))
+ type = builtin->builtin_int;
break;
case TYPE_CODE_FLT:
if (!is_prototyped && coerce_float_to_double_p)
{
- if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double))
- type = builtin_type_double;
- else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin_type_double))
- type = builtin_type_long_double;
+ if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_double))
+ type = builtin->builtin_double;
+ else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin->builtin_double))
+ type = builtin->builtin_long_double;
}
break;
case TYPE_CODE_FUNC:
@@ -199,7 +200,7 @@ find_function_addr (struct value *functi
{
struct type *ftype = check_typedef (value_type (function));
enum type_code code = TYPE_CODE (ftype);
- struct type *value_type;
+ struct type *value_type = NULL;
CORE_ADDR funaddr;
/* If it's a member function, just look at the function
@@ -223,8 +224,6 @@ find_function_addr (struct value *functi
¤t_target);
value_type = TYPE_TARGET_TYPE (ftype);
}
- else
- value_type = builtin_type_int;
}
else if (code == TYPE_CODE_INT)
{
@@ -251,8 +250,6 @@ find_function_addr (struct value *functi
/* Handle integer used as address of a function. */
funaddr = (CORE_ADDR) value_as_long (function);
}
-
- value_type = builtin_type_int;
}
else
error (_("Invalid data type for function to be called."));
@@ -472,6 +469,9 @@ call_function_by_hand (struct value *fun
funaddr = find_function_addr (function, &values_type);
CHECK_TYPEDEF (values_type);
+ if (!values_type)
+ values_type = builtin_type (gdbarch)->builtin_int;
+
/* Are we returning a value using a structure return (passing a
hidden argument pointing to storage) or a normal value return?
There are two cases: language-mandated structure return and
@@ -590,7 +590,8 @@ call_function_by_hand (struct value *fun
else
param_type = NULL;
- args[i] = value_arg_coerce (args[i], param_type, prototyped, &sp);
+ args[i] = value_arg_coerce (gdbarch, args[i],
+ param_type, prototyped, &sp);
if (param_type != NULL && language_pass_by_reference (param_type))
args[i] = value_addr (args[i]);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (35 preceding siblings ...)
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
@ 2008-08-31 18:16 ` uweigand
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
` (2 subsequent siblings)
39 siblings, 0 replies; 98+ messages in thread
From: uweigand @ 2008-08-31 18:16 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: diff-type-tdep --]
[-- Type: text/plain, Size: 36871 bytes --]
Hello,
this patch removes all instances of builtin_type_ macros from all
*-tdep.c files. This is completely straigtforward as we always
have a gdbarch to work with.
Bye,
Ulrich
ChangeLog:
* alpha-tdep.c (alpha_register_type): Use builtin_type (gdbarch)
instead of builtin_type_ macros.
* amd64-tdep.c (amd64_register_type): Likewise.
(amd64_get_longjmp_target): Likewise.
* arm-tdep.c (arm_register_type): Likewise.
* avr-tdep.c (avr_register_type): Likewise.
* cris-tdep.c (cris_register_type, crisv32_register_type): Likewise.
* frv-tdep.c (frv_register_type): Likewise.
* h8300-tdep.c (h8300_register_type): Likewise.
* hppa-tdep.c (hppa32_convert_from_func_ptr_addr,
hppa_skip_trampoline_code): Likewise.
* i386-tdep.c (i386_register_type): Likewise.
(i386_unwind_pc, i386_sse_type): Likewise.
* ia64-tdep.c (ia64_register_type): Likewise.
* m32r-tdep.c (m32r_register_type): Likewise.
* m68k-tdep.c (m68k_register_type, m68k_unwind_pc): Likewise.
* m88k-tdep.c (m88k_register_type): Likewise.
* mep-tdep.c (mep_register_type): Likewise.
* mips-tdep.c (mips_pseudo_register_type): Likewise.
* mn10300-tdep.c (mn10300_register_type): Likewise.
* mt-tdep.c (mt_copro_register_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64): Likewise.
(rs6000_convert_register_p, rs6000_register_to_value,
rs6000_value_to_register): Likewise.
* s390-tdep.c (s390_register_type): Likewise.
* sh64-tdep.c (sh64_register_type): Likewise.
(sh64_build_float_register_type, sh64_do_fp_register): Likewise.
* sh-tdep.c (sh_sh2a_register_type, sh_sh3e_register_type,
sh_sh4_build_float_register_type, sh_sh4_register_type,
sh_default_register_type): Likewise.
* sparc64-tdep.c (sparc64_register_type): Likewise.
* sparc-tdep.c (sparc32_register_type): Likewise.
* spu-tdep.c (spu_builtin_type_vec128, spu_register_type): Likewise.
* v850-tdep.c (v850_register_type): Likewise.
* vax-tdep.c (vax_register_type): Likewise.
* xtensa-tdep.c (xtensa_register_type, xtensa_unwind_pc,
xtensa_push_dummy_call): Likewise.
* std-regs.c (value_of_builtin_frame_fp_reg,
value_of_builtin_frame_pc_reg): Likewise.
* target-descriptions.c (tdesc_register_type): Likewise.
Index: gdb-head/gdb/alpha-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.c
+++ gdb-head/gdb/alpha-tdep.c
@@ -95,9 +95,9 @@ static struct type *
alpha_register_type (struct gdbarch *gdbarch, int regno)
{
if (regno == ALPHA_SP_REGNUM || regno == ALPHA_GP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (regno == ALPHA_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
/* Don't need to worry about little vs big endian until
some jerk tries to port to alpha-unicosmk. */
Index: gdb-head/gdb/amd64-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64-tdep.c
+++ gdb-head/gdb/amd64-tdep.c
@@ -90,11 +90,11 @@ amd64_register_type (struct gdbarch *gdb
if (regnum >= AMD64_RAX_REGNUM && regnum <= AMD64_RDI_REGNUM)
return builtin_type_int64;
if (regnum == AMD64_RBP_REGNUM || regnum == AMD64_RSP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (regnum >= AMD64_R8_REGNUM && regnum <= AMD64_R15_REGNUM)
return builtin_type_int64;
if (regnum == AMD64_RIP_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum == AMD64_EFLAGS_REGNUM)
return i386_eflags_type;
if (regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM)
@@ -1277,7 +1277,7 @@ amd64_get_longjmp_target (struct frame_i
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
- int len = TYPE_LENGTH (builtin_type_void_func_ptr);
+ int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
/* If JB_PC_OFFSET is -1, we have no way to find out where the
longjmp will land. */
@@ -1285,11 +1285,12 @@ amd64_get_longjmp_target (struct frame_i
return 0;
get_frame_register (frame, AMD64_RDI_REGNUM, buf);
- jb_addr = extract_typed_address (buf, builtin_type_void_data_ptr);
+ jb_addr= extract_typed_address
+ (buf, builtin_type (gdbarch)->builtin_data_ptr);
if (target_read_memory (jb_addr + jb_pc_offset, buf, len))
return 0;
- *pc = extract_typed_address (buf, builtin_type_void_func_ptr);
+ *pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
return 1;
}
Index: gdb-head/gdb/arm-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-tdep.c
+++ gdb-head/gdb/arm-tdep.c
@@ -1603,9 +1603,9 @@ arm_register_type (struct gdbarch *gdbar
if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS)
return builtin_type_arm_ext;
else if (regnum == ARM_SP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else if (regnum == ARM_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
else if (regnum >= ARRAY_SIZE (arm_register_names))
/* These registers are only supported on targets which supply
an XML description. */
Index: gdb-head/gdb/avr-tdep.c
===================================================================
--- gdb-head.orig/gdb/avr-tdep.c
+++ gdb-head/gdb/avr-tdep.c
@@ -213,7 +213,7 @@ avr_register_type (struct gdbarch *gdbar
if (reg_nr == AVR_PC_REGNUM)
return builtin_type_uint32;
if (reg_nr == AVR_SP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else
return builtin_type_uint8;
}
Index: gdb-head/gdb/cris-tdep.c
===================================================================
--- gdb-head.orig/gdb/cris-tdep.c
+++ gdb-head/gdb/cris-tdep.c
@@ -1658,10 +1658,10 @@ static struct type *
cris_register_type (struct gdbarch *gdbarch, int regno)
{
if (regno == gdbarch_pc_regnum (gdbarch))
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
else if (regno == gdbarch_sp_regnum (gdbarch)
|| regno == CRIS_FP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
|| (regno >= MOF_REGNUM && regno <= USP_REGNUM))
/* Note: R8 taken care of previous clause. */
@@ -1679,10 +1679,10 @@ static struct type *
crisv32_register_type (struct gdbarch *gdbarch, int regno)
{
if (regno == gdbarch_pc_regnum (gdbarch))
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
else if (regno == gdbarch_sp_regnum (gdbarch)
|| regno == CRIS_FP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else if ((regno >= 0 && regno <= ACR_REGNUM)
|| (regno >= EXS_REGNUM && regno <= SPC_REGNUM)
|| (regno == PID_REGNUM)
Index: gdb-head/gdb/frv-tdep.c
===================================================================
--- gdb-head.orig/gdb/frv-tdep.c
+++ gdb-head/gdb/frv-tdep.c
@@ -292,7 +292,7 @@ static struct type *
frv_register_type (struct gdbarch *gdbarch, int reg)
{
if (reg >= first_fpr_regnum && reg <= last_fpr_regnum)
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else if (reg == iacc0_regnum)
return builtin_type_int64;
else
Index: gdb-head/gdb/h8300-tdep.c
===================================================================
--- gdb-head.orig/gdb/h8300-tdep.c
+++ gdb-head/gdb/h8300-tdep.c
@@ -1112,10 +1112,10 @@ h8300_register_type (struct gdbarch *gdb
switch (regno)
{
case E_PC_REGNUM:
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
case E_SP_REGNUM:
case E_FP_REGNUM:
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
default:
if (regno == E_PSEUDO_CCR_REGNUM (gdbarch))
return builtin_type_uint8;
Index: gdb-head/gdb/hppa-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-tdep.c
+++ gdb-head/gdb/hppa-tdep.c
@@ -1244,8 +1244,9 @@ hppa32_convert_from_func_ptr_addr (struc
{
if (addr & 2)
{
+ struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
CORE_ADDR plabel = addr & ~3;
- return read_memory_typed_address (plabel, builtin_type_void_func_ptr);
+ return read_memory_typed_address (plabel, func_ptr_type);
}
return addr;
@@ -2897,6 +2898,9 @@ hppa_in_solib_call_trampoline (CORE_ADDR
CORE_ADDR
hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+
unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
int dp_rel;
@@ -2907,7 +2911,7 @@ hppa_skip_trampoline_code (struct frame_
/* PLABELs have bit 30 set; if it's a PLABEL, then dereference it. */
if (pc & 0x2)
- pc = read_memory_typed_address (pc & ~0x3, builtin_type_void_func_ptr);
+ pc = read_memory_typed_address (pc & ~0x3, func_ptr_type);
return pc;
}
@@ -2928,7 +2932,7 @@ hppa_skip_trampoline_code (struct frame_
if (in_plt_section (pc, NULL))
{
- pc = read_memory_typed_address (pc, builtin_type_void_func_ptr);
+ pc = read_memory_typed_address (pc, func_ptr_type);
/* If the PLT slot has not yet been resolved, the target will be
the PLT stub. */
@@ -2942,7 +2946,7 @@ hppa_skip_trampoline_code (struct frame_
}
/* This should point to the fixup routine. */
- pc = read_memory_typed_address (pc + 8, builtin_type_void_func_ptr);
+ pc = read_memory_typed_address (pc + 8, func_ptr_type);
}
}
Index: gdb-head/gdb/i386-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-tdep.c
+++ gdb-head/gdb/i386-tdep.c
@@ -1275,7 +1275,7 @@ i386_unwind_pc (struct gdbarch *gdbarch,
gdb_byte buf[8];
frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
- return extract_typed_address (buf, builtin_type_void_func_ptr);
+ return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
}
\f
@@ -2071,9 +2071,11 @@ i386_sse_type (struct gdbarch *gdbarch)
t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION);
append_composite_type_field (t, "v4_float",
- init_vector_type (builtin_type_float, 4));
+ init_vector_type (builtin_type (gdbarch)
+ ->builtin_float, 4));
append_composite_type_field (t, "v2_double",
- init_vector_type (builtin_type_double, 2));
+ init_vector_type (builtin_type (gdbarch)
+ ->builtin_double, 2));
append_composite_type_field (t, "v16_int8",
init_vector_type (builtin_type_int8, 16));
append_composite_type_field (t, "v8_int16",
@@ -2100,13 +2102,13 @@ static struct type *
i386_register_type (struct gdbarch *gdbarch, int regnum)
{
if (regnum == I386_EIP_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum == I386_EFLAGS_REGNUM)
return i386_eflags_type;
if (regnum == I386_EBP_REGNUM || regnum == I386_ESP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (i386_fp_regnum_p (gdbarch, regnum))
return builtin_type_i387_ext;
@@ -2120,7 +2122,7 @@ i386_register_type (struct gdbarch *gdba
if (regnum == I387_MXCSR_REGNUM (gdbarch_tdep (gdbarch)))
return i386_mxcsr_type;
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
/* Map a cooked register onto a raw register or memory. For the i386,
Index: gdb-head/gdb/ia64-tdep.c
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.c
+++ gdb-head/gdb/ia64-tdep.c
@@ -309,7 +309,7 @@ ia64_register_type (struct gdbarch *arch
if (reg >= IA64_FR0_REGNUM && reg <= IA64_FR127_REGNUM)
return builtin_type_ia64_ext;
else
- return builtin_type_long;
+ return builtin_type (arch)->builtin_long;
}
static int
Index: gdb-head/gdb/m32r-tdep.c
===================================================================
--- gdb-head.orig/gdb/m32r-tdep.c
+++ gdb-head/gdb/m32r-tdep.c
@@ -231,9 +231,9 @@ static struct type *
m32r_register_type (struct gdbarch *gdbarch, int reg_nr)
{
if (reg_nr == M32R_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
else if (reg_nr == M32R_SP_REGNUM || reg_nr == M32R_FP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else
return builtin_type_int32;
}
Index: gdb-head/gdb/m68k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68k-tdep.c
+++ gdb-head/gdb/m68k-tdep.c
@@ -120,7 +120,7 @@ m68k_register_type (struct gdbarch *gdba
}
if (regnum == M68K_FPI_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum == M68K_FPC_REGNUM || regnum == M68K_FPS_REGNUM)
return builtin_type_int32;
@@ -132,10 +132,10 @@ m68k_register_type (struct gdbarch *gdba
}
if (regnum == gdbarch_pc_regnum (gdbarch))
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (regnum == M68K_PS_REGNUM)
return m68k_ps_type;
@@ -832,7 +832,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch,
gdb_byte buf[8];
frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
- return extract_typed_address (buf, builtin_type_void_func_ptr);
+ return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
}
\f
/* Normal frames. */
Index: gdb-head/gdb/m88k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m88k-tdep.c
+++ gdb-head/gdb/m88k-tdep.c
@@ -75,11 +75,11 @@ m88k_register_type (struct gdbarch *gdba
/* SXIP, SNIP, SFIP and R1 contain code addresses. */
if ((regnum >= M88K_SXIP_REGNUM && regnum <= M88K_SFIP_REGNUM)
|| regnum == M88K_R1_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
/* R30 and R31 typically contains data addresses. */
if (regnum == M88K_R30_REGNUM || regnum == M88K_R31_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
return builtin_type_int32;
}
Index: gdb-head/gdb/mep-tdep.c
===================================================================
--- gdb-head.orig/gdb/mep-tdep.c
+++ gdb-head/gdb/mep-tdep.c
@@ -1097,14 +1097,14 @@ mep_register_type (struct gdbarch *gdbar
if (size == 32)
{
if (mep_pseudo_cr_is_float (reg_nr))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else
return builtin_type_uint32;
}
else if (size == 64)
{
if (mep_pseudo_cr_is_float (reg_nr))
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
else
return builtin_type_uint64;
}
Index: gdb-head/gdb/mips-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-tdep.c
+++ gdb-head/gdb/mips-tdep.c
@@ -737,12 +737,13 @@ mips_pseudo_register_type (struct gdbarc
/* Use pointer types for registers if we can. For n32 we can not,
since we do not have a 64-bit pointer type. */
- if (mips_abi_regsize (gdbarch) == TYPE_LENGTH (builtin_type_void_data_ptr))
+ if (mips_abi_regsize (gdbarch)
+ == TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr))
{
if (rawnum == MIPS_SP_REGNUM || rawnum == MIPS_EMBED_BADVADDR_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else if (rawnum == MIPS_EMBED_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
}
if (mips_abi_regsize (gdbarch) == 4 && TYPE_LENGTH (rawtype) == 8
Index: gdb-head/gdb/mn10300-tdep.c
===================================================================
--- gdb-head.orig/gdb/mn10300-tdep.c
+++ gdb-head/gdb/mn10300-tdep.c
@@ -265,7 +265,7 @@ am33_2_register_name (struct gdbarch *gd
static struct type *
mn10300_register_type (struct gdbarch *gdbarch, int reg)
{
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
static CORE_ADDR
Index: gdb-head/gdb/mt-tdep.c
===================================================================
--- gdb-head.orig/gdb/mt-tdep.c
+++ gdb-head/gdb/mt-tdep.c
@@ -226,9 +226,9 @@ mt_copro_register_type (struct gdbarch *
case MT_MAC_REGNUM:
return builtin_type_uint32;
case MT_CONTEXT_REGNUM:
- return builtin_type_long_long;
+ return builtin_type (arch)->builtin_long_long;
case MT_FLAG_REGNUM:
- return builtin_type_unsigned_char;
+ return builtin_type (arch)->builtin_unsigned_char;
default:
if (regnum >= MT_CPR0_REGNUM && regnum <= MT_CPR15_REGNUM)
return builtin_type_int16;
Index: gdb-head/gdb/rs6000-tdep.c
===================================================================
--- gdb-head.orig/gdb/rs6000-tdep.c
+++ gdb-head/gdb/rs6000-tdep.c
@@ -2079,7 +2079,8 @@ rs6000_builtin_type_vec64 (struct gdbarc
t = init_composite_type ("__ppc_builtin_type_vec64", TYPE_CODE_UNION);
append_composite_type_field (t, "uint64", builtin_type_int64);
append_composite_type_field (t, "v2_float",
- init_vector_type (builtin_type_float, 2));
+ init_vector_type (builtin_type (gdbarch)
+ ->builtin_float, 2));
append_composite_type_field (t, "v2_int32",
init_vector_type (builtin_type_int32, 2));
append_composite_type_field (t, "v4_int16",
@@ -2277,7 +2278,8 @@ rs6000_convert_register_p (struct gdbarc
&& regnum >= tdep->ppc_fp0_regnum
&& regnum < tdep->ppc_fp0_regnum + ppc_num_fprs
&& TYPE_CODE (type) == TYPE_CODE_FLT
- && TYPE_LENGTH (type) != TYPE_LENGTH (builtin_type_double));
+ && TYPE_LENGTH (type)
+ != TYPE_LENGTH (builtin_type (gdbarch)->builtin_double));
}
static void
@@ -2286,12 +2288,14 @@ rs6000_register_to_value (struct frame_i
struct type *type,
gdb_byte *to)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte from[MAX_REGISTER_SIZE];
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
get_frame_register (frame, regnum, from);
- convert_typed_floating (from, builtin_type_double, to, type);
+ convert_typed_floating (from, builtin_type (gdbarch)->builtin_double,
+ to, type);
}
static void
@@ -2300,11 +2304,13 @@ rs6000_value_to_register (struct frame_i
struct type *type,
const gdb_byte *from)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte to[MAX_REGISTER_SIZE];
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
- convert_typed_floating (from, type, to, builtin_type_double);
+ convert_typed_floating (from, type,
+ to, builtin_type (gdbarch)->builtin_double);
put_frame_register (frame, regnum, to);
}
Index: gdb-head/gdb/s390-tdep.c
===================================================================
--- gdb-head.orig/gdb/s390-tdep.c
+++ gdb-head/gdb/s390-tdep.c
@@ -96,19 +96,19 @@ static struct type *
s390_register_type (struct gdbarch *gdbarch, int regnum)
{
if (regnum == S390_PSWM_REGNUM || regnum == S390_PSWA_REGNUM)
- return builtin_type_long;
+ return builtin_type (gdbarch)->builtin_long;
if (regnum >= S390_R0_REGNUM && regnum <= S390_R15_REGNUM)
- return builtin_type_long;
+ return builtin_type (gdbarch)->builtin_long;
if (regnum >= S390_A0_REGNUM && regnum <= S390_A15_REGNUM)
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
if (regnum == S390_FPC_REGNUM)
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
if (regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
if (regnum == S390_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum == S390_CC_REGNUM)
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
internal_error (__FILE__, __LINE__, _("invalid regnum"));
}
Index: gdb-head/gdb/sh64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh64-tdep.c
+++ gdb-head/gdb/sh64-tdep.c
@@ -1503,12 +1503,12 @@ REGISTER_BYTE returns the register byte
*/
static struct type *
-sh64_build_float_register_type (int high)
+sh64_build_float_register_type (struct gdbarch *gdbarch, int high)
{
struct type *temp;
temp = create_range_type (NULL, builtin_type_int32, 0, high);
- return create_array_type (NULL, builtin_type_float, temp);
+ return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
}
/* Return the GDB type object for the "standard" data type
@@ -1520,27 +1520,27 @@ sh64_register_type (struct gdbarch *gdba
&& reg_nr <= FP_LAST_REGNUM)
|| (reg_nr >= FP0_C_REGNUM
&& reg_nr <= FP_LAST_C_REGNUM))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else if ((reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
|| (reg_nr >= DR0_C_REGNUM
&& reg_nr <= DR_LAST_C_REGNUM))
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
else if (reg_nr >= FPP0_REGNUM
&& reg_nr <= FPP_LAST_REGNUM)
- return sh64_build_float_register_type (1);
+ return sh64_build_float_register_type (gdbarch, 1);
else if ((reg_nr >= FV0_REGNUM
&& reg_nr <= FV_LAST_REGNUM)
||(reg_nr >= FV0_C_REGNUM
&& reg_nr <= FV_LAST_C_REGNUM))
- return sh64_build_float_register_type (3);
+ return sh64_build_float_register_type (gdbarch, 3);
else if (reg_nr == FPSCR_REGNUM)
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
else if (reg_nr >= R0_C_REGNUM
&& reg_nr < FP0_C_REGNUM)
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
else
- return builtin_type_long_long;
+ return builtin_type (gdbarch)->builtin_long_long;
}
static void
@@ -1997,7 +1997,7 @@ sh64_do_fp_register (struct gdbarch *gdb
regnum, gdbarch_register_name (gdbarch, regnum));
/* Get the register as a number */
- flt = unpack_double (builtin_type_float, raw_buffer, &inv);
+ flt = unpack_double (builtin_type (gdbarch)->builtin_float, raw_buffer, &inv);
/* Print the name and some spaces. */
fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
Index: gdb-head/gdb/sh-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh-tdep.c
+++ gdb-head/gdb/sh-tdep.c
@@ -2132,11 +2132,11 @@ sh_sh2a_register_type (struct gdbarch *g
{
if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
&& (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
else
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
/* Return the GDB type object for the "standard" data type
@@ -2146,18 +2146,18 @@ sh_sh3e_register_type (struct gdbarch *g
{
if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
&& (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
static struct type *
-sh_sh4_build_float_register_type (int high)
+sh_sh4_build_float_register_type (struct gdbarch *gdbarch, int high)
{
struct type *temp;
temp = create_range_type (NULL, builtin_type_int32, 0, high);
- return create_array_type (NULL, builtin_type_float, temp);
+ return create_array_type (NULL, builtin_type (gdbarch)->builtin_float, temp);
}
static struct type *
@@ -2165,19 +2165,19 @@ sh_sh4_register_type (struct gdbarch *gd
{
if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
&& (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
- return sh_sh4_build_float_register_type (3);
+ return sh_sh4_build_float_register_type (gdbarch, 3);
else
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
static struct type *
sh_default_register_type (struct gdbarch *gdbarch, int reg_nr)
{
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
/* Is a register in a reggroup?
Index: gdb-head/gdb/sparc64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64-tdep.c
+++ gdb-head/gdb/sparc64-tdep.c
@@ -247,15 +247,15 @@ sparc64_register_type (struct gdbarch *g
/* Raw registers. */
if (regnum == SPARC_SP_REGNUM || regnum == SPARC_FP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (regnum >= SPARC_G0_REGNUM && regnum <= SPARC_I7_REGNUM)
return builtin_type_int64;
if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
if (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
if (regnum == SPARC64_PC_REGNUM || regnum == SPARC64_NPC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
/* This raw register contains the contents of %cwp, %pstate, %asi
and %ccr as laid out in a %tstate register. */
if (regnum == SPARC64_STATE_REGNUM)
@@ -280,9 +280,9 @@ sparc64_register_type (struct gdbarch *g
if (regnum == SPARC64_CCR_REGNUM)
return builtin_type_int64;
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D62_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q60_REGNUM)
- return builtin_type_long_double;
+ return builtin_type (gdbarch)->builtin_long_double;
internal_error (__FILE__, __LINE__, _("invalid regnum"));
}
Index: gdb-head/gdb/sparc-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc-tdep.c
+++ gdb-head/gdb/sparc-tdep.c
@@ -332,16 +332,16 @@ static struct type *
sparc32_register_type (struct gdbarch *gdbarch, int regnum)
{
if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
if (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM)
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
if (regnum == SPARC_SP_REGNUM || regnum == SPARC_FP_REGNUM)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
if (regnum == SPARC32_PC_REGNUM || regnum == SPARC32_NPC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
if (regnum == SPARC32_PSR_REGNUM)
return sparc_psr_type;
Index: gdb-head/gdb/spu-tdep.c
===================================================================
--- gdb-head.orig/gdb/spu-tdep.c
+++ gdb-head/gdb/spu-tdep.c
@@ -74,9 +74,11 @@ spu_builtin_type_vec128 (struct gdbarch
append_composite_type_field (t, "v16_int8",
init_vector_type (builtin_type_int8, 16));
append_composite_type_field (t, "v2_double",
- init_vector_type (builtin_type_double, 2));
+ init_vector_type (builtin_type (gdbarch)
+ ->builtin_double, 2));
append_composite_type_field (t, "v4_float",
- init_vector_type (builtin_type_float, 4));
+ init_vector_type (builtin_type (gdbarch)
+ ->builtin_float, 4));
TYPE_VECTOR (t) = 1;
TYPE_NAME (t) = "spu_builtin_type_vec128";
@@ -137,10 +139,10 @@ spu_register_type (struct gdbarch *gdbar
return builtin_type_uint32;
case SPU_PC_REGNUM:
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
case SPU_SP_REGNUM:
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
case SPU_FPSCR_REGNUM:
return builtin_type_uint128;
Index: gdb-head/gdb/std-regs.c
===================================================================
--- gdb-head.orig/gdb/std-regs.c
+++ gdb-head/gdb/std-regs.c
@@ -42,12 +42,13 @@ value_of_builtin_frame_fp_reg (struct fr
frame);
else
{
- struct value *val = allocate_value (builtin_type_void_data_ptr);
+ struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+ struct value *val = allocate_value (data_ptr_type);
gdb_byte *buf = value_contents_raw (val);
if (frame == NULL)
memset (buf, 0, TYPE_LENGTH (value_type (val)));
else
- gdbarch_address_to_pointer (gdbarch, builtin_type_void_data_ptr,
+ gdbarch_address_to_pointer (gdbarch, data_ptr_type,
buf, get_frame_base_address (frame));
return val;
}
@@ -61,12 +62,13 @@ value_of_builtin_frame_pc_reg (struct fr
return value_of_register (gdbarch_pc_regnum (gdbarch), frame);
else
{
- struct value *val = allocate_value (builtin_type_void_func_ptr);
+ struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+ struct value *val = allocate_value (func_ptr_type);
gdb_byte *buf = value_contents_raw (val);
if (frame == NULL)
memset (buf, 0, TYPE_LENGTH (value_type (val)));
else
- gdbarch_address_to_pointer (gdbarch, builtin_type_void_func_ptr,
+ gdbarch_address_to_pointer (gdbarch, func_ptr_type,
buf, get_frame_pc (frame));
return val;
}
Index: gdb-head/gdb/target-descriptions.c
===================================================================
--- gdb-head.orig/gdb/target-descriptions.c
+++ gdb-head/gdb/target-descriptions.c
@@ -552,32 +552,32 @@ tdesc_register_type (struct gdbarch *gdb
if (strcmp (reg->type, "float") == 0)
{
if (reg->bitsize == gdbarch_float_bit (gdbarch))
- return builtin_type_float;
+ return builtin_type (gdbarch)->builtin_float;
else if (reg->bitsize == gdbarch_double_bit (gdbarch))
- return builtin_type_double;
+ return builtin_type (gdbarch)->builtin_double;
else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
- return builtin_type_long_double;
+ return builtin_type (gdbarch)->builtin_long_double;
}
else if (strcmp (reg->type, "int") == 0)
{
if (reg->bitsize == gdbarch_long_bit (gdbarch))
- return builtin_type_long;
+ return builtin_type (gdbarch)->builtin_long;
else if (reg->bitsize == TARGET_CHAR_BIT)
- return builtin_type_char;
+ return builtin_type (gdbarch)->builtin_char;
else if (reg->bitsize == gdbarch_short_bit (gdbarch))
- return builtin_type_short;
+ return builtin_type (gdbarch)->builtin_short;
else if (reg->bitsize == gdbarch_int_bit (gdbarch))
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
- return builtin_type_long_long;
+ return builtin_type (gdbarch)->builtin_long_long;
else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
/* A bit desperate by this point... */
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
}
else if (strcmp (reg->type, "code_ptr") == 0)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
else if (strcmp (reg->type, "data_ptr") == 0)
- return builtin_type_void_data_ptr;
+ return builtin_type (gdbarch)->builtin_data_ptr;
else
internal_error (__FILE__, __LINE__,
"Register \"%s\" has an unknown type \"%s\"",
@@ -585,7 +585,7 @@ tdesc_register_type (struct gdbarch *gdb
warning (_("Register \"%s\" has an unsupported size (%d bits)"),
reg->name, reg->bitsize);
- return builtin_type_long;
+ return builtin_type (gdbarch)->builtin_long;
}
static int
Index: gdb-head/gdb/v850-tdep.c
===================================================================
--- gdb-head.orig/gdb/v850-tdep.c
+++ gdb-head/gdb/v850-tdep.c
@@ -183,7 +183,7 @@ static struct type *
v850_register_type (struct gdbarch *gdbarch, int regnum)
{
if (regnum == E_PC_REGNUM)
- return builtin_type_void_func_ptr;
+ return builtin_type (gdbarch)->builtin_func_ptr;
return builtin_type_int32;
}
Index: gdb-head/gdb/vax-tdep.c
===================================================================
--- gdb-head.orig/gdb/vax-tdep.c
+++ gdb-head/gdb/vax-tdep.c
@@ -61,7 +61,7 @@ vax_register_name (struct gdbarch *gdbar
static struct type *
vax_register_type (struct gdbarch *gdbarch, int regnum)
{
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
}
\f
/* Core file support. */
Index: gdb-head/gdb/xtensa-tdep.c
===================================================================
--- gdb-head.orig/gdb/xtensa-tdep.c
+++ gdb-head/gdb/xtensa-tdep.c
@@ -229,7 +229,7 @@ xtensa_register_type (struct gdbarch *gd
+ gdbarch_tdep (gdbarch)->num_aregs)
|| (regnum >= gdbarch_tdep (gdbarch)->a0_base
&& regnum < gdbarch_tdep (gdbarch)->a0_base + 16))
- return builtin_type_int;
+ return builtin_type (gdbarch)->builtin_int;
if (regnum == gdbarch_pc_regnum (gdbarch)
|| regnum == gdbarch_tdep (gdbarch)->a0_base + 1)
@@ -1015,15 +1015,16 @@ static CORE_ADDR
xtensa_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
gdb_byte buf[8];
+ CORE_ADDR pc;
DEBUGTRACE ("xtensa_unwind_pc (next_frame = %p)\n", next_frame);
frame_unwind_register (next_frame, gdbarch_pc_regnum (gdbarch), buf);
+ pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
- DEBUGINFO ("[xtensa_unwind_pc] pc = 0x%08x\n", (unsigned int)
- extract_typed_address (buf, builtin_type_void_func_ptr));
+ DEBUGINFO ("[xtensa_unwind_pc] pc = 0x%08x\n", (unsigned int) pc);
- return extract_typed_address (buf, builtin_type_void_func_ptr);
+ return pc;
}
@@ -1677,9 +1678,10 @@ xtensa_push_dummy_call (struct gdbarch *
case TYPE_CODE_ENUM:
/* Cast argument to long if necessary as the mask does it too. */
- if (TYPE_LENGTH (arg_type) < TYPE_LENGTH (builtin_type_long))
+ if (TYPE_LENGTH (arg_type)
+ < TYPE_LENGTH (builtin_type (gdbarch)->builtin_long))
{
- arg_type = builtin_type_long;
+ arg_type = builtin_type (gdbarch)->builtin_long;
arg = value_cast (arg_type, arg);
}
/* Aligment is equal to the type length for the basic types. */
@@ -1689,15 +1691,16 @@ xtensa_push_dummy_call (struct gdbarch *
case TYPE_CODE_FLT:
/* Align doubles correctly. */
- if (TYPE_LENGTH (arg_type) == TYPE_LENGTH (builtin_type_double))
- info->align = TYPE_LENGTH (builtin_type_double);
+ if (TYPE_LENGTH (arg_type)
+ == TYPE_LENGTH (builtin_type (gdbarch)->builtin_double))
+ info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_double);
else
- info->align = TYPE_LENGTH (builtin_type_long);
+ info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
break;
case TYPE_CODE_STRUCT:
default:
- info->align = TYPE_LENGTH (builtin_type_long);
+ info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
break;
}
info->length = TYPE_LENGTH (arg_type);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (36 preceding siblings ...)
2008-08-31 18:16 ` [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files uweigand
@ 2008-08-31 22:20 ` Mark Kettenis
2008-09-01 3:46 ` David Miller
2008-09-01 18:57 ` Ulrich Weigand
2008-09-02 12:50 ` Daniel Jacobowitz
2008-09-06 3:16 ` Joel Brobecker
39 siblings, 2 replies; 98+ messages in thread
From: Mark Kettenis @ 2008-08-31 22:20 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> Date: Sun, 31 Aug 2008 19:50:45 +0200
> From: uweigand@de.ibm.com
>
> Hello,
>
> one of the last remaining "implicit" uses of current_gdbarch is the
> builtin_type_ macros. This patch set completely removes those macros.
>
> I've attempted to not simply replace those types with explict uses of
> current_gdbarch, but instead choose the proper architecture to use:
>
> - I've added a gdbarch pointer to struct expression, and used this
> per-expression arch throughout expression parsing and evaluation.
> - I've converted some types (like builtin_void_type) back to be
> platform-neutral, so they can be freely used throughout GDB.
> - In many cases, an existing per-frame or per-objfile arch was available
> (or could be made available) and should be used.
> - Target-specific code should use target_gdbarch.
> - In a very small number of case, current_gdbarch remains for now.
>
> Each of the following patches contains a more specific explanation.
>
> Combination of all 37 patches tested on amd64-linux, s390-ibm-linux,
> s390x-ibm-linux, powerpc-linux, powerpc64-linux, and spu-elf with no
> regressions. Also, compile-tested with --enable-targets=all (each
> patch by itself).
>
> I'd be interested in particular in feedback from the Ada maintainers
> on the Ada-related changes in this patch-set.
>
> What do you think?
I've probably had one piwo too many at this point, but can we please
stop this Linux [x/zillion] crap? You can't seriously pretend there
are really 37 independent diffs that people would want to review
and/or test can you?
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
@ 2008-09-01 3:46 ` David Miller
2008-09-01 18:57 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: David Miller @ 2008-09-01 3:46 UTC (permalink / raw)
To: mark.kettenis; +Cc: uweigand, gdb-patches
From: Mark Kettenis <mark.kettenis@xs4all.nl>
Date: Mon, 1 Sep 2008 00:18:16 +0200 (CEST)
> I've probably had one piwo too many at this point, but can we please
> stop this Linux [x/zillion] crap? You can't seriously pretend there
> are really 37 independent diffs that people would want to review
> and/or test can you?
Why is it crap to split up a large harder to review (and bisect)
change into bite size (easier to review and later bisect) independant
pieces? And why is it purely labelled as "a Linux thing" to split up
a large patch this way? I've seen this submission technique used in
many other projects.
If a reviewer doesn't have time to review the whole bit, they can
choose to look at one a few or even just one of them, when it is
split up like this.
What if later there is a regression and someone tries to bisect
through this change? If we have just one huge one it's harder to
figure out which of the 37 parts caused the problem, whereas if
we could bisect to one of these 37 pieces, we'd know precisely which
part added the regression.
That is just smart development as far as I can see.
The response I am seeing seems like a negative knee jerk reaction to
me. I post sets of 50 patches at a time frequently for some of my
work, and it eases the reviewer burdon tremendously.
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
@ 2008-09-01 7:19 ` Tom Tromey
2008-09-02 23:34 ` Ulrich Weigand
2008-09-05 23:02 ` Joel Brobecker
1 sibling, 1 reply; 98+ messages in thread
From: Tom Tromey @ 2008-09-01 7:19 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
Ulrich> GDB allows to dereference an integer type, treating it as if
Ulrich> it were an "int *".
Ulrich> It might make sense to check for which languages this extension
Ulrich> is actually useful, and remove it from the rest.
Ulrich> * jv-lang.c (evaluate_subexp_java): Likewise.
FWIW -- I couldn't come up with a situation where this extension makes
sense for Java. I'm certain I have never used it while debugging Java
code.
Tom
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
2008-09-01 3:46 ` David Miller
@ 2008-09-01 18:57 ` Ulrich Weigand
2008-09-02 10:22 ` Mark Kettenis
1 sibling, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-01 18:57 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis wrote:
> I've probably had one piwo too many at this point, but can we please
> stop this Linux [x/zillion] crap? You can't seriously pretend there
> are really 37 independent diffs that people would want to review
> and/or test can you?
Actually, the patches *do* touch mostly independent areas of GDB,
and I'd expect different maintainers to want to review only some
of them. I've spent some effort to try to separate out functional
changes, in the hope of making review simpler ...
As to *testing*, I agree that having to apply 37 patches in sequence
is a pain, which is why I sent -in addition to the broken-out series-
a single cumulative patch as well.
In the end, this is simply a large set of changes (the cumulative patch
is 8000 lines, the broken-out patches total 10000 lines) spread out
across many parts of GDB (the patch set touches 97 files) -- if you have
suggestions how to present a change like this in a way that's easier to
review, those would certainly be welcome.
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] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-01 18:57 ` Ulrich Weigand
@ 2008-09-02 10:22 ` Mark Kettenis
2008-09-02 12:30 ` Daniel Jacobowitz
2008-09-02 21:37 ` Ulrich Weigand
0 siblings, 2 replies; 98+ messages in thread
From: Mark Kettenis @ 2008-09-02 10:22 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> Date: Mon, 1 Sep 2008 20:56:41 +0200 (CEST)
> From: "Ulrich Weigand" <uweigand@de.ibm.com>
>
> Mark Kettenis wrote:
>
> > I've probably had one piwo too many at this point, but can we please
> > stop this Linux [x/zillion] crap? You can't seriously pretend there
> > are really 37 independent diffs that people would want to review
> > and/or test can you?
>
> Actually, the patches *do* touch mostly independent areas of GDB,
> and I'd expect different maintainers to want to review only some
> of them. I've spent some effort to try to separate out functional
> changes, in the hope of making review simpler ...
Let me say that even if I think it doesn't really help, I apreciate
the effort.
> As to *testing*, I agree that having to apply 37 patches in sequence
> is a pain, which is why I sent -in addition to the broken-out series-
> a single cumulative patch as well.
Yes, that was a good thing to do. I apologize for sending the message
I sent yesterday evening before reading all my mail.
> In the end, this is simply a large set of changes (the cumulative patch
> is 8000 lines, the broken-out patches total 10000 lines) spread out
> across many parts of GDB (the patch set touches 97 files) -- if you have
> suggestions how to present a change like this in a way that's easier to
> review, those would certainly be welcome.
I don't think there is much you can do about it. A large set of
fairly mechanical changes is simply a large set of mechanical changes.
It's probably good if people have a look at part of the diff, but in
the end we'll just have to trust that the job was done properly and
that it gets committed (preferably after people have tested it).
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-02 10:22 ` Mark Kettenis
@ 2008-09-02 12:30 ` Daniel Jacobowitz
2008-09-02 21:37 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 12:30 UTC (permalink / raw)
To: Mark Kettenis; +Cc: uweigand, gdb-patches
On Tue, Sep 02, 2008 at 12:20:44PM +0200, Mark Kettenis wrote:
> I don't think there is much you can do about it. A large set of
> fairly mechanical changes is simply a large set of mechanical changes.
> It's probably good if people have a look at part of the diff, but in
> the end we'll just have to trust that the job was done properly and
> that it gets committed (preferably after people have tested it).
I agree. FWIW, I found this helpful - there was one problem in
particular where I wanted to see Ulrich's solution, and I was able to
find it easily :-)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
@ 2008-09-02 12:38 ` Daniel Jacobowitz
2008-09-02 21:48 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 12:38 UTC (permalink / raw)
To: gdb-patches
On Sun, Aug 31, 2008 at 07:50:53PM +0200, Ulrich Weigand wrote:
> Hello,
>
> this patch removes the functions value_add and value_sub which handle
> both integer and pointer arithmetic, and replaces them by functions
> value_ptradd, value_ptrsub, and value_ptrdiff that solely take care
> of C-style pointer arithmetic. (For integer arithmetic, value_binop
> can be used.)
>
> This moves the type to be used for pointer difference operations up
> eval.c (this should at some point be replaces by a per-gdbarch
> "ptrdiff_t" type). It also makes the subsequent patches to remove
> current_gdbarch references from value_binop simpler.
I've got to say I don't like the direction of this change :-(
Smarts in the expression parser are not available to reuse by other
code that constructs values - which is something I think we should be
doing more often. Why should the caller have to know that the two
values are pointers?
> @@ -1531,8 +1556,19 @@ evaluate_subexp_standard (struct type *e
> goto nosideret;
> if (binop_user_defined_p (op, arg1, arg2))
> return value_x_binop (arg1, arg2, op, OP_NULL, noside);
> + else if (ptrmath_type_p (value_type (arg1))
> + && ptrmath_type_p (value_type (arg2)))
> + {
> + /* FIXME -- should be ptrdiff_t */
> + type = builtin_type (exp->gdbarch)->builtin_long;
> + return value_from_longest (type, value_ptrdiff (arg1, arg2));
> + }
> + else if (ptrmath_type_p (value_type (arg1)))
> + return value_ptrsub (arg1, arg2);
> + else if (ptrmath_type_p (value_type (arg2)))
> + return value_ptrsub (arg2, arg1);
> else
> - return value_sub (arg1, arg2);
> + return value_binop (arg1, arg2, BINOP_SUB);
>
> case BINOP_EXP:
> case BINOP_MUL:
There's something wrong in the last else if; arg1 - arg2 != arg2 - arg1.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
@ 2008-09-02 12:43 ` Daniel Jacobowitz
2008-09-02 21:55 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 12:43 UTC (permalink / raw)
To: gdb-patches
On Sun, Aug 31, 2008 at 07:51:08PM +0200, Ulrich Weigand wrote:
> One problem is the $_ variable, which holds a pointer value. To
> allow using a platform-neutral type for this, I'm introducing a
> new platform-neutral pointer type builtin_type_void_ptr. The
> lenght of this type is chosen so that it can hold every CORE_ADDR
> value.
I don't think this is a good idea. Target-specific code should not be
required to correctly handle jumbo pointers, e.g. in "(gdb) print
foo ($_)". In a command function, we must already have some idea of
what the associated architecture is (e.g. to initialize the
architecture used by the expression evaluator); why not use that?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
@ 2008-09-02 12:48 ` Daniel Jacobowitz
2008-09-02 21:56 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 12:48 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
On Sun, Aug 31, 2008 at 07:51:13PM +0200, Ulrich Weigand wrote:
> @@ -472,6 +469,9 @@ call_function_by_hand (struct value *fun
> funaddr = find_function_addr (function, &values_type);
> CHECK_TYPEDEF (values_type);
>
> + if (!values_type)
> + values_type = builtin_type (gdbarch)->builtin_int;
> +
> /* Are we returning a value using a structure return (passing a
> hidden argument pointing to storage) or a normal value return?
> There are two cases: language-mandated structure return and
CHECK_TYPEDEF -> gdb_assert (type).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (37 preceding siblings ...)
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
@ 2008-09-02 12:50 ` Daniel Jacobowitz
2008-09-02 22:02 ` Ulrich Weigand
2008-09-06 3:16 ` Joel Brobecker
39 siblings, 1 reply; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 12:50 UTC (permalink / raw)
To: gdb-patches
On Sun, Aug 31, 2008 at 07:50:45PM +0200, Ulrich Weigand wrote:
> What do you think?
All the others I didn't respond to look OK to me. I'm mildly
concerned about the contortions you had to go through; it becomes hard
to get at the architecture in new places. But we'll have to see how
that works out in practice.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-02 10:22 ` Mark Kettenis
2008-09-02 12:30 ` Daniel Jacobowitz
@ 2008-09-02 21:37 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 21:37 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis wrote:
> > As to *testing*, I agree that having to apply 37 patches in sequence
> > is a pain, which is why I sent -in addition to the broken-out series-
> > a single cumulative patch as well.
>
> Yes, that was a good thing to do. I apologize for sending the message
> I sent yesterday evening before reading all my mail.
No problem -- I appreciate the feedback.
> > In the end, this is simply a large set of changes (the cumulative patch
> > is 8000 lines, the broken-out patches total 10000 lines) spread out
> > across many parts of GDB (the patch set touches 97 files) -- if you have
> > suggestions how to present a change like this in a way that's easier to
> > review, those would certainly be welcome.
>
> I don't think there is much you can do about it. A large set of
> fairly mechanical changes is simply a large set of mechanical changes.
> It's probably good if people have a look at part of the diff, but in
> the end we'll just have to trust that the job was done properly and
> that it gets committed (preferably after people have tested it).
The thing is, parts of the patch set (e.g. the -tdep.c changes) are
indeed completely mechanical changes. However, in other places I am
making definite design choices (e.g. should an expression really be
something architecture-neutral, or explicitly platform-specific?).
One important reason for splitting the patch set up is in fact to
avoid such design choices being swamped and overlooked within a
single large, mostly mechanical patch ...
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] 98+ messages in thread
* Re: [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-09-02 12:38 ` Daniel Jacobowitz
@ 2008-09-02 21:48 ` Ulrich Weigand
2008-09-02 21:52 ` Daniel Jacobowitz
2008-09-04 22:32 ` Tom Tromey
0 siblings, 2 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 21:48 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> > This moves the type to be used for pointer difference operations up
> > eval.c (this should at some point be replaces by a per-gdbarch
> > "ptrdiff_t" type). It also makes the subsequent patches to remove
> > current_gdbarch references from value_binop simpler.
>
> I've got to say I don't like the direction of this change :-(
>
> Smarts in the expression parser are not available to reuse by other
> code that constructs values - which is something I think we should be
> doing more often. Why should the caller have to know that the two
> values are pointers?
Lets put the question differently: Why should the generic "add" routine
of a debugger supporting many languages have hard-coded semantics that
are specific to C (and in fact, the C ABI on a specific platform)?
I was trying to make the "value_*" routines be as much as possible
language- and architecture-independent, and push language- and
architecture-specific semantics up to higher layers. (In this case,
the expression evaluator. In fact, I might like it even better if
expressions themselves were also language-agnostic, and all the
language-specific semantics were encoded explicitly into different
operand codes by the parsers ...)
As to your question: when replacing uses of value_add, every caller
*knew* whether the arguments were pointers or scalars (exept for the
generic expression evaluator, of course). GDB-internal uses do not
really assume the C-specific overloading of the "+" operator ...
> > @@ -1531,8 +1556,19 @@ evaluate_subexp_standard (struct type *e
> > goto nosideret;
> > if (binop_user_defined_p (op, arg1, arg2))
> > return value_x_binop (arg1, arg2, op, OP_NULL, noside);
> > + else if (ptrmath_type_p (value_type (arg1))
> > + && ptrmath_type_p (value_type (arg2)))
> > + {
> > + /* FIXME -- should be ptrdiff_t */
> > + type = builtin_type (exp->gdbarch)->builtin_long;
> > + return value_from_longest (type, value_ptrdiff (arg1, arg2));
> > + }
> > + else if (ptrmath_type_p (value_type (arg1)))
> > + return value_ptrsub (arg1, arg2);
> > + else if (ptrmath_type_p (value_type (arg2)))
> > + return value_ptrsub (arg2, arg1);
> > else
> > - return value_sub (arg1, arg2);
> > + return value_binop (arg1, arg2, BINOP_SUB);
> >
> > case BINOP_EXP:
> > case BINOP_MUL:
>
> There's something wrong in the last else if; arg1 - arg2 != arg2 - arg1.
Oops. That last case "integer - pointer" is not allowed in C anyway;
this should throw an error (the old code did as well; this is a bug
introduced by my change). I'll fix that ...
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] 98+ messages in thread
* Re: [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-09-02 21:48 ` Ulrich Weigand
@ 2008-09-02 21:52 ` Daniel Jacobowitz
2008-09-04 22:32 ` Tom Tromey
1 sibling, 0 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 21:52 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Tue, Sep 02, 2008 at 11:47:08PM +0200, Ulrich Weigand wrote:
> Lets put the question differently: Why should the generic "add" routine
> of a debugger supporting many languages have hard-coded semantics that
> are specific to C (and in fact, the C ABI on a specific platform)?
>
> I was trying to make the "value_*" routines be as much as possible
> language- and architecture-independent, and push language- and
> architecture-specific semantics up to higher layers. (In this case,
> the expression evaluator. In fact, I might like it even better if
> expressions themselves were also language-agnostic, and all the
> language-specific semantics were encoded explicitly into different
> operand codes by the parsers ...)
Yes, that would be nice - but I think we'd need a different
parsing system then; for instance, to do C++ overloading at the right
time.
> As to your question: when replacing uses of value_add, every caller
> *knew* whether the arguments were pointers or scalars (exept for the
> generic expression evaluator, of course). GDB-internal uses do not
> really assume the C-specific overloading of the "+" operator ...
OK, that's good enough for me. I agree it would be nice to define
what the value operators do. We'll be exposing them to Python, and
I want to be able to document sanely in the manual what happens if you
add an integer and a pointer :-)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables
2008-09-02 12:43 ` Daniel Jacobowitz
@ 2008-09-02 21:55 ` Ulrich Weigand
2008-09-02 22:00 ` Daniel Jacobowitz
2008-09-02 23:53 ` Ulrich Weigand
0 siblings, 2 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 21:55 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Sun, Aug 31, 2008 at 07:51:08PM +0200, Ulrich Weigand wrote:
> > One problem is the $_ variable, which holds a pointer value. To
> > allow using a platform-neutral type for this, I'm introducing a
> > new platform-neutral pointer type builtin_type_void_ptr. The
> > lenght of this type is chosen so that it can hold every CORE_ADDR
> > value.
>
> I don't think this is a good idea. Target-specific code should not be
> required to correctly handle jumbo pointers, e.g. in "(gdb) print
> foo ($_)". In a command function, we must already have some idea of
> what the associated architecture is (e.g. to initialize the
> architecture used by the expression evaluator); why not use that?
I guess that would mean current_gdbarch for now. However, I had been
wondering what that means for the multi-architecture case -- if you
set $_ in one frame, and then switch to a frame using a different
architecture and use $_ as inferior call argument there, we'll still
get pointers the architecture doesn't understand ...
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] 98+ messages in thread
* Re: [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines
2008-09-02 12:48 ` Daniel Jacobowitz
@ 2008-09-02 21:56 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 21:56 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Sun, Aug 31, 2008 at 07:51:13PM +0200, Ulrich Weigand wrote:
> > @@ -472,6 +469,9 @@ call_function_by_hand (struct value *fun
> > funaddr = find_function_addr (function, &values_type);
> > CHECK_TYPEDEF (values_type);
> >
> > + if (!values_type)
> > + values_type = builtin_type (gdbarch)->builtin_int;
> > +
> > /* Are we returning a value using a structure return (passing a
> > hidden argument pointing to storage) or a normal value return?
> > There are two cases: language-mandated structure return and
>
> CHECK_TYPEDEF -> gdb_assert (type).
Oops. Thanks for catching this; I'll fix it.
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] 98+ messages in thread
* Re: [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables
2008-09-02 21:55 ` Ulrich Weigand
@ 2008-09-02 22:00 ` Daniel Jacobowitz
2008-09-02 23:53 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 22:00 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Tue, Sep 02, 2008 at 11:54:15PM +0200, Ulrich Weigand wrote:
> I guess that would mean current_gdbarch for now. However, I had been
> wondering what that means for the multi-architecture case -- if you
> set $_ in one frame, and then switch to a frame using a different
> architecture and use $_ as inferior call argument there, we'll still
> get pointers the architecture doesn't understand ...
Yes indeed. But this problem's not specific to $_; you could get it
by calling a function from the other architecture or using a variable
from the history.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-02 12:50 ` Daniel Jacobowitz
@ 2008-09-02 22:02 ` Ulrich Weigand
2008-09-02 22:12 ` Daniel Jacobowitz
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 22:02 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Sun, Aug 31, 2008 at 07:50:45PM +0200, Ulrich Weigand wrote:
> > What do you think?
>
> All the others I didn't respond to look OK to me.
Thanks for looking over them!
> I'm mildly
> concerned about the contortions you had to go through; it becomes hard
> to get at the architecture in new places. But we'll have to see how
> that works out in practice.
To some extent, there is a choice of direction here. Today, we have a
number of low-level routines that have implicit dependency on the
"current" architecture. To fix this, there are really two directions:
- Re-define the lower-level parts to be architecture-independent, and
push architecture-dependent semantics up.
or
- Make lower-level entities *explicitly* architecture-specific
For example, should a "value" be platform-neutral or platform-specific?
If value is platform-neutral, we'll need to take explicit care at the
locations where values get in contact with platform-specific code, e.g.
when loading/storing from target memory. If value is platform-specific,
it should probably carry an explicit gdbarch pointer. Then we can -in
a multi-arch setting- get into the situation what to do with values of
a different architecture than the current frame ...
With this patch-set, I've made "expression" explicitly platform-specific,
but tried to keep "value" and "type" more platform-independent. I guess
we'll have to see if this is right choice.
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] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-02 22:02 ` Ulrich Weigand
@ 2008-09-02 22:12 ` Daniel Jacobowitz
0 siblings, 0 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 22:12 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Wed, Sep 03, 2008 at 12:01:55AM +0200, Ulrich Weigand wrote:
> With this patch-set, I've made "expression" explicitly platform-specific,
> but tried to keep "value" and "type" more platform-independent. I guess
> we'll have to see if this is right choice.
It makes sense to me, after some staring at it. I think the right
approach is to make the common cases straightforward, and reject some
of the hardest cases - for instance, I don't know that a single
expression calling functions belonging to two different architectures
will ever matter, in practice.
[Watch the Cell debugger prove me wrong...]
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types
2008-09-01 7:19 ` Tom Tromey
@ 2008-09-02 23:34 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 23:34 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
Tom Tromey wrote:
> >>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
>
> Ulrich> GDB allows to dereference an integer type, treating it as if
> Ulrich> it were an "int *".
>
> Ulrich> It might make sense to check for which languages this extension
> Ulrich> is actually useful, and remove it from the rest.
>
> Ulrich> * jv-lang.c (evaluate_subexp_java): Likewise.
>
> FWIW -- I couldn't come up with a situation where this extension makes
> sense for Java. I'm certain I have never used it while debugging Java
> code.
Fine with me -- I'll leave the jv-lang.c part out then.
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] 98+ messages in thread
* Re: [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables
2008-09-02 21:55 ` Ulrich Weigand
2008-09-02 22:00 ` Daniel Jacobowitz
@ 2008-09-02 23:53 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-02 23:53 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Daniel Jacobowitz wrote:
> > On Sun, Aug 31, 2008 at 07:51:08PM +0200, Ulrich Weigand wrote:
> > > One problem is the $_ variable, which holds a pointer value. To
> > > allow using a platform-neutral type for this, I'm introducing a
> > > new platform-neutral pointer type builtin_type_void_ptr. The
> > > lenght of this type is chosen so that it can hold every CORE_ADDR
> > > value.
> >
> > I don't think this is a good idea. Target-specific code should not be
> > required to correctly handle jumbo pointers, e.g. in "(gdb) print
> > foo ($_)". In a command function, we must already have some idea of
> > what the associated architecture is (e.g. to initialize the
> > architecture used by the expression evaluator); why not use that?
>
> I guess that would mean current_gdbarch for now.
Like below. Once we eliminate current_gdbarch in command functions,
those new instances introduces below can go away again ...
Bye,
Ulrich
ChangeLog:
* defs.h (struct gdbarch): Add forward declaration.
(set_next_address): Add GDBARCH argument.
* printcmd.c (set_next_address): Use it to find pointer type.
* breakpoint.c (breakpoint_1): Update call.
* source.c (line_info): Likewise.
* findcmd.c (find_command): Use current_gdbarch to find pointer type.
* breakpoint.c (set_breakpoint_count): Use platform-neutral
types for internal variable values.
* infrun.c (handle_inferior_event): Likewise.
* source.c (forward_search_command, reverse_search_command): Likewise.
* tracepoint.c (set_tracepoint_count, set_traceframe_num,
set_tracepoint_num, set_traceframe_context): Likewise.
Index: gdb-head/gdb/breakpoint.c
===================================================================
--- gdb-head.orig/gdb/breakpoint.c
+++ gdb-head/gdb/breakpoint.c
@@ -401,7 +401,7 @@ set_breakpoint_count (int num)
{
breakpoint_count = num;
set_internalvar (lookup_internalvar ("bpnum"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Used in run_command to zero the hit count when a new run starts. */
@@ -4017,7 +4017,7 @@ breakpoint_1 (int bnum, int allflag)
/* Compare against (CORE_ADDR)-1 in case some compiler decides
that a comparison of an unsigned with -1 is always false. */
if (last_addr != (CORE_ADDR) -1 && !server_command)
- set_next_address (last_addr);
+ set_next_address (current_gdbarch, last_addr);
}
/* FIXME? Should this be moved up so that it is only called when
Index: gdb-head/gdb/findcmd.c
===================================================================
--- gdb-head.orig/gdb/findcmd.c
+++ gdb-head/gdb/findcmd.c
@@ -292,13 +292,14 @@ find_command (char *args, int from_tty)
/* Record and print the results. */
set_internalvar (lookup_internalvar ("numfound"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) found_count));
if (found_count > 0)
{
+ struct gdbarch *gdbarch = current_gdbarch;
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
set_internalvar (lookup_internalvar ("_"),
- value_from_pointer (builtin_type_void_data_ptr,
- last_found_addr));
+ value_from_pointer (ptr_type, last_found_addr));
}
if (found_count == 0)
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -2017,7 +2017,7 @@ handle_inferior_event (struct execution_
/* Record the exit code in the convenience variable $_exitcode, so
that the user can inspect this again later. */
set_internalvar (lookup_internalvar ("_exitcode"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) ecs->ws.value.integer));
gdb_flush (gdb_stdout);
target_mourn_inferior ();
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -503,13 +503,15 @@ print_scalar_formatted (const void *vala
The `info lines' command uses this. */
void
-set_next_address (CORE_ADDR addr)
+set_next_address (struct gdbarch *gdbarch, CORE_ADDR addr)
{
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
next_address = addr;
/* Make address available to the user as $_. */
set_internalvar (lookup_internalvar ("_"),
- value_from_pointer (builtin_type_void_data_ptr, addr));
+ value_from_pointer (ptr_type, addr));
}
/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
Index: gdb-head/gdb/source.c
===================================================================
--- gdb-head.orig/gdb/source.c
+++ gdb-head/gdb/source.c
@@ -1511,7 +1511,7 @@ line_info (char *arg, int from_tty)
}
/* x/i should display this line's code. */
- set_next_address (start_pc);
+ set_next_address (current_gdbarch, start_pc);
/* Repeating "info line" should do the following line. */
last_line_listed = sal.line + 1;
@@ -1614,7 +1614,7 @@ forward_search_command (char *regex, int
fclose (stream);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) line));
current_source_line = max (line - lines_to_list / 2, 1);
return;
@@ -1696,7 +1696,7 @@ reverse_search_command (char *regex, int
fclose (stream);
print_source_lines (current_source_symtab, line, line + 1, 0);
set_internalvar (lookup_internalvar ("_"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) line));
current_source_line = max (line - lines_to_list / 2, 1);
return;
Index: gdb-head/gdb/tracepoint.c
===================================================================
--- gdb-head.orig/gdb/tracepoint.c
+++ gdb-head/gdb/tracepoint.c
@@ -220,7 +220,7 @@ set_tracepoint_count (int num)
{
tracepoint_count = num;
set_internalvar (lookup_internalvar ("tpnum"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set traceframe number to NUM. */
@@ -229,7 +229,7 @@ set_traceframe_num (int num)
{
traceframe_number = num;
set_internalvar (lookup_internalvar ("trace_frame"),
- value_from_longest (builtin_type_int, (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set tracepoint number to NUM. */
@@ -238,8 +238,7 @@ set_tracepoint_num (int num)
{
tracepoint_number = num;
set_internalvar (lookup_internalvar ("tracepoint"),
- value_from_longest (builtin_type_int,
- (LONGEST) num));
+ value_from_longest (builtin_type_int32, (LONGEST) num));
}
/* Set externally visible debug variables for querying/printing
@@ -252,23 +251,19 @@ set_traceframe_context (CORE_ADDR trace_
static struct type *func_range, *file_range;
struct value *func_val;
struct value *file_val;
- static struct type *charstar;
int len;
- if (charstar == (struct type *) NULL)
- charstar = lookup_pointer_type (builtin_type_char);
-
if (trace_pc == -1) /* Cease debugging any trace buffers. */
{
traceframe_fun = 0;
traceframe_sal.pc = traceframe_sal.line = 0;
traceframe_sal.symtab = NULL;
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_pointer (charstar, (LONGEST) 0));
+ allocate_value (builtin_type_void));
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_pointer (charstar, (LONGEST) 0));
+ allocate_value (builtin_type_void));
set_internalvar (lookup_internalvar ("trace_line"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) - 1));
return;
}
@@ -280,7 +275,7 @@ set_traceframe_context (CORE_ADDR trace_
/* Save linenumber as "$trace_line", a debugger variable visible to
users. */
set_internalvar (lookup_internalvar ("trace_line"),
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
(LONGEST) traceframe_sal.line));
/* Save func name as "$trace_func", a debugger variable visible to
@@ -288,14 +283,14 @@ set_traceframe_context (CORE_ADDR trace_
if (traceframe_fun == NULL ||
SYMBOL_LINKAGE_NAME (traceframe_fun) == NULL)
set_internalvar (lookup_internalvar ("trace_func"),
- value_from_pointer (charstar, (LONGEST) 0));
+ allocate_value (builtin_type_void));
else
{
len = strlen (SYMBOL_LINKAGE_NAME (traceframe_fun));
func_range = create_range_type (func_range,
- builtin_type_int, 0, len - 1);
+ builtin_type_int32, 0, len - 1);
func_string = create_array_type (func_string,
- builtin_type_char, func_range);
+ builtin_type_true_char, func_range);
func_val = allocate_value (func_string);
deprecated_set_value_type (func_val, func_string);
memcpy (value_contents_raw (func_val),
@@ -310,14 +305,14 @@ set_traceframe_context (CORE_ADDR trace_
if (traceframe_sal.symtab == NULL ||
traceframe_sal.symtab->filename == NULL)
set_internalvar (lookup_internalvar ("trace_file"),
- value_from_pointer (charstar, (LONGEST) 0));
+ allocate_value (builtin_type_void));
else
{
len = strlen (traceframe_sal.symtab->filename);
file_range = create_range_type (file_range,
- builtin_type_int, 0, len - 1);
+ builtin_type_int32, 0, len - 1);
file_string = create_array_type (file_string,
- builtin_type_char, file_range);
+ builtin_type_true_char, file_range);
file_val = allocate_value (file_string);
deprecated_set_value_type (file_val, file_string);
memcpy (value_contents_raw (file_val),
Index: gdb-head/gdb/defs.h
===================================================================
--- gdb-head.orig/gdb/defs.h
+++ gdb-head/gdb/defs.h
@@ -298,6 +298,7 @@ struct cleanup
struct symtab;
struct breakpoint;
struct frame_info;
+struct gdbarch;
/* From utils.c */
@@ -570,7 +571,7 @@ extern int info_verbose;
/* From printcmd.c */
-extern void set_next_address (CORE_ADDR);
+extern void set_next_address (struct gdbarch *, CORE_ADDR);
extern void print_address_symbolic (CORE_ADDR, struct ui_file *, int,
char *);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-09-02 21:48 ` Ulrich Weigand
2008-09-02 21:52 ` Daniel Jacobowitz
@ 2008-09-04 22:32 ` Tom Tromey
2008-09-05 18:21 ` Joel Brobecker
1 sibling, 1 reply; 98+ messages in thread
From: Tom Tromey @ 2008-09-04 22:32 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Daniel Jacobowitz, gdb-patches
>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
Ulrich> I was trying to make the "value_*" routines be as much as possible
Ulrich> language- and architecture-independent, and push language- and
Ulrich> architecture-specific semantics up to higher layers. (In this case,
Ulrich> the expression evaluator. In fact, I might like it even better if
Ulrich> expressions themselves were also language-agnostic, and all the
Ulrich> language-specific semantics were encoded explicitly into different
Ulrich> operand codes by the parsers ...)
FWIW, I also would prefer this approach. I think the primary benefit
is fewer dependencies between modules.
Tom
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
@ 2008-09-05 18:08 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 18:08 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> * language.c (lang_bool_type): Remove.
> (language_bool_type): New function.
I was hoping we could cache the boolean type, but I guess it can get
stale every time we load or unload a symbol file...
> case TYPE_CODE_RANGE:
> arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> arg3 = value_from_longest (builtin_type_int,
> TYPE_HIGH_BOUND (type));
> + type = language_bool_type (exp->language_defn, exp->gdbarch);
> return
> - value_from_longest (builtin_type_int,
> + value_from_longest (type,
> (value_less (arg1, arg3)
> || value_equal (arg1, arg3))
> && (value_less (arg2, arg1)
Nice improvement - the returning of a boolean type instead of an int :).
It should transform:
(gdb) print 2 in 1 .. 3
$1 = 1
Hopefully into:`
(gdb) print 2 in 1 .. 3
$1 = true
Thanks!
Your patch also allowed me to notice something else: I also think that
I'll explore the idea of using value_in() instead of the combination of
value_less/value_equal/[...]. Separate patch, though.
No further comment, your honor...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
@ 2008-09-05 18:16 ` Joel Brobecker
2008-09-05 20:17 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 18:16 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> * valarith.h (value_bitstring_subscript): New function.
> (value_subscript): No longer handle TYPE_CODE_BITSTRING.
Perhaps it would be worth mentioning in the function description
that it no longer handle bitstrings?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
@ 2008-09-05 18:18 ` Joel Brobecker
2008-09-05 20:16 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 18:18 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> + /* FIXME: This should size_t. */
Missing verb?
> + struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit
2008-09-04 22:32 ` Tom Tromey
@ 2008-09-05 18:21 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 18:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: Ulrich Weigand, Daniel Jacobowitz, gdb-patches
> Ulrich> I was trying to make the "value_*" routines be as much as possible
> Ulrich> language- and architecture-independent, and push language- and
> Ulrich> architecture-specific semantics up to higher layers. (In this case,
> Ulrich> the expression evaluator. In fact, I might like it even better if
> Ulrich> expressions themselves were also language-agnostic, and all the
> Ulrich> language-specific semantics were encoded explicitly into different
> Ulrich> operand codes by the parsers ...)
>
> FWIW, I also would prefer this approach.
Same here - generally speaking. There might be cases like Daniel says
where we're not ready for that (yet?), but that's definitely a goal
at least as far as Ada support has been concerned.
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type
2008-09-05 18:18 ` Joel Brobecker
@ 2008-09-05 20:16 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-05 20:16 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> > + /* FIXME: This should size_t. */
>
> Missing verb?
Fixed, thanks!
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] 98+ messages in thread
* Re: [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling
2008-09-05 18:16 ` Joel Brobecker
@ 2008-09-05 20:17 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-05 20:17 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> > * valarith.h (value_bitstring_subscript): New function.
> > (value_subscript): No longer handle TYPE_CODE_BITSTRING.
>
> Perhaps it would be worth mentioning in the function description
> that it no longer handle bitstrings?
Makes sense. I've added the following text:
@@ -171,6 +171,11 @@ an integer nor a pointer of the same typ
}
/* Return the value of ARRAY[IDX].
+
+ ARRAY may be of type TYPE_CODE_ARRAY or TYPE_CODE_STRING. If the
+ current language supports C-style arrays, it may also be TYPE_CODE_PTR.
+ To access TYPE_CODE_BITSTRING values, use value_bitstring_subscript.
+
See comments in value_coerce_array() for rationale for reason for
doing lower bounds adjustment here rather than there.
FIXME: Perhaps we should validate that the index is valid and if
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] 98+ messages in thread
* Re: [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
@ 2008-09-05 20:18 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-05 20:18 UTC (permalink / raw)
To: gdb-patches
> gnu-v3-abi.c uses current_gdbarch and builtin_type_ macros to determine
> ABI properties of the C++ class implementation. The following patch
> removes the dependency on the current_gdbarch variable by using the
> architecture associated with the objfile where the class type is defined.
This patch no longer applies after the recent method-ptr change:
http://sourceware.org/ml/gdb-patches/2008-09/msg00059.html
The updated version follows.
Bye,
Ulrich
* cp-abi.h (cplus_method_ptr_size): Add TO_TYPE parameter.
(cplus_make_method_ptr): Add TYPE parameter.
* cp-abi.c (cplus_method_ptr_size): Add TO_TYPE parameter. Pass it
on to current_cp_abi.method_ptr_size callback.
(cplus_make_method_ptr): Add TYPE parameter. Pass it on to
current_cp_abi.make_method_ptr callback.
* gdbtypes.c (lookup_methodptr_type): Pass target type
argument to cplus_method_ptr_size.
* valops.c (value_cast): Pass type argument to cplus_make_method_ptr.
(value_struct_elt_for_reference): Likewise.
* gnu-v3-abi.c (get_class_arch): New function.
(vtable_address_point_offset): Add GDBARCH parameter. Use it
instead of current_gdbarch. Update all callers.
(gnuv3_get_vtable): Likewise.
(gnuv3_get_virtual_fn): Likewise.
(gnuv3_decode_method_ptr): Likewise.
(gnuv3_rtti_type): Call get_class_arch to determine architecture.
Use it instead of current_gdbarch.
(gnuv3_virtual_fn_field): Likewise.
(gnuv3_baseclass_offset): Likewise.
(gnuv3_print_method_ptr): Likewise.
(gnuv3_method_ptr_to_value): Likewise.
(gnuv3_method_ptr_size): Add TYPE parameter. Use it to determine
class architecture. Use architecture types instead of builtin types.
(gnuv3_make_method_ptr): Likewise.
* cp-valprint.c (cp_print_class_member): Expect pointer type
instead of class type. Use its length when extracting value.
* c-valprint.c (c_val_print): Update call to cp_print_class_member.
Index: gdb-head/gdb/cp-abi.c
===================================================================
--- gdb-head.orig/gdb/cp-abi.c
+++ gdb-head/gdb/cp-abi.c
@@ -113,19 +113,20 @@ cplus_print_method_ptr (const gdb_byte *
}
int
-cplus_method_ptr_size (void)
+cplus_method_ptr_size (struct type *to_type)
{
if (current_cp_abi.method_ptr_size == NULL)
error (_("GDB does not support pointers to methods on this target"));
- return (*current_cp_abi.method_ptr_size) ();
+ return (*current_cp_abi.method_ptr_size) (to_type);
}
void
-cplus_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+cplus_make_method_ptr (struct type *type, gdb_byte *contents,
+ CORE_ADDR value, int is_virtual)
{
if (current_cp_abi.make_method_ptr == NULL)
error (_("GDB does not support pointers to methods on this target"));
- (*current_cp_abi.make_method_ptr) (contents, value, is_virtual);
+ (*current_cp_abi.make_method_ptr) (type, contents, value, is_virtual);
}
CORE_ADDR
Index: gdb-head/gdb/cp-abi.h
===================================================================
--- gdb-head.orig/gdb/cp-abi.h
+++ gdb-head/gdb/cp-abi.h
@@ -151,21 +151,20 @@ extern int baseclass_offset (struct type
void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
struct ui_file *stream);
-/* Return the size of a pointer to member function for the current
- architecture. */
-int cplus_method_ptr_size (void);
+/* Return the size of a pointer to member function of type TO_TYPE. */
+int cplus_method_ptr_size (struct type *to_type);
/* Return the method which should be called by applying METHOD_PTR
to *THIS_P, and adjust *THIS_P if necessary. */
struct value *cplus_method_ptr_to_value (struct value **this_p,
struct value *method_ptr);
-/* Create the byte pattern in CONTENTS representing a pointer to
- member function at ADDRESS (if IS_VIRTUAL is 0) or with virtual
- table offset ADDRESS (if IS_VIRTUAL is 1). This is the opposite
- of cplus_method_ptr_to_value. */
-void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
- int is_virtual);
+/* Create the byte pattern in CONTENTS representing a pointer of
+ type TYPE to member function at ADDRESS (if IS_VIRTUAL is 0)
+ or with virtual table offset ADDRESS (if IS_VIRTUAL is 1).
+ This is the opposite of cplus_method_ptr_to_value. */
+void cplus_make_method_ptr (struct type *type, gdb_byte *CONTENTS,
+ CORE_ADDR address, int is_virtual);
/* Determine if we are currently in a C++ thunk. If so, get the address
of the routine we are thunking to and continue to there instead. */
@@ -195,8 +194,8 @@ struct cp_abi_ops
const bfd_byte *valaddr, CORE_ADDR address);
void (*print_method_ptr) (const gdb_byte *contents, struct type *type,
struct ui_file *stream);
- int (*method_ptr_size) (void);
- void (*make_method_ptr) (gdb_byte *, CORE_ADDR, int);
+ int (*method_ptr_size) (struct type *);
+ void (*make_method_ptr) (struct type *, gdb_byte *, CORE_ADDR, int);
struct value * (*method_ptr_to_value) (struct value **, struct value *);
CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
int (*pass_by_reference) (struct type *type);
Index: gdb-head/gdb/cp-valprint.c
===================================================================
--- gdb-head.orig/gdb/cp-valprint.c
+++ gdb-head/gdb/cp-valprint.c
@@ -538,16 +538,16 @@ cp_find_class_member (struct type **doma
}
void
-cp_print_class_member (const gdb_byte *valaddr, struct type *domain,
+cp_print_class_member (const gdb_byte *valaddr, struct type *type,
struct ui_file *stream, char *prefix)
{
/* VAL is a byte offset into the structure type DOMAIN.
Find the name of the field for that offset and
print it. */
+ struct type *domain = TYPE_DOMAIN_TYPE (type);
+ LONGEST val = extract_signed_integer (valaddr, TYPE_LENGTH (type));
unsigned int fieldno;
- LONGEST val = unpack_long (builtin_type_long, valaddr);
-
/* Pointers to data members are usually byte offsets into an object.
Because a data member can have offset zero, and a NULL pointer to
member must be distinct from any valid non-NULL pointer to
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -189,9 +189,7 @@ c_val_print (struct type *type, const gd
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
break;
}
- cp_print_class_member (valaddr + embedded_offset,
- TYPE_DOMAIN_TYPE (type),
- stream, "&");
+ cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
break;
case TYPE_CODE_METHODPTR:
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -663,7 +663,7 @@ lookup_methodptr_type (struct type *to_t
mtype = alloc_type (TYPE_OBJFILE (to_type));
TYPE_TARGET_TYPE (mtype) = to_type;
TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
- TYPE_LENGTH (mtype) = cplus_method_ptr_size ();
+ TYPE_LENGTH (mtype) = cplus_method_ptr_size (to_type);
TYPE_CODE (mtype) = TYPE_CODE_METHODPTR;
return mtype;
}
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -45,6 +45,21 @@ gnuv3_is_operator_name (const char *name
}
+/* Determine architecture of class DOMAIN. This architecture is used
+ to query C++ ABI details (types, method pointer layout, etc.).
+
+ Note that we assume DOMAIN must have been allocated with an OBJFILE;
+ GDB does not provide any built-in class types. Thus we use the
+ architecture of that OBJFILE to define the C++ ABI. */
+
+static struct gdbarch *
+get_class_arch (struct type *domain)
+{
+ gdb_assert (TYPE_CODE (domain) == TYPE_CODE_CLASS);
+ gdb_assert (TYPE_OBJFILE (domain) != NULL);
+ return get_objfile_arch (TYPE_OBJFILE (domain));
+}
+
/* To help us find the components of a vtable, we build ourselves a
GDB type object representing the vtable structure. Following the
V3 ABI, it goes something like this:
@@ -176,10 +191,9 @@ build_gdb_vtable_type (struct gdbarch *a
gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
(i.e., where objects' virtual table pointers point). */
static int
-vtable_address_point_offset (void)
+vtable_address_point_offset (struct gdbarch *gdbarch)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
/ TARGET_CHAR_BIT);
@@ -190,8 +204,8 @@ static struct type *
gnuv3_rtti_type (struct value *value,
int *full_p, int *top_p, int *using_enc_p)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct gdbarch *gdbarch;
+ struct type *vtable_type;
struct type *values_type = check_typedef (value_type (value));
CORE_ADDR vtable_address;
struct value *vtable;
@@ -208,6 +222,16 @@ gnuv3_rtti_type (struct value *value,
if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
return NULL;
+ /* This routine may be called for Java types that do not have
+ a proper objfile. Just return NULL for those. */
+ if (!TYPE_OBJFILE (values_type)
+ || !TYPE_OBJFILE (values_type)->obfd)
+ return NULL;
+
+ /* Determine architecture. */
+ gdbarch = get_class_arch (values_type);
+ vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+
/* If we can't find the virtual table pointer for values_type, we
can't find the RTTI. */
values_type_vptr_fieldno = get_vptr_fieldno (values_type,
@@ -229,8 +253,9 @@ gnuv3_rtti_type (struct value *value,
}
vtable_address
= value_as_address (value_field (value, values_type_vptr_fieldno));
- vtable = value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
+ vtable
+ = value_at_lazy (vtable_type,
+ vtable_address - vtable_address_point_offset (gdbarch));
/* Find the linker symbol for this vtable. */
vtable_symbol
@@ -282,10 +307,9 @@ gnuv3_rtti_type (struct value *value,
vtable type for this architecture. */
static struct value *
-gnuv3_get_vtable (struct value *container)
+gnuv3_get_vtable (struct gdbarch *gdbarch, struct value *container)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
struct type *vtable_pointer_type;
struct value *vtable_pointer;
CORE_ADDR vtable_pointer_address, vtable_address;
@@ -311,17 +335,17 @@ gnuv3_get_vtable (struct value *containe
/* Correct it to point at the start of the virtual table, rather
than the address point. */
return value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
+ vtable_address - vtable_address_point_offset (gdbarch));
}
/* Return a function pointer for CONTAINER's VTABLE_INDEX'th virtual
function, of type FNTYPE. */
static struct value *
-gnuv3_get_virtual_fn (struct value *container, struct type *fntype,
- int vtable_index)
+gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
+ struct type *fntype, int vtable_index)
{
- struct value *vtable = gnuv3_get_vtable (container);
+ struct value *vtable = gnuv3_get_vtable (gdbarch, container);
struct value *vfn;
/* Fetch the appropriate function pointer from the vtable. */
@@ -333,7 +357,7 @@ gnuv3_get_virtual_fn (struct value *cont
(i.e. points to the descriptor). We don't need to scale the index
by the size of a function descriptor; GCC does that before outputing
debug information. */
- if (gdbarch_vtable_function_descriptors (current_gdbarch))
+ if (gdbarch_vtable_function_descriptors (gdbarch))
vfn = value_addr (vfn);
/* Cast the function pointer to the appropriate type. */
@@ -351,18 +375,22 @@ gnuv3_virtual_fn_field (struct value **v
struct type *vfn_base, int offset)
{
struct type *values_type = check_typedef (value_type (*value_p));
+ struct gdbarch *gdbarch;
/* Some simple sanity checks. */
if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
error (_("Only classes can have virtual functions."));
+ /* Determine architecture. */
+ gdbarch = get_class_arch (values_type);
+
/* Cast our value to the base class which defines this virtual
function. This takes care of any necessary `this'
adjustments. */
if (vfn_base != values_type)
*value_p = value_cast (vfn_base, *value_p);
- return gnuv3_get_virtual_fn (*value_p, TYPE_FN_FIELD_TYPE (f, j),
+ return gnuv3_get_virtual_fn (gdbarch, *value_p, TYPE_FN_FIELD_TYPE (f, j),
TYPE_FN_FIELD_VOFFSET (f, j));
}
@@ -377,8 +405,9 @@ static int
gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
CORE_ADDR address)
{
- struct type *vtable_type = gdbarch_data (current_gdbarch,
- vtable_type_gdbarch_data);
+ struct gdbarch *gdbarch;
+ struct type *vtable_type;
+ struct type *ptr_type;
struct value *vtable;
struct type *vbasetype;
struct value *offset_val, *vbase_array;
@@ -386,6 +415,11 @@ gnuv3_baseclass_offset (struct type *typ
long int cur_base_offset, base_offset;
int vbasetype_vptr_fieldno;
+ /* Determine architecture. */
+ gdbarch = get_class_arch (type);
+ vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+ ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
/* If it isn't a virtual base, this is easy. The offset is in the
type definition. */
if (!BASETYPE_VIA_VIRTUAL (type, index))
@@ -397,14 +431,13 @@ gnuv3_baseclass_offset (struct type *typ
complete inheritance graph based on the debug info. Neither is
worthwhile. */
cur_base_offset = TYPE_BASECLASS_BITPOS (type, index) / 8;
- if (cur_base_offset >= - vtable_address_point_offset ())
+ if (cur_base_offset >= - vtable_address_point_offset (gdbarch))
error (_("Expected a negative vbase offset (old compiler?)"));
- cur_base_offset = cur_base_offset + vtable_address_point_offset ();
- if ((- cur_base_offset) % TYPE_LENGTH (builtin_type_void_data_ptr) != 0)
+ cur_base_offset = cur_base_offset + vtable_address_point_offset (gdbarch);
+ if ((- cur_base_offset) % TYPE_LENGTH (ptr_type) != 0)
error (_("Misaligned vbase offset."));
- cur_base_offset = cur_base_offset
- / ((int) TYPE_LENGTH (builtin_type_void_data_ptr));
+ cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type));
/* We're now looking for the cur_base_offset'th entry (negative index)
in the vcall_and_vbase_offsets array. We used to cast the object to
@@ -425,11 +458,11 @@ gnuv3_baseclass_offset (struct type *typ
error (_("Illegal vptr offset in class %s"),
TYPE_NAME (vbasetype) ? TYPE_NAME (vbasetype) : "<unknown>");
- vtable_address = value_as_address (value_at_lazy (builtin_type_void_data_ptr,
- address));
- vtable = value_at_lazy (vtable_type,
- vtable_address - vtable_address_point_offset ());
- offset_val = value_from_longest(builtin_type_int32, cur_base_offset);
+ vtable_address = value_as_address (value_at_lazy (ptr_type, address));
+ vtable
+ = value_at_lazy (vtable_type,
+ vtable_address - vtable_address_point_offset (gdbarch));
+ offset_val = value_from_longest (builtin_type_int32, cur_base_offset);
vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
base_offset = value_as_long (value_subscript (vbase_array, offset_val));
return base_offset;
@@ -492,12 +525,13 @@ gnuv3_find_method_in (struct type *domai
/* Decode GNU v3 method pointer. */
static int
-gnuv3_decode_method_ptr (const gdb_byte *contents,
+gnuv3_decode_method_ptr (struct gdbarch *gdbarch,
+ const gdb_byte *contents,
CORE_ADDR *value_p,
LONGEST *adjustment_p)
{
- struct type *funcptr_type = builtin_type_void_func_ptr;
- struct type *offset_type = builtin_type_long;
+ struct type *funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
+ struct type *offset_type = builtin_type (gdbarch)->builtin_long;
CORE_ADDR ptr_value;
LONGEST voffset, adjustment;
int vbit;
@@ -513,7 +547,7 @@ gnuv3_decode_method_ptr (const gdb_byte
contents += TYPE_LENGTH (funcptr_type);
adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
- if (!gdbarch_vbit_in_delta (current_gdbarch))
+ if (!gdbarch_vbit_in_delta (gdbarch))
{
vbit = voffset & 1;
voffset = voffset ^ vbit;
@@ -536,15 +570,14 @@ gnuv3_print_method_ptr (const gdb_byte *
struct type *type,
struct ui_file *stream)
{
+ struct type *domain = TYPE_DOMAIN_TYPE (type);
+ struct gdbarch *gdbarch = get_class_arch (domain);
CORE_ADDR ptr_value;
LONGEST adjustment;
- struct type *domain;
int vbit;
- domain = TYPE_DOMAIN_TYPE (type);
-
/* Extract the pointer to member. */
- vbit = gnuv3_decode_method_ptr (contents, &ptr_value, &adjustment);
+ vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment);
/* Check for NULL. */
if (ptr_value == 0 && vbit == 0)
@@ -562,7 +595,7 @@ gnuv3_print_method_ptr (const gdb_byte *
/* It's a virtual table offset, maybe in this class. Search
for a field with the correct vtable offset. First convert it
to an index, as used in TYPE_FN_FIELD_VOFFSET. */
- voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
+ voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
physname = gnuv3_find_method_in (domain, voffset, adjustment);
@@ -601,17 +634,22 @@ gnuv3_print_method_ptr (const gdb_byte *
/* GNU v3 implementation of cplus_method_ptr_size. */
static int
-gnuv3_method_ptr_size (void)
+gnuv3_method_ptr_size (struct type *type)
{
- return 2 * TYPE_LENGTH (builtin_type_void_data_ptr);
+ struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+ struct gdbarch *gdbarch = get_class_arch (domain_type);
+ return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
}
/* GNU v3 implementation of cplus_make_method_ptr. */
static void
-gnuv3_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
+ CORE_ADDR value, int is_virtual)
{
- int size = TYPE_LENGTH (builtin_type_void_data_ptr);
+ struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
+ struct gdbarch *gdbarch = get_class_arch (domain_type);
+ int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
/* FIXME drow/2006-12-24: The adjustment of "this" is currently
always zero, since the method pointer is of the correct type.
@@ -622,7 +660,7 @@ gnuv3_make_method_ptr (gdb_byte *content
support for adjusting pointers to members when casting them -
not currently supported by GDB. */
- if (!gdbarch_vbit_in_delta (current_gdbarch))
+ if (!gdbarch_vbit_in_delta (gdbarch))
{
store_unsigned_integer (contents, size, value | is_virtual);
store_unsigned_integer (contents + size, size, 0);
@@ -639,20 +677,22 @@ gnuv3_make_method_ptr (gdb_byte *content
static struct value *
gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
{
+ struct gdbarch *gdbarch;
const gdb_byte *contents = value_contents (method_ptr);
CORE_ADDR ptr_value;
- struct type *final_type, *method_type;
+ struct type *domain_type, *final_type, *method_type;
LONGEST adjustment;
struct value *adjval;
int vbit;
- final_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
- final_type = lookup_pointer_type (final_type);
+ domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
+ final_type = lookup_pointer_type (domain_type);
method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));
/* Extract the pointer to member. */
- vbit = gnuv3_decode_method_ptr (contents, &ptr_value, &adjustment);
+ gdbarch = get_class_arch (domain_type);
+ vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment);
/* First convert THIS to match the containing type of the pointer to
member. This cast may adjust the value of THIS. */
@@ -673,15 +713,18 @@ gnuv3_method_ptr_to_value (struct value
You can provoke this case by casting a Base::* to a Derived::*, for
instance. */
- *this_p = value_cast (builtin_type_void_data_ptr, *this_p);
- adjval = value_from_longest (builtin_type_long, adjustment);
+ *this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);
+ adjval = value_from_longest (builtin_type (gdbarch)->builtin_long,
+ adjustment);
*this_p = value_ptradd (*this_p, adjval);
*this_p = value_cast (final_type, *this_p);
if (vbit)
{
- LONGEST voffset = ptr_value / TYPE_LENGTH (builtin_type_long);
- return gnuv3_get_virtual_fn (value_ind (*this_p), method_type, voffset);
+ LONGEST voffset;
+ voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
+ return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p),
+ method_type, voffset);
}
else
return value_from_pointer (lookup_pointer_type (method_type), ptr_value);
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -466,7 +466,7 @@ value_cast (struct type *type, struct va
&& value_as_long (arg2) == 0)
{
struct value *result = allocate_value (type);
- cplus_make_method_ptr (value_contents_writeable (result), 0, 0);
+ cplus_make_method_ptr (type, value_contents_writeable (result), 0, 0);
return result;
}
else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT
@@ -2612,7 +2612,8 @@ value_struct_elt_for_reference (struct t
{
result = allocate_value
(lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
- cplus_make_method_ptr (value_contents_writeable (result),
+ cplus_make_method_ptr (value_type (result),
+ value_contents_writeable (result),
TYPE_FN_FIELD_VOFFSET (f, j), 1);
}
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -2635,7 +2636,8 @@ value_struct_elt_for_reference (struct t
else
{
result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
- cplus_make_method_ptr (value_contents_writeable (result),
+ cplus_make_method_ptr (value_type (result),
+ value_contents_writeable (result),
VALUE_ADDRESS (v), 0);
}
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
@ 2008-09-05 22:39 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 22:39 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> This patch adds a number of _promote calls to ada-lang.c; while these
> should simply preserve the status quo, someone familiar with the Ada
> type promotion rules should probably have a look at those, maybe this
> code can now be simplified a bit ...
There are a few cases where I am also wondering whether a simplification
might be possible or not (case UNOP_IN_RANGE, BINOP_IN_BOUNDS,
TERNOP_IN_RANGE for instance), but I am not sure. I cannot test
this patch and I won't be able to for at least a few more days
or a week, so I'd say let's preserve the current status quo.
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
@ 2008-09-05 22:56 ` Joel Brobecker
2008-09-07 15:40 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 22:56 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> As the actual type doesn't really matter, this patch changes that
> to use builtin_type_int8 instead.
(maybe I am answering prematurely since I haven't read the other
patches, but I have to answer now, or I'll probably forget by the
time I reach the last patch).
I understand how builtin_type_int8 is architecture neutral, and
thus allows us to get rid of the dependency on the gdbarch. No
dispute on the actual patch.
But the patch really made me think that we really ought to have
a procedure that returns a dummy value for the EVAL_SKIP case.
That way, we don't have to remember that we should be using
an arch-neutral type such as builtin_type_int8.
On another related note, the "goto nosideret" seems to be misused
to me. We seem to always have:
goto nosideret;
[...]
nosideret:
return value_from_longest (builtin_type_long, (LONGEST) 1);
If we have a value_dummy() function, we can replace all gotos with
a "return value_dummy ()", and get rid of the label. I think it will
be more readable.
This can be done as a followup patch, though...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
2008-09-01 7:19 ` Tom Tromey
@ 2008-09-05 23:02 ` Joel Brobecker
1 sibling, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 23:02 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> It might make sense to check for which languages this extension
> is actually useful, and remove it from the rest.
I know that this doesn't make sense in Ada, but I'm always uncomfortable
removing "features" when I don't know who might be relying on it. It's
reasonably easy to provide that features, so I wouldn't mind keeping it,
at least for C/C++/etc languages and Ada.
My 2 cents...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
@ 2008-09-05 23:13 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-05 23:13 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> ada-lang.c uses builtin_type_double as intermediate type in some
> type conversions. This doesn't seem to be necessary, as the
> value_as_double and value_from_double routines should be able
> to handle the same types directly ...
This looks like a nice cleanup :), and we can always fix any ommission/bug
that we might find in value_as/from_double routines later. If we find any.
Thanks!
> ChangeLog:
>
> * ada-lang.c (cast_to_fixed): Do not cast to builtin_type_double.
> (cast_from_fixed_to_double): Rename to ...
> (cast_from_fixed): ... this. Add TYPE parameter. Use it instead
> of builtin_type_double.
> (ada_value_cast): Use cast_from_fixed instead of casting result
> of cast_from_fixed_to_double.
> (ada_evaluate_subexp): Update calls to cast_from_fixed_to_double.
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
@ 2008-09-06 0:24 ` Joel Brobecker
2008-09-07 15:43 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 0:24 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> two more small changes to ada-lang.c: ada_array_length would simply use
> builtin_type_int as type of its return value, even though it should probably
> better use the type of the array bounds.
I don't think this part is correct, since the bounds can be any discrete
type, which includes enumeration types. The 'Length attribute is defined
as returning a universal_integer. The definition of universal_integer
is a little complicated for me, but it is an integer.
For this hunk:
> @@ -2633,12 +2633,13 @@ ada_array_length (struct value *arr, int
> return value_from_longest (type, v);
> }
> else
> - return
> - value_from_longest (builtin_type_int,
> - value_as_long (desc_one_bound (desc_bounds (arr),
> - n, 1))
> - - value_as_long (desc_one_bound (desc_bounds (arr),
> - n, 0)) + 1);
> + {
> + struct value *high = desc_one_bound (desc_bounds (arr), n, 1);
> + struct value *low = desc_one_bound (desc_bounds (arr), n, 0);
> + return value_from_longest (value_type (high),
> + value_as_long (high)
> + - value_as_long (low) + 1);
In this case, I propose we use builtin_type_int32 as you have done
in an earlier patch, or maybe builtin_type_uint32 since the length
is always positive. Not ideal, but I don't think it's worse than
what we have been doing so far (there might be some 64-bit architectures
where Integer'Length is 64-bit, so technically we might be doing worse,
but again, i don't think we're going to see arrays that large - hopefully
I won't stand corrected, but I propose to worry about it then).
Another option is to pass the int type as a parameter, since I believe
it is indirectly accessible form the caller (ada_evaluate_subexp).
We can extract the gdbarch from the expression, and then get the
int type from there. For some reason, I find it annoying to have
to pass the type, and this approach annoys me as much as the current
approach. Since this is also more work, I would simply leave it as
a builtin_type_int32 for now.
> case TYPE_CODE_RANGE:
> - arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> - arg3 = value_from_longest (builtin_type_int,
> - TYPE_HIGH_BOUND (type));
> + arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
> + TYPE_LOW_BOUND (type));
> + arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
> + TYPE_HIGH_BOUND (type));
> binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
> binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
> type = language_bool_type (exp->language_defn, exp->gdbarch);
I don't really understand why the TYPE_TARGET_TYPE is necessarily
an integer type. I don't even think that the TYPE_TARGET_TYPE
is necessarily set, particularly in the case of enumerated types
or base types.
We have access to the int type through the expression in this case.
Can we use that?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
@ 2008-09-06 0:38 ` Joel Brobecker
2008-09-06 4:12 ` Daniel Jacobowitz
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 0:38 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> However, this problem can be fixed by simply making sure that noone
> ever calls lookup_pointer_type, lookup_reference_type, or lookup_function_type
> on the platform-neutral builtin_type_void type.
I am really concerned that, one day, we will miss someone re-introducing
a call to one of these functions with the builtin_type_void type
It would be really useful to do whatever we can to prevent this
from happening.
I don't want to add a field in our type structure to mark the types
that are architecture-specific, since that would have a noticeable
memory cost just for a few specific types. So about the following,
not ideal but probably good enough:
- Add a new function architecture_neutral_builtin_type () that
returns true/non-zero if the given type is one of the builtin
types defined by gdbtypes (just doing a pointer check against
every builtin_type_* that we have)
- Add an assertion in lookup_pointer_type, lookup_reference_type,
and lookup_function_type using the function above.
- Add a comment a the beginning of the builtin_type section explaining
that the following types are architecture neutral, and that computing
pointer/reference/function types should not be performed on them.
Explicitly remind the reader that when adding a new builtin type
there, he should also update the check in
architecture_neutral_builtin_type.
Another option is to generate the builtin types and the associated
architecture_neutral_builtin_type function a-la gdbarch. Probably
cleaner, as less error prone.
This doesn't have to be done as part of this patch, though, especially
since this is open to discussion. Perhaps shortly after this patch set
is checked in, we could make sure to follow up on that?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
@ 2008-09-06 1:37 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 1:37 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> a number of places use builtin_type_ macros to build up argument lists
> for inferior function calls. However, they always use the routine
> find_function_in_inferior first to find the function to be called.
> This routine is able to determine the objfile that defines the function
> to be called -- and the per-objfile architecture of that file should
> be used to determine the default types for the inferior call.
Oh la la, I see now why Daniel used the term "contorsions".
Nothing much we can do about it, I guess, and a necessary thing
to do, but I thought I'd mention it.
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
@ 2008-09-06 3:15 ` Joel Brobecker
2008-09-07 16:44 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 3:15 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> @@ -197,11 +197,11 @@ print_range_bound (struct type *type, ch
> the upper bound of the 0 .. -1 range types to be printed as
> a very large unsigned number instead of -1.
> To workaround this stabs deficiency, we replace the TYPE by
> - builtin_type_long when we detect that the bound is negative,
> + builtin_type_int32 when we detect that the bound is negative,
> and the type is a TYPE_CODE_INT. The bound is negative when
> 'm' is the last character of the number scanned in BOUNDS. */
> if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT)
> - type = builtin_type_long;
> + type = builtin_type_int32;
> ada_print_scalar (type, B, stream);
> if (bounds[*n] == '_')
> *n += 2;
I'm slightly concerned about the effect of this change on 64-bit
platforms. Normally, stabs is a 32bit format so this shouldn't be
a problem, but Tru64 is a 64-bit platform with stabs, and the
range values are stored as text in the stabs string. So presumably
64-bit range types are possible... However, I couldn't come up with
a case where things get degraded. Nor did the testsuite, which does
also test the case described in the comments), reveal any regression.
So I guess we should be OK.
> Index: gdb-head/gdb/p-typeprint.c
> ===================================================================
> --- gdb-head.orig/gdb/p-typeprint.c
> +++ gdb-head/gdb/p-typeprint.c
> @@ -756,7 +756,7 @@ pascal_type_print_base (struct type *typ
> {
> struct type *target = TYPE_TARGET_TYPE (type);
> if (target == NULL)
> - target = builtin_type_long;
> + target = builtin_type_int32;
> print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
> fputs_filtered ("..", stream);
> print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
Just an observation: This part seems erroneous, no? type is a
TYPE_CODE_RANGE, but there is no underlying TARGET_TYPE? Would
it make better sense to error-out instead? On platforms using DWARF,
this should never happen (we complain about the missing base type
and use an integer type as a substitute). For stabs, things seem
a little less clear, but it looks like we also always create range
types with a base type. So maybe this should never happen. Anyway,
if there is a Fortran maintainer reading this...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
` (38 preceding siblings ...)
2008-09-02 12:50 ` Daniel Jacobowitz
@ 2008-09-06 3:16 ` Joel Brobecker
2008-09-07 16:43 ` Ulrich Weigand
39 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 3:16 UTC (permalink / raw)
To: uweigand; +Cc: gdb-patches
> What do you think?
I think I have now reviewed all 37 patches and sent all my comments.
I would like to test this patch against our testsuite, but unfortunately
it will be a few more days at least before I can do so. If I get to it
before the patch is checked in, I will send the results...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-09-06 0:38 ` Joel Brobecker
@ 2008-09-06 4:12 ` Daniel Jacobowitz
2008-09-06 14:00 ` Joel Brobecker
2008-09-07 15:59 ` Ulrich Weigand
0 siblings, 2 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-06 4:12 UTC (permalink / raw)
To: Joel Brobecker; +Cc: uweigand, gdb-patches
On Fri, Sep 05, 2008 at 05:37:24PM -0700, Joel Brobecker wrote:
> I don't want to add a field in our type structure to mark the types
> that are architecture-specific, since that would have a noticeable
> memory cost just for a few specific types.
No, it wouldn't. We have tons of free flag bits; it sounds like the
right thing to do would be to mark only the global types.>
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-09-06 4:12 ` Daniel Jacobowitz
@ 2008-09-06 14:00 ` Joel Brobecker
2008-09-07 15:59 ` Ulrich Weigand
1 sibling, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-06 14:00 UTC (permalink / raw)
To: uweigand, gdb-patches
> > I don't want to add a field in our type structure to mark the types
> > that are architecture-specific, since that would have a noticeable
> > memory cost just for a few specific types.
>
> No, it wouldn't. We have tons of free flag bits; it sounds like the
> right thing to do would be to mark only the global types.>
Duh!!! Of course...
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type
2008-09-05 22:56 ` Joel Brobecker
@ 2008-09-07 15:40 ` Ulrich Weigand
2008-09-07 15:49 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-07 15:40 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> On another related note, the "goto nosideret" seems to be misused
> to me. We seem to always have:
>
> goto nosideret;
> [...]
>
> nosideret:
> return value_from_longest (builtin_type_long, (LONGEST) 1);
>
> If we have a value_dummy() function, we can replace all gotos with
> a "return value_dummy ()", and get rid of the label. I think it will
> be more readable.
I tried to have evaluate_subexp return NULL for the EVAL_SKIP case,
but that caused frequently-used constructe like this to break:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
return arg1;
I guess with a bit of effort those could be fixed.
Another approach might be to use "allocate_value (builtin_void_type)"
as the dummy return value for the EVAL_SKIP case.
> This can be done as a followup patch, though...
Agreed.
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] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-06 0:24 ` Joel Brobecker
@ 2008-09-07 15:43 ` Ulrich Weigand
2008-09-09 18:00 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-07 15:43 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote
> > two more small changes to ada-lang.c: ada_array_length would simply use
> > builtin_type_int as type of its return value, even though it should probably
> > better use the type of the array bounds.
>
> I don't think this part is correct, since the bounds can be any discrete
> type, which includes enumeration types. The 'Length attribute is defined
> as returning a universal_integer. The definition of universal_integer
> is a little complicated for me, but it is an integer.
I see; it seems I have misinterpreted range types -- I though they were always
based on an integer type.
> For this hunk:
>
> > @@ -2633,12 +2633,13 @@ ada_array_length (struct value *arr, int
> > return value_from_longest (type, v);
> > }
> > else
> > - return
> > - value_from_longest (builtin_type_int,
> > - value_as_long (desc_one_bound (desc_bounds (arr),
> > - n, 1))
> > - - value_as_long (desc_one_bound (desc_bounds (arr),
> > - n, 0)) + 1);
> > + {
> > + struct value *high = desc_one_bound (desc_bounds (arr), n, 1);
> > + struct value *low = desc_one_bound (desc_bounds (arr), n, 0);
> > + return value_from_longest (value_type (high),
> > + value_as_long (high)
> > + - value_as_long (low) + 1);
>
> In this case, I propose we use builtin_type_int32 as you have done
> in an earlier patch, or maybe builtin_type_uint32 since the length
> is always positive. Not ideal, but I don't think it's worse than
> what we have been doing so far (there might be some 64-bit architectures
> where Integer'Length is 64-bit, so technically we might be doing worse,
> but again, i don't think we're going to see arrays that large - hopefully
> I won't stand corrected, but I propose to worry about it then).
>
> Another option is to pass the int type as a parameter, since I believe
> it is indirectly accessible form the caller (ada_evaluate_subexp).
> We can extract the gdbarch from the expression, and then get the
> int type from there. For some reason, I find it annoying to have
> to pass the type, and this approach annoys me as much as the current
> approach. Since this is also more work, I would simply leave it as
> a builtin_type_int32 for now.
OK, fine with me.
> > case TYPE_CODE_RANGE:
> > - arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> > - arg3 = value_from_longest (builtin_type_int,
> > - TYPE_HIGH_BOUND (type));
> > + arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
> > + TYPE_LOW_BOUND (type));
> > + arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
> > + TYPE_HIGH_BOUND (type));
> > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
> > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
> > type = language_bool_type (exp->language_defn, exp->gdbarch);
>
> I don't really understand why the TYPE_TARGET_TYPE is necessarily
> an integer type. I don't even think that the TYPE_TARGET_TYPE
> is necessarily set, particularly in the case of enumerated types
> or base types.
>
> We have access to the int type through the expression in this case.
> Can we use that?
I guess so, but it would appear this doesn't really help. There isn't
really anything in the language that says the gdbarch's int type is the
"correct" type to use here, or is there?
If not, and this is just about using some "random" integer type to perform
the comparison in, it seems to me using builtin_type_int32 here as well
would be better ...
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] 98+ messages in thread
* Re: [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type
2008-09-07 15:40 ` Ulrich Weigand
@ 2008-09-07 15:49 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-07 15:49 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> > nosideret:
> > return value_from_longest (builtin_type_long, (LONGEST) 1);
> >
> > If we have a value_dummy() function, we can replace all gotos with
> > a "return value_dummy ()", and get rid of the label. I think it will
> > be more readable.
>
> I tried to have evaluate_subexp return NULL for the EVAL_SKIP case,
> but that caused frequently-used constructe like this to break:
>
> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
> arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
>
> if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
> return arg1;
Right, I think the expectation for evaluate_subexp was that it would
never return NULL - either it errors out or returns a valid value.
What I meant in my message above is that we could have a new procedure
that returns a valid value of some kind, but whose content is
unspecified - to be used in cases like EVAL_SKIP when we don't really
care about. The function is there more as a shortcut for building
that dummy value. Your suggestion of using allocate_value (builtin_void_type)
might actually be even better than using builtin_type_int8 - we should
never read the value contents anyway.
> I guess with a bit of effort those could be fixed.
Not worth it, IMO.
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-09-06 4:12 ` Daniel Jacobowitz
2008-09-06 14:00 ` Joel Brobecker
@ 2008-09-07 15:59 ` Ulrich Weigand
2008-09-13 15:23 ` Daniel Jacobowitz
2008-09-13 17:23 ` Joel Brobecker
1 sibling, 2 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-07 15:59 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches
Daniel Jacobowitz wrote:
> On Fri, Sep 05, 2008 at 05:37:24PM -0700, Joel Brobecker wrote:
> > I don't want to add a field in our type structure to mark the types
> > that are architecture-specific, since that would have a noticeable
> > memory cost just for a few specific types.
>
> No, it wouldn't. We have tons of free flag bits; it sounds like the
> right thing to do would be to mark only the global types.
We could do that, but I'm not sure this really helps with the underlying
core problem. The problem isn't so much calling lookup_pointer_type on
a platform-neutral type, the actual problem is:
- make_pointer_type using current_gdbarch to determine pointer size
- the *single* cached pointer type in TYPE_POINTER_TYPE
I can see two ways forward to solve those problems:
1.) lookup_pointer_type creates a pointer type of the same architecture
as the underlying type
This would imply calling lookup_pointer_type on a platform-neutral
type would be invalid, but a simple flag is not enough, because for
platform-specific types we have to be able to actually get at the
gdbarch itself.
So we'd have to have something like a get_type_arch (...) routine,
and the platform-neutral check would be implemented by checking
whether this routine returns NULL.
2.) lookup_pointer_type gets an gdbarch argument (or maybe just a
"size" argument, as that is what we really need)
In this case, we'd probably have to extend the caching mechanims
to cache pointers of multiple different sizes (note that to some
extent that exists today via TYPE_CHAIN, see make_qualified_type).
Then, there wouldn't really be any strict reason any more why
we couldn't allow making pointer types to platform-neutral types ...
It seems to me that option 1.) might be preferable, however I don't
really want to grow "struct type" to hold a gdbarch pointer.
In most cases, we can use get_objfile_arch (TYPE_OBJFILE (...)) to
get at the type's architecture, but there are some corner-cases
where this doesn't work right now, e.g. the copy_type_recursive
logic ...
Any opinions on this?
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] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-06 3:16 ` Joel Brobecker
@ 2008-09-07 16:43 ` Ulrich Weigand
2008-09-09 18:05 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-07 16:43 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> I think I have now reviewed all 37 patches and sent all my comments.
Many thanks for the thorough review1
> I would like to test this patch against our testsuite, but unfortunately
> it will be a few more days at least before I can do so. If I get to it
> before the patch is checked in, I will send the results...
I can wait a couple of days before checking them in, no problem ...
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] 98+ messages in thread
* Re: [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers
2008-09-06 3:15 ` Joel Brobecker
@ 2008-09-07 16:44 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-07 16:44 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> > @@ -197,11 +197,11 @@ print_range_bound (struct type *type, ch
> > the upper bound of the 0 .. -1 range types to be printed as
> > a very large unsigned number instead of -1.
> > To workaround this stabs deficiency, we replace the TYPE by
> > - builtin_type_long when we detect that the bound is negative,
> > + builtin_type_int32 when we detect that the bound is negative,
> > and the type is a TYPE_CODE_INT. The bound is negative when
> > 'm' is the last character of the number scanned in BOUNDS. */
> > if (bounds[*n - 1] == 'm' && TYPE_CODE (type) == TYPE_CODE_INT)
> > - type = builtin_type_long;
> > + type = builtin_type_int32;
> > ada_print_scalar (type, B, stream);
> > if (bounds[*n] == '_')
> > *n += 2;
>
> I'm slightly concerned about the effect of this change on 64-bit
> platforms. Normally, stabs is a 32bit format so this shouldn't be
> a problem, but Tru64 is a 64-bit platform with stabs, and the
> range values are stored as text in the stabs string. So presumably
> 64-bit range types are possible... However, I couldn't come up with
> a case where things get degraded. Nor did the testsuite, which does
> also test the case described in the comments), reveal any regression.
> So I guess we should be OK.
OK, thanks for verifying this.
> > Index: gdb-head/gdb/p-typeprint.c
> > ===================================================================
> > --- gdb-head.orig/gdb/p-typeprint.c
> > +++ gdb-head/gdb/p-typeprint.c
> > @@ -756,7 +756,7 @@ pascal_type_print_base (struct type *typ
> > {
> > struct type *target = TYPE_TARGET_TYPE (type);
> > if (target == NULL)
> > - target = builtin_type_long;
> > + target = builtin_type_int32;
> > print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
> > fputs_filtered ("..", stream);
> > print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
>
> Just an observation: This part seems erroneous, no? type is a
> TYPE_CODE_RANGE, but there is no underlying TARGET_TYPE? Would
> it make better sense to error-out instead? On platforms using DWARF,
> this should never happen (we complain about the missing base type
> and use an integer type as a substitute). For stabs, things seem
> a little less clear, but it looks like we also always create range
> types with a base type. So maybe this should never happen. Anyway,
> if there is a Fortran maintainer reading this...
I agree that this should never trigger, as create_range_type is
never called with a NULL index_type argument. (For stabsread.c
it seems it might get called with a builtin_type_error argument
in certain cases, but never NULL.)
The same holds for the copies of this code in m2-typeprint.c and
m2-valprint.c.
However, I simply wanted to preserve the status quo with this patch
set -- those checks can be removed with a follow-on patch.
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] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-07 15:43 ` Ulrich Weigand
@ 2008-09-09 18:00 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-09 18:00 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> > > two more small changes to ada-lang.c: ada_array_length would
> > > simply use builtin_type_int as type of its return value, even
> > > though it should probably better use the type of the array bounds.
> >
> > I don't think this part is correct, since the bounds can be any discrete
> > type, which includes enumeration types. The 'Length attribute is defined
> > as returning a universal_integer. The definition of universal_integer
> > is a little complicated for me, but it is an integer.
>
> I see; it seems I have misinterpreted range types -- I though they
> were always based on an integer type.
A range type is, I think, always based on an integer type. But the
thing is that array index types can be any discrete type: This means
that one can use an enumerated type as well.
So, for ada_array_length, shall use use a type of builtin_type_int32?
That's what I did for my testing (more on this in a separate message)
> > > case TYPE_CODE_RANGE:
> > > - arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> > > - arg3 = value_from_longest (builtin_type_int,
> > > - TYPE_HIGH_BOUND (type));
> > > + arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > + TYPE_LOW_BOUND (type));
> > > + arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > + TYPE_HIGH_BOUND (type));
> > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
> > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
> > > type = language_bool_type (exp->language_defn, exp->gdbarch);
> >
> > I don't really understand why the TYPE_TARGET_TYPE is necessarily
> > an integer type. I don't even think that the TYPE_TARGET_TYPE
> > is necessarily set, particularly in the case of enumerated types
> > or base types.
> >
> > We have access to the int type through the expression in this case.
> > Can we use that?
>
> I guess so, but it would appear this doesn't really help. There isn't
> really anything in the language that says the gdbarch's int type is the
> "correct" type to use here, or is there?
No, I don't think so. I had a look at the Ada Reference Manual,
and it doesn't say anything about that.
> If not, and this is just about using some "random" integer type to perform
> the comparison in, it seems to me using builtin_type_int32 here as well
> would be better ...
It just occured to me that, since this is a TYPE_CODE_RANGE, can't
we just use its type? A TYPE_CODE_RANGE should always be some kind
of "integer" type, so why not use that when calling value_from_longest?
I have this awful feeling that we're missing something, but I don't
see what. Do you see anything wrong with that?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-07 16:43 ` Ulrich Weigand
@ 2008-09-09 18:05 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 21:18 ` Joel Brobecker
0 siblings, 2 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-09 18:05 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> > I would like to test this patch against our testsuite, but unfortunately
> > it will be a few more days at least before I can do so. If I get to it
> > before the patch is checked in, I will send the results...
>
> I can wait a couple of days before checking them in, no problem ...
I just finished a first round of testing. Noticed that the gnu-v3-abi
changes don't seem to apply anymore (I think because of your recent
change, actually! ;-).
I made the modifications suggested in the 19/37 patch discussion.
I still got a few regressions with our testsuite, which I will
investigate now. Can you hold the patch off a little while longer?
Cheers,
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-09 18:00 ` Joel Brobecker
@ 2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 22:08 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-09 20:21 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> So, for ada_array_length, shall use use a type of builtin_type_int32?
> That's what I did for my testing (more on this in a separate message)
OK, I've changed the patch accordingly.
> > > > case TYPE_CODE_RANGE:
> > > > - arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
> > > > - arg3 = value_from_longest (builtin_type_int,
> > > > - TYPE_HIGH_BOUND (type));
> > > > + arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > > + TYPE_LOW_BOUND (type));
> > > > + arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
> > > > + TYPE_HIGH_BOUND (type));
> > > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
> > > > binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
> > > > type = language_bool_type (exp->language_defn, exp->gdbarch);
> > >
> > > I don't really understand why the TYPE_TARGET_TYPE is necessarily
> > > an integer type. I don't even think that the TYPE_TARGET_TYPE
> > > is necessarily set, particularly in the case of enumerated types
> > > or base types.
> > >
> > > We have access to the int type through the expression in this case.
> > > Can we use that?
> >
> > I guess so, but it would appear this doesn't really help. There isn't
> > really anything in the language that says the gdbarch's int type is the
> > "correct" type to use here, or is there?
>
> No, I don't think so. I had a look at the Ada Reference Manual,
> and it doesn't say anything about that.
>
> > If not, and this is just about using some "random" integer type to perform
> > the comparison in, it seems to me using builtin_type_int32 here as well
> > would be better ...
>
> It just occured to me that, since this is a TYPE_CODE_RANGE, can't
> we just use its type? A TYPE_CODE_RANGE should always be some kind
> of "integer" type, so why not use that when calling value_from_longest?
> I have this awful feeling that we're missing something, but I don't
> see what. Do you see anything wrong with that?
Well, the only effect going through GDB values to perform the comparison has
is to do the appropriate type promotions. However, if this doesn't actually
apply for Ada, I'm wondering why we don't simply do the comparison on integral
LONGEST values directly, like in the patch below?
Does this make sense?
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_array_length): Use builtin_type_int32 instead
of builtin_type_int.
(ada_evaluate_subexp): Perform range check on LONGEST values
instead of on GDB values.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -2623,7 +2623,7 @@ ada_array_length (struct value *arr, int
}
else
return
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
value_as_long (desc_one_bound (desc_bounds (arr),
n, 1))
- value_as_long (desc_one_bound (desc_bounds (arr),
@@ -8860,18 +8860,13 @@ ada_evaluate_subexp (struct type *expect
return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
- arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
- arg3 = value_from_longest (builtin_type_int,
- TYPE_HIGH_BOUND (type));
- binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
- binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
- type = language_bool_type (exp->language_defn, exp->gdbarch);
- return
- value_from_longest (type,
- (value_less (arg1, arg3)
- || value_equal (arg1, arg3))
- && (value_less (arg2, arg1)
- || value_equal (arg2, arg1)));
+ {
+ LONGEST val = value_as_long (arg1);
+ LONGEST low = TYPE_LOW_BOUND (type);
+ LONGEST high = TYPE_HIGH_BOUND (type);
+ type = language_bool_type (exp->language_defn, exp->gdbarch);
+ return value_from_longest (type, low <= val && val <= high);
+ }
}
case BINOP_IN_BOUNDS:
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-09 18:05 ` Joel Brobecker
@ 2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 21:18 ` Joel Brobecker
1 sibling, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-09 20:21 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> I just finished a first round of testing. Noticed that the gnu-v3-abi
> changes don't seem to apply anymore (I think because of your recent
> change, actually! ;-).
Yes, that's why I posted an updated version of the patch -- sorry for
the confusion:
http://sourceware.org/ml/gdb-patches/2008-09/msg00111.html
> I made the modifications suggested in the 19/37 patch discussion.
>
> I still got a few regressions with our testsuite, which I will
> investigate now. Can you hold the patch off a little while longer?
Certainly! Thanks for testing ...
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] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-09 18:05 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
@ 2008-09-09 21:18 ` Joel Brobecker
2008-09-09 22:12 ` Ulrich Weigand
1 sibling, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-09 21:18 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]
Hi Ulrich,
> I still got a few regressions with our testsuite, which I will
> investigate now. Can you hold the patch off a little while longer?
OK, our testsuite found 2 issues:
1. Pointer arithmetics, in particular "PTR + PTR" or "PTR - PTR"
expressions. For instance:
(gdb) print b'address - a'address
Argument to arithmetic operation not a number or boolean.
It's worth mentioning that the problem was already present
with pointer addition (adding two pointers doesn't necessarily
make a lot of sense, but anyway...).
The regression on the substraction is because we replaced the
call to (rip'ed) value_sub by a call to value_binop, which
doesn't support pointer differences.
I think the semantics of pointer differences in Ada are different
from C. It's just a number substraction. So I just added support
for it directly at the caller site, thus calling value_binop
only for values that it supports. Same for addition.
2. The second problem is just an oversight. You needed a variable
to store the int builtin type, and unfortunately you reused
a variable that was still in use.
See ada-lang.c (evaluate_subexp) [OP_ATR_SIZE].
For now, I just used builtin_type_int32. Not ideal, but should
be large enough for the vast majority of objects we actually
have to deal with in real life.
Two suggested patches attached...
BTW: I tested on x86-linux (DWARF & STABS) as well as on x86_64-linux
(DWARF only, obviously).
--
Joel
[-- Attachment #2: 01-ptrdiff.diff --]
[-- Type: text/plain, Size: 1252 bytes --]
diff -r ef6e8d4d28b4 -r c0202064b824 ada-lang.c
--- a/ada-lang.c Tue Sep 09 10:27:10 2008 -0700
+++ b/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
@@ -9909,6 +9909,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) + value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
@@ -9927,6 +9931,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) - value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
[-- Attachment #3: 02-size_atr.diff --]
[-- Type: text/plain, Size: 749 bytes --]
diff -r c0202064b824 -r 61698126d402 ChangeLog.joel
diff -r c0202064b824 -r 61698126d402 ada-lang.c
--- a/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
+++ b/ada-lang.c Tue Sep 09 12:57:26 2008 -0700
@@ -10541,11 +10541,10 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
- type = builtin_type (exp->gdbarch)->builtin_int;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, not_lval);
- else
- return value_from_longest (type,
+ return value_zero (builtin_type_int32, not_lval);
+ else
+ return value_from_longest (builtin_type_int32,
TARGET_CHAR_BIT * TYPE_LENGTH (type));
case OP_ATR_VAL:
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-09 20:21 ` Ulrich Weigand
@ 2008-09-09 22:08 ` Joel Brobecker
2008-09-09 22:32 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-09 22:08 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> > It just occured to me that, since this is a TYPE_CODE_RANGE, can't
> > we just use its type? A TYPE_CODE_RANGE should always be some kind
> > of "integer" type, so why not use that when calling value_from_longest?
> > I have this awful feeling that we're missing something, but I don't
> > see what. Do you see anything wrong with that?
First, I need to correct myself - ranges are not just for integral
types. You can have a range over any discrete type, which means
things like this:
type Digit is (Zero, One, Two, ...);
subtype Binary is Digit range (Zero .. One);
In this case, Binary would be defined as a subrange of the enumeration
type. However, after thinking about it awhile, I don't think that
enumeration types are that different from integral types in terms
of comparison and range check.
That being said:
> Well, the only effect going through GDB values to perform the
> comparison has is to do the appropriate type promotions. However, if
> this doesn't actually apply for Ada, I'm wondering why we don't simply
> do the comparison on integral LONGEST values directly, like in the
> patch below?
The only problem that I see is when the base type of the range type
is unsigned. value_less is supposed to be able to handle such cases,
whereas converting the bounds to a LONGEST might cause some problems,
no?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-09 21:18 ` Joel Brobecker
@ 2008-09-09 22:12 ` Ulrich Weigand
2008-09-10 6:18 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-09 22:12 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> 1. Pointer arithmetics, in particular "PTR + PTR" or "PTR - PTR"
> expressions. For instance:
>
> (gdb) print b'address - a'address
> Argument to arithmetic operation not a number or boolean.
>
> It's worth mentioning that the problem was already present
> with pointer addition (adding two pointers doesn't necessarily
> make a lot of sense, but anyway...).
>
> The regression on the substraction is because we replaced the
> call to (rip'ed) value_sub by a call to value_binop, which
> doesn't support pointer differences.
>
> I think the semantics of pointer differences in Ada are different
> from C. It's just a number substraction. So I just added support
> for it directly at the caller site, thus calling value_binop
> only for values that it supports. Same for addition.
I see. In that case, your patch would be a bugfix completely
independently of my patch set. Do you want to commit it right away?
> 2. The second problem is just an oversight. You needed a variable
> to store the int builtin type, and unfortunately you reused
> a variable that was still in use.
> See ada-lang.c (evaluate_subexp) [OP_ATR_SIZE].
>
> For now, I just used builtin_type_int32. Not ideal, but should
> be large enough for the vast majority of objects we actually
> have to deal with in real life.
Huh? I'm not sure what base this patch is against:
> --- a/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
> +++ b/ada-lang.c Tue Sep 09 12:57:26 2008 -0700
> @@ -10541,11 +10541,10 @@ ada_evaluate_subexp (struct type *expect
>
> if (noside == EVAL_SKIP)
> goto nosideret;
> - type = builtin_type (exp->gdbarch)->builtin_int;
> if (noside == EVAL_AVOID_SIDE_EFFECTS)
> - return value_zero (type, not_lval);
> - else
> - return value_from_longest (type,
> + return value_zero (builtin_type_int32, not_lval);
> + else
> + return value_from_longest (builtin_type_int32,
> TARGET_CHAR_BIT * TYPE_LENGTH (type));
>
> case OP_ATR_VAL:
The OP_ATR_SIZE in ada_evaluate_subexp in current head looks like this:
case OP_ATR_SIZE:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (builtin_type_int, not_lval);
else
return value_from_longest (builtin_type_int,
TARGET_CHAR_BIT
* TYPE_LENGTH (value_type (arg1)));
and after my patch set we have:
case OP_ATR_SIZE:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
type = builtin_type (exp->gdbarch)->builtin_int;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (type, not_lval);
else
return value_from_longest (type,
TARGET_CHAR_BIT
* TYPE_LENGTH (value_type (arg1)));
Do you have some other patches applied?
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] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-09 22:08 ` Joel Brobecker
@ 2008-09-09 22:32 ` Ulrich Weigand
2008-09-10 6:09 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-09 22:32 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> First, I need to correct myself - ranges are not just for integral
> types. You can have a range over any discrete type, which means
> things like this:
>
> type Digit is (Zero, One, Two, ...);
> subtype Binary is Digit range (Zero .. One);
>
> In this case, Binary would be defined as a subrange of the enumeration
> type. However, after thinking about it awhile, I don't think that
> enumeration types are that different from integral types in terms
> of comparison and range check.
Yes, value_less etc. should be able to handle enumeration (and range)
types fine.
> That being said:
>
> > Well, the only effect going through GDB values to perform the
> > comparison has is to do the appropriate type promotions. However, if
> > this doesn't actually apply for Ada, I'm wondering why we don't simply
> > do the comparison on integral LONGEST values directly, like in the
> > patch below?
>
> The only problem that I see is when the base type of the range type
> is unsigned. value_less is supposed to be able to handle such cases,
> whereas converting the bounds to a LONGEST might cause some problems,
> no?
I see. We'd need to compare either LONGEST or ULONGEST to take care
of signed vs. unsigned types. value_less already does this ...
So I guess your original proposal to use the range type itself is
the simplest solution. Implemented by the patch below.
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_array_length): Use builtin_type_int32 instead
of builtin_type_int.
(ada_evaluate_subexp) [UNOP_IN_RANGE]: Use operand range type
instead of builtin_type_int.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -2623,7 +2623,7 @@ ada_array_length (struct value *arr, int
}
else
return
- value_from_longest (builtin_type_int,
+ value_from_longest (builtin_type_int32,
value_as_long (desc_one_bound (desc_bounds (arr),
n, 1))
- value_as_long (desc_one_bound (desc_bounds (arr),
@@ -8860,9 +8860,8 @@ ada_evaluate_subexp (struct type *expect
return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
- arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
- arg3 = value_from_longest (builtin_type_int,
- TYPE_HIGH_BOUND (type));
+ arg2 = value_from_longest (type, TYPE_LOW_BOUND (type));
+ arg3 = value_from_longest (type, TYPE_HIGH_BOUND (type));
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-09 22:32 ` Ulrich Weigand
@ 2008-09-10 6:09 ` Joel Brobecker
2008-09-10 9:51 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-10 6:09 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> So I guess your original proposal to use the range type itself is
> the simplest solution. Implemented by the patch below.
Agreed.
> ChangeLog:
>
> * ada-lang.c (ada_array_length): Use builtin_type_int32 instead
> of builtin_type_int.
> (ada_evaluate_subexp) [UNOP_IN_RANGE]: Use operand range type
> instead of builtin_type_int.
I think we can commit this independently of the rest, right?
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-09 22:12 ` Ulrich Weigand
@ 2008-09-10 6:18 ` Joel Brobecker
2008-09-10 9:43 ` Ulrich Weigand
0 siblings, 1 reply; 98+ messages in thread
From: Joel Brobecker @ 2008-09-10 6:18 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> > 1. Pointer arithmetics, in particular "PTR + PTR" or "PTR - PTR"
> > expressions. For instance:
> >
> > (gdb) print b'address - a'address
> > Argument to arithmetic operation not a number or boolean.
[...]
> I see. In that case, your patch would be a bugfix completely
> independently of my patch set. Do you want to commit it right away?
Sure! I don't know what this didn't cross my mind earlier, I guess
I was in a bit of a crunch... Will do that tomorrow (I'm also planning
on submitting a bunch of patches tomorrow as well, if things go as
planned - so that'll be a good time for that).
> > 2. The second problem is just an oversight. You needed a variable
> > to store the int builtin type, and unfortunately you reused
> > a variable that was still in use.
> > See ada-lang.c (evaluate_subexp) [OP_ATR_SIZE].
> >
> > For now, I just used builtin_type_int32. Not ideal, but should
> > be large enough for the vast majority of objects we actually
> > have to deal with in real life.
>
> Huh? I'm not sure what base this patch is against:
It was on top of your patch - If I am not mistaken, it should apply
cleanly after you apply yours. I did, however, generate the patch
against AdaCore's gdb-head (which is a merge between our changes
and nearly-top-of-fsf-tree) to which I applied your patch. So there
might indeed be some differences that would cause a conflict; I just
don't see any, right now.
Perhaps there are some withspace differences? I hate those tabs with a
passion, and always having them right is really difficult and fustrating
for me.
> > --- a/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
> > +++ b/ada-lang.c Tue Sep 09 12:57:26 2008 -0700
> > @@ -10541,11 +10541,10 @@ ada_evaluate_subexp (struct type *expect
> >
> > if (noside == EVAL_SKIP)
> > goto nosideret;
> > - type = builtin_type (exp->gdbarch)->builtin_int;
> > if (noside == EVAL_AVOID_SIDE_EFFECTS)
> > - return value_zero (type, not_lval);
> > - else
> > - return value_from_longest (type,
> > + return value_zero (builtin_type_int32, not_lval);
> > + else
> > + return value_from_longest (builtin_type_int32,
> > TARGET_CHAR_BIT * TYPE_LENGTH (type));
> >
> > case OP_ATR_VAL:
>
> The OP_ATR_SIZE in ada_evaluate_subexp in current head looks like this:
>
> case OP_ATR_SIZE:
> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
> if (noside == EVAL_SKIP)
> goto nosideret;
> else if (noside == EVAL_AVOID_SIDE_EFFECTS)
> return value_zero (builtin_type_int, not_lval);
> else
> return value_from_longest (builtin_type_int,
> TARGET_CHAR_BIT
> * TYPE_LENGTH (value_type (arg1)));
>
> and after my patch set we have:
>
> case OP_ATR_SIZE:
> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
> if (noside == EVAL_SKIP)
> goto nosideret;
> type = builtin_type (exp->gdbarch)->builtin_int;
> if (noside == EVAL_AVOID_SIDE_EFFECTS)
> return value_zero (type, not_lval);
> else
> return value_from_longest (type,
> TARGET_CHAR_BIT
> * TYPE_LENGTH (value_type (arg1)));
>
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-10 6:18 ` Joel Brobecker
@ 2008-09-10 9:43 ` Ulrich Weigand
2008-09-10 16:25 ` Joel Brobecker
0 siblings, 1 reply; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-10 9:43 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> Sure! I don't know what this didn't cross my mind earlier, I guess
> I was in a bit of a crunch... Will do that tomorrow (I'm also planning
> on submitting a bunch of patches tomorrow as well, if things go as
> planned - so that'll be a good time for that).
OK, thanks!
> It was on top of your patch - If I am not mistaken, it should apply
> cleanly after you apply yours. I did, however, generate the patch
> against AdaCore's gdb-head (which is a merge between our changes
> and nearly-top-of-fsf-tree) to which I applied your patch. So there
> might indeed be some differences that would cause a conflict; I just
> don't see any, right now.
Your version has:
> > > + return value_from_longest (builtin_type_int32,
> > > TARGET_CHAR_BIT * TYPE_LENGTH (type));
which causes the problem with the re-used "type" variable.
The current gdb-head version has:
> > return value_from_longest (builtin_type_int,
> > TARGET_CHAR_BIT
> > * TYPE_LENGTH (value_type (arg1)));
instead, where this problem does not occur.
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] 98+ messages in thread
* Re: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
2008-09-10 6:09 ` Joel Brobecker
@ 2008-09-10 9:51 ` Ulrich Weigand
0 siblings, 0 replies; 98+ messages in thread
From: Ulrich Weigand @ 2008-09-10 9:51 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> > ChangeLog:
> >
> > * ada-lang.c (ada_array_length): Use builtin_type_int32 instead
> > of builtin_type_int.
> > (ada_evaluate_subexp) [UNOP_IN_RANGE]: Use operand range type
> > instead of builtin_type_int.
>
> I think we can commit this independently of the rest, right?
Sure. I've checked this in now ...
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] 98+ messages in thread
* Re: [rfc][00/37] Eliminate builtin_type_ macros
2008-09-10 9:43 ` Ulrich Weigand
@ 2008-09-10 16:25 ` Joel Brobecker
0 siblings, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-10 16:25 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]
> > Sure! I don't know what this didn't cross my mind earlier, I guess
> > I was in a bit of a crunch... Will do that tomorrow (I'm also planning
> > on submitting a bunch of patches tomorrow as well, if things go as
> > planned - so that'll be a good time for that).
>
> OK, thanks!
OK, I ended up checking in both patches (there was simply too much
confusion on the second one, so it was simpler if I just change
the use of builtin_type_int into builtin_type_int32). Hopefully,
this should clear the way for you to commit your series of patches!
2008-09-10 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_evaluate_subexp) [BINOP_ADD, BINOP_SUB]:
Add special handling for pointer types.
2008-09-10 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_evaluate_subexp) [OP_ATR_SIZE]: Use
archecture-neutral builtin_type_int32 instead of builtin_type_int.
As I said, using int32 is not completely ideal, but should be good
enough in practice. If someone ever hits that limitation, I'll think
about writing a function that returns a type that's big enough to hold
a given LONGEST/ULONGEST...
Actual patches attached. Tested on x86-linux by running the gdb.ada
testcases.
Cheers,
--
Joel
[-- Attachment #2: 01-ptrdiff.diff --]
[-- Type: text/plain, Size: 1409 bytes --]
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -p -r1.156 -r1.157
--- ada-lang.c 10 Sep 2008 09:47:39 -0000 1.156
+++ ada-lang.c 10 Sep 2008 16:12:35 -0000 1.157
@@ -8497,6 +8497,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) + value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
@@ -8514,6 +8518,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) - value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
[-- Attachment #3: 02-size_atr.diff --]
[-- Type: text/plain, Size: 807 bytes --]
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.157
diff -u -p -r1.157 ada-lang.c
--- ada-lang.c 10 Sep 2008 16:12:35 -0000 1.157
+++ ada-lang.c 10 Sep 2008 16:19:19 -0000
@@ -9074,9 +9074,9 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type_int, not_lval);
+ return value_zero (builtin_type_int32, not_lval);
else
- return value_from_longest (builtin_type_int,
+ return value_from_longest (builtin_type_int32,
TARGET_CHAR_BIT
* TYPE_LENGTH (value_type (arg1)));
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-09-07 15:59 ` Ulrich Weigand
@ 2008-09-13 15:23 ` Daniel Jacobowitz
2008-09-13 17:23 ` Joel Brobecker
1 sibling, 0 replies; 98+ messages in thread
From: Daniel Jacobowitz @ 2008-09-13 15:23 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches
On Sun, Sep 07, 2008 at 05:58:20PM +0200, Ulrich Weigand wrote:
> 2.) lookup_pointer_type gets an gdbarch argument (or maybe just a
> "size" argument, as that is what we really need)
>
> In this case, we'd probably have to extend the caching mechanims
> to cache pointers of multiple different sizes (note that to some
> extent that exists today via TYPE_CHAIN, see make_qualified_type).
>
> Then, there wouldn't really be any strict reason any more why
> we couldn't allow making pointer types to platform-neutral types ...
I like this idea; maybe pass the gdbarch to lookup_pointer_type, and
let it encapsulate the knowledge that the size is all we need?
There are architectures with differently sized pointers; this might
make them easier to accomodate someday.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 98+ messages in thread
* Re: [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void
2008-09-07 15:59 ` Ulrich Weigand
2008-09-13 15:23 ` Daniel Jacobowitz
@ 2008-09-13 17:23 ` Joel Brobecker
1 sibling, 0 replies; 98+ messages in thread
From: Joel Brobecker @ 2008-09-13 17:23 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Daniel Jacobowitz, gdb-patches
> 2.) lookup_pointer_type gets an gdbarch argument (or maybe just a
> "size" argument, as that is what we really need)
>
> In this case, we'd probably have to extend the caching mechanims
> to cache pointers of multiple different sizes (note that to some
> extent that exists today via TYPE_CHAIN, see make_qualified_type).
>
> Then, there wouldn't really be any strict reason any more why
> we couldn't allow making pointer types to platform-neutral types ...
I like this approach as well - I think that passing the gdbarch is fine.
The lookup_pointer_type could iterate over the TYPE_CHAIN list until
it finds a pointer of the right size (or create a new one if not).
--
Joel
^ permalink raw reply [flat|nested] 98+ messages in thread
end of thread, other threads:[~2008-09-13 17:23 UTC | newest]
Thread overview: 98+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
2008-08-31 17:52 ` [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc uweigand
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
2008-09-05 23:13 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
2008-09-06 3:15 ` Joel Brobecker
2008-09-07 16:44 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture uweigand
2008-08-31 17:52 ` [rfc][33/37] Eliminate builtin_type_ macros: Default target word size uweigand
2008-08-31 17:52 ` [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator uweigand
2008-08-31 17:52 ` [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters uweigand
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
2008-09-05 22:56 ` Joel Brobecker
2008-09-07 15:40 ` Ulrich Weigand
2008-09-07 15:49 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
2008-09-01 7:19 ` Tom Tromey
2008-09-02 23:34 ` Ulrich Weigand
2008-09-05 23:02 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
2008-09-05 18:18 ` Joel Brobecker
2008-09-05 20:16 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines uweigand
2008-08-31 17:52 ` [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit uweigand
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
2008-09-02 12:43 ` Daniel Jacobowitz
2008-09-02 21:55 ` Ulrich Weigand
2008-09-02 22:00 ` Daniel Jacobowitz
2008-09-02 23:53 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
2008-09-06 0:38 ` Joel Brobecker
2008-09-06 4:12 ` Daniel Jacobowitz
2008-09-06 14:00 ` Joel Brobecker
2008-09-07 15:59 ` Ulrich Weigand
2008-09-13 15:23 ` Daniel Jacobowitz
2008-09-13 17:23 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
2008-09-05 18:08 ` Joel Brobecker
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
2008-09-06 0:24 ` Joel Brobecker
2008-09-07 15:43 ` Ulrich Weigand
2008-09-09 18:00 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 22:08 ` Joel Brobecker
2008-09-09 22:32 ` Ulrich Weigand
2008-09-10 6:09 ` Joel Brobecker
2008-09-10 9:51 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture uweigand
2008-08-31 17:53 ` [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros uweigand
2008-08-31 17:53 ` [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit uweigand
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
2008-09-05 20:18 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
2008-09-05 22:39 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling uweigand
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
2008-09-05 18:16 ` Joel Brobecker
2008-09-05 20:17 ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references uweigand
2008-08-31 17:53 ` [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types uweigand
2008-08-31 17:53 ` [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code uweigand
2008-08-31 17:53 ` [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type uweigand
2008-08-31 17:53 ` [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number uweigand
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
2008-09-02 12:38 ` Daniel Jacobowitz
2008-09-02 21:48 ` Ulrich Weigand
2008-09-02 21:52 ` Daniel Jacobowitz
2008-09-04 22:32 ` Tom Tromey
2008-09-05 18:21 ` Joel Brobecker
2008-08-31 17:53 ` [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info uweigand
2008-08-31 17:53 ` [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c uweigand
2008-08-31 17:53 ` [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation uweigand
2008-08-31 18:12 ` [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c uweigand
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
2008-09-06 1:37 ` Joel Brobecker
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
2008-09-02 12:48 ` Daniel Jacobowitz
2008-09-02 21:56 ` Ulrich Weigand
2008-08-31 18:16 ` [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files uweigand
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
2008-09-01 3:46 ` David Miller
2008-09-01 18:57 ` Ulrich Weigand
2008-09-02 10:22 ` Mark Kettenis
2008-09-02 12:30 ` Daniel Jacobowitz
2008-09-02 21:37 ` Ulrich Weigand
2008-09-02 12:50 ` Daniel Jacobowitz
2008-09-02 22:02 ` Ulrich Weigand
2008-09-02 22:12 ` Daniel Jacobowitz
2008-09-06 3:16 ` Joel Brobecker
2008-09-07 16:43 ` Ulrich Weigand
2008-09-09 18:05 ` Joel Brobecker
2008-09-09 20:21 ` Ulrich Weigand
2008-09-09 21:18 ` Joel Brobecker
2008-09-09 22:12 ` Ulrich Weigand
2008-09-10 6:18 ` Joel Brobecker
2008-09-10 9:43 ` Ulrich Weigand
2008-09-10 16:25 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox