* printcmd.c (decode_format): Don't blithely set the size for
an address to 'w'. Make it 'g' or 'h', depending on TARGET_PTR_BIT. * defs.h: Just typedef CORE_ADDR to bfd_vma. Include bfd.h. If BFD64, make a LONGEST a BFD_HOST_64_BIT. * defs.h (longest_to_int): Don't depend on CC_HAS_LONG_LONG; instead always just check against INT_MIN and INT_MAX (this also fixes things if sizeof (long) > sizeof (int), e.g. Alpha). * config/pa/tm-hppa.h, config/i386/sun386.h, config/rs6000/tm-rs6000.h: Don't define LONGEST or BUILTIN_TYPE_LONGEST. * gdbtypes.h: Remove BUILTIN_TYPE_LONGEST and BUILTIN_TYPE_UNSIGNED_LONGEST. * language.h, c-lang.c, ch-lang.c, m2-lang.c: Remove longest_int and longest_unsigned_int. * value.h (struct value): Just align to LONGEST, rather than worrying about CC_HAS_LONG_LONG. * valarith.c (value_binop, _initialize_valarith): Figure out type ourself based on sizeof (LONGEST) rather than relying on BUILTIN_TYPE_LONGEST. The point is that we don't depend on CC_HAS_LONG_LONG anymore. * valprint.c (val_print_type_code_int): Just call extract_unsigned_integer directly, rather than going through unpack_long. * printcmd.c (decode_format): Remove code which would sometimes change 'g' size to 'w' for integers. print_scalar_formatted handles printing huge integers well enough, thank you.
This commit is contained in:
parent
1fb57a5d3e
commit
eade0c6ce8
@ -1,5 +1,32 @@
|
||||
Wed Feb 2 11:16:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||
|
||||
* printcmd.c (decode_format): Don't blithely set the size for
|
||||
an address to 'w'. Make it 'g' or 'h', depending on TARGET_PTR_BIT.
|
||||
|
||||
* defs.h: Just typedef CORE_ADDR to bfd_vma. Include bfd.h.
|
||||
If BFD64, make a LONGEST a BFD_HOST_64_BIT.
|
||||
* defs.h (longest_to_int): Don't depend on CC_HAS_LONG_LONG; instead
|
||||
always just check against INT_MIN and INT_MAX (this also fixes things
|
||||
if sizeof (long) > sizeof (int), e.g. Alpha).
|
||||
* config/pa/tm-hppa.h, config/i386/sun386.h, config/rs6000/tm-rs6000.h:
|
||||
Don't define LONGEST or BUILTIN_TYPE_LONGEST.
|
||||
* gdbtypes.h: Remove BUILTIN_TYPE_LONGEST and
|
||||
BUILTIN_TYPE_UNSIGNED_LONGEST.
|
||||
* language.h, c-lang.c, ch-lang.c, m2-lang.c: Remove longest_int
|
||||
and longest_unsigned_int.
|
||||
* value.h (struct value): Just align to LONGEST, rather than worrying
|
||||
about CC_HAS_LONG_LONG.
|
||||
* valarith.c (value_binop, _initialize_valarith): Figure out type
|
||||
ourself based on sizeof (LONGEST) rather than relying on
|
||||
BUILTIN_TYPE_LONGEST. The point is that we don't depend on
|
||||
CC_HAS_LONG_LONG anymore.
|
||||
* valprint.c (val_print_type_code_int): Just call
|
||||
extract_unsigned_integer directly, rather than going through
|
||||
unpack_long.
|
||||
* printcmd.c (decode_format): Remove code which would sometimes
|
||||
change 'g' size to 'w' for integers. print_scalar_formatted handles
|
||||
printing huge integers well enough, thank you.
|
||||
|
||||
* command.c (add_set_cmd, no_just_help_class_command): Change
|
||||
to make this the sfunc, not cfunc, since that is how we call it.
|
||||
* command.h: Comment difference between sfunc and cfunc.
|
||||
|
@ -404,8 +404,6 @@ const struct language_defn c_language_defn = {
|
||||
c_create_fundamental_type, /* Create fundamental type in this language */
|
||||
c_print_type, /* Print a type using appropriate syntax */
|
||||
c_val_print, /* Print a value using appropriate syntax */
|
||||
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */
|
||||
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
|
||||
&builtin_type_double, /* longest floating point type */ /*FIXME*/
|
||||
{"", "", "", ""}, /* Binary format info */
|
||||
{"0%lo", "0", "o", ""}, /* Octal format info */
|
||||
@ -428,8 +426,6 @@ const struct language_defn cplus_language_defn = {
|
||||
c_create_fundamental_type, /* Create fundamental type in this language */
|
||||
c_print_type, /* Print a type using appropriate syntax */
|
||||
c_val_print, /* Print a value using appropriate syntax */
|
||||
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */
|
||||
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
|
||||
&builtin_type_double, /* longest floating point type */ /*FIXME*/
|
||||
{"", "", "", ""}, /* Binary format info */
|
||||
{"0%lo", "0", "o", ""}, /* Octal format info */
|
||||
|
@ -315,8 +315,6 @@ const struct language_defn chill_language_defn = {
|
||||
chill_create_fundamental_type,/* Create fundamental type in this language */
|
||||
chill_print_type, /* Print a type using appropriate syntax */
|
||||
chill_val_print, /* Print a value using appropriate syntax */
|
||||
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */
|
||||
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
|
||||
&builtin_type_chill_real, /* longest floating point type */
|
||||
{"", "B'", "", ""}, /* Binary format info */
|
||||
{"O'%lo", "O'", "o", ""}, /* Octal format info */
|
||||
|
@ -86,12 +86,6 @@ i386_skip_prologue PARAMS ((int));
|
||||
|
||||
#define INVALID_FLOAT(p, len) (0)
|
||||
|
||||
/* Largest integer type */
|
||||
#define LONGEST long
|
||||
|
||||
/* Name of the builtin type for the LONGEST type above. */
|
||||
#define BUILTIN_TYPE_LONGEST builtin_type_long
|
||||
|
||||
/* Say how long (ordinary) registers are. This is a piece of bogosity
|
||||
used in push_word and a few other places; REGISTER_RAW_SIZE is the
|
||||
real way to know how big a register is. */
|
||||
|
@ -600,20 +600,6 @@ extern struct type *builtin_type_chill_long;
|
||||
extern struct type *builtin_type_chill_ulong;
|
||||
extern struct type *builtin_type_chill_real;
|
||||
|
||||
/* CC_HAS_LONG_LONG is defined if the host has "long long". */
|
||||
|
||||
#ifdef CC_HAS_LONG_LONG
|
||||
|
||||
#define BUILTIN_TYPE_LONGEST builtin_type_long_long
|
||||
#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long
|
||||
|
||||
#else /* not CC_HAS_LONG_LONG. */
|
||||
|
||||
#define BUILTIN_TYPE_LONGEST builtin_type_long
|
||||
#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long
|
||||
|
||||
#endif /* not CC_HAS_LONG_LONG. */
|
||||
|
||||
/* Maximum and minimum values of built-in types */
|
||||
|
||||
#define MAX_OF_TYPE(t) \
|
||||
|
@ -144,14 +144,6 @@ struct language_defn
|
||||
int (*la_val_print) PARAMS ((struct type *, char *, CORE_ADDR, GDB_FILE *,
|
||||
int, int, int, enum val_prettyprint));
|
||||
|
||||
/* Longest signed integral type */
|
||||
|
||||
struct type **la_longest_int;
|
||||
|
||||
/* Longest unsigned integral type */
|
||||
|
||||
struct type **la_longest_unsigned_int;
|
||||
|
||||
/* Longest floating point type */
|
||||
|
||||
struct type **la_longest_float;
|
||||
@ -244,8 +236,6 @@ set_language PARAMS ((enum language));
|
||||
with the "set language" command. */
|
||||
|
||||
/* Returns some built-in types */
|
||||
#define longest_int() (*current_language->la_longest_int)
|
||||
#define longest_unsigned_int() (*current_language->la_longest_unsigned_int)
|
||||
#define longest_float() (*current_language->la_longest_float)
|
||||
|
||||
#define create_fundamental_type(objfile,typeid) \
|
||||
|
@ -405,8 +405,6 @@ const struct language_defn m2_language_defn = {
|
||||
m2_create_fundamental_type, /* Create fundamental type in this language */
|
||||
m2_print_type, /* Print a type using appropriate syntax */
|
||||
m2_val_print, /* Print a value using appropriate syntax */
|
||||
&builtin_type_m2_int, /* longest signed integral type */
|
||||
&builtin_type_m2_card, /* longest unsigned integral type */
|
||||
&builtin_type_m2_real, /* longest floating point type */
|
||||
{"", "", "", ""}, /* Binary format info */
|
||||
{"%loB", "", "o", "B"}, /* Octal format info */
|
||||
|
143
gdb/valarith.c
143
gdb/valarith.c
@ -24,6 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "expression.h"
|
||||
#include "target.h"
|
||||
#include "language.h"
|
||||
#include "demangle.h"
|
||||
#include <string.h>
|
||||
|
||||
/* Define whether or not the C operator '/' truncates towards zero for
|
||||
@ -126,7 +127,10 @@ value_subscript (array, idx)
|
||||
value bound;
|
||||
struct type *range_type;
|
||||
|
||||
if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY)
|
||||
COERCE_REF (array);
|
||||
|
||||
if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY
|
||||
|| TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_STRING)
|
||||
{
|
||||
range_type = TYPE_FIELD_TYPE (VALUE_TYPE (array), 0);
|
||||
lowerbound = TYPE_FIELD_BITPOS (range_type, 0);
|
||||
@ -139,6 +143,7 @@ value_subscript (array, idx)
|
||||
{
|
||||
return value_subscripted_rvalue (array, idx);
|
||||
}
|
||||
array = value_coerce_array (array);
|
||||
}
|
||||
return value_ind (value_add (array, idx));
|
||||
}
|
||||
@ -225,8 +230,8 @@ value_x_binop (arg1, arg2, op, otherop)
|
||||
enum exp_opcode op, otherop;
|
||||
{
|
||||
value * argvec;
|
||||
char *ptr;
|
||||
char tstr[13];
|
||||
char *ptr, *mangle_ptr;
|
||||
char tstr[13], mangle_tstr[13];
|
||||
int static_memfuncp;
|
||||
|
||||
COERCE_REF (arg1);
|
||||
@ -292,7 +297,9 @@ value_x_binop (arg1, arg2, op, otherop)
|
||||
default:
|
||||
error ("Invalid binary operation specified.");
|
||||
}
|
||||
|
||||
argvec[0] = value_struct_elt (&arg1, argvec+1, tstr, &static_memfuncp, "structure");
|
||||
|
||||
if (argvec[0])
|
||||
{
|
||||
if (static_memfuncp)
|
||||
@ -320,8 +327,8 @@ value_x_unop (arg1, op)
|
||||
enum exp_opcode op;
|
||||
{
|
||||
value * argvec;
|
||||
char *ptr;
|
||||
char tstr[13];
|
||||
char *ptr, *mangle_ptr;
|
||||
char tstr[13], mangle_tstr[13];
|
||||
int static_memfuncp;
|
||||
|
||||
COERCE_ENUM (arg1);
|
||||
@ -339,6 +346,8 @@ value_x_unop (arg1, op)
|
||||
/* make the right function name up */
|
||||
strcpy(tstr,"operator__");
|
||||
ptr = tstr+8;
|
||||
strcpy(mangle_tstr, "__");
|
||||
mangle_ptr = mangle_tstr+2;
|
||||
switch (op)
|
||||
{
|
||||
case UNOP_PREINCREMENT: strcpy(ptr,"++"); break;
|
||||
@ -351,7 +360,9 @@ value_x_unop (arg1, op)
|
||||
default:
|
||||
error ("Invalid binary operation specified.");
|
||||
}
|
||||
|
||||
argvec[0] = value_struct_elt (&arg1, argvec+1, tstr, &static_memfuncp, "structure");
|
||||
|
||||
if (argvec[0])
|
||||
{
|
||||
if (static_memfuncp)
|
||||
@ -506,6 +517,15 @@ value_concat (arg1, arg2)
|
||||
}
|
||||
|
||||
|
||||
/* The type we give to value_binop results. This is a kludge to get around
|
||||
the fact that we don't know how to determine the result type from
|
||||
the types of the operands. (I'm not really sure how much we feel
|
||||
the need to duplicate the exact rules of the current language.
|
||||
They can get really hairy. But not to do so makes it hard to document
|
||||
just what we *do* do). */
|
||||
static struct type *signed_operation_result;
|
||||
static struct type *unsigned_operation_result;
|
||||
|
||||
/* Perform a binary operation on two operands which have reasonable
|
||||
representations as integers or floats. This includes booleans,
|
||||
characters, integers, or floats.
|
||||
@ -543,6 +563,9 @@ value_binop (arg1, arg2, op)
|
||||
||
|
||||
TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_FLT)
|
||||
{
|
||||
/* FIXME-if-picky-about-floating-accuracy: Should be doing this
|
||||
in target format. real.c in GCC probably has the necessary
|
||||
code. */
|
||||
double v1, v2, v;
|
||||
v1 = value_as_double (arg1);
|
||||
v2 = value_as_double (arg2);
|
||||
@ -569,8 +592,8 @@ value_binop (arg1, arg2, op)
|
||||
}
|
||||
|
||||
val = allocate_value (builtin_type_double);
|
||||
SWAP_TARGET_AND_HOST (&v, sizeof (v));
|
||||
*(double *) VALUE_CONTENTS_RAW (val) = v;
|
||||
store_floating (VALUE_CONTENTS_RAW (val), TYPE_LENGTH (VALUE_TYPE (val)),
|
||||
v);
|
||||
}
|
||||
else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_BOOL
|
||||
&&
|
||||
@ -598,11 +621,10 @@ value_binop (arg1, arg2, op)
|
||||
error ("Invalid operation on booleans.");
|
||||
}
|
||||
|
||||
/* start-sanitize-chill (FIXME!) */
|
||||
val = allocate_value (builtin_type_chill_bool);
|
||||
/* end-sanitize-chill */
|
||||
SWAP_TARGET_AND_HOST (&v, sizeof (v));
|
||||
*(LONGEST *) VALUE_CONTENTS_RAW (val) = v;
|
||||
store_signed_integer (VALUE_CONTENTS_RAW (val),
|
||||
TYPE_LENGTH (VALUE_TYPE (val)),
|
||||
v);
|
||||
}
|
||||
else
|
||||
/* Integral operations here. */
|
||||
@ -612,7 +634,7 @@ value_binop (arg1, arg2, op)
|
||||
if ((TYPE_UNSIGNED (VALUE_TYPE (arg1))
|
||||
|| TYPE_UNSIGNED (VALUE_TYPE (arg2)))
|
||||
&& (TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST)
|
||||
|| TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST)))
|
||||
|| TYPE_LENGTH (VALUE_TYPE (arg2)) >= sizeof (unsigned LONGEST)))
|
||||
{
|
||||
unsigned LONGEST v1, v2, v;
|
||||
v1 = (unsigned LONGEST) value_as_long (arg1);
|
||||
@ -643,14 +665,12 @@ value_binop (arg1, arg2, op)
|
||||
case BINOP_MOD:
|
||||
/* Knuth 1.2.4, integer only. Note that unlike the C '%' op,
|
||||
v1 mod 0 has a defined value, v1. */
|
||||
/* start-sanitize-chill */
|
||||
/* Chill specifies that v2 must be > 0, so check for that. */
|
||||
if (current_language -> la_language == language_chill
|
||||
&& value_as_long (arg2) <= 0)
|
||||
{
|
||||
error ("Second operand of MOD must be greater than zero.");
|
||||
}
|
||||
/* end-sanitize-chill */
|
||||
if (v2 == 0)
|
||||
{
|
||||
v = v1;
|
||||
@ -703,9 +723,10 @@ value_binop (arg1, arg2, op)
|
||||
error ("Invalid binary operation on numbers.");
|
||||
}
|
||||
|
||||
val = allocate_value (BUILTIN_TYPE_UNSIGNED_LONGEST);
|
||||
SWAP_TARGET_AND_HOST (&v, sizeof (v));
|
||||
*(unsigned LONGEST *) VALUE_CONTENTS_RAW (val) = v;
|
||||
val = allocate_value (unsigned_operation_result);
|
||||
store_unsigned_integer (VALUE_CONTENTS_RAW (val),
|
||||
TYPE_LENGTH (VALUE_TYPE (val)),
|
||||
v);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -738,14 +759,12 @@ value_binop (arg1, arg2, op)
|
||||
case BINOP_MOD:
|
||||
/* Knuth 1.2.4, integer only. Note that unlike the C '%' op,
|
||||
X mod 0 has a defined value, X. */
|
||||
/* start-sanitize-chill */
|
||||
/* Chill specifies that v2 must be > 0, so check for that. */
|
||||
if (current_language -> la_language == language_chill
|
||||
&& v2 <= 0)
|
||||
{
|
||||
error ("Second operand of MOD must be greater than zero.");
|
||||
}
|
||||
/* end-sanitize-chill */
|
||||
if (v2 == 0)
|
||||
{
|
||||
v = v1;
|
||||
@ -802,9 +821,10 @@ value_binop (arg1, arg2, op)
|
||||
error ("Invalid binary operation on numbers.");
|
||||
}
|
||||
|
||||
val = allocate_value (BUILTIN_TYPE_LONGEST);
|
||||
SWAP_TARGET_AND_HOST (&v, sizeof (v));
|
||||
*(LONGEST *) VALUE_CONTENTS_RAW (val) = v;
|
||||
val = allocate_value (signed_operation_result);
|
||||
store_signed_integer (VALUE_CONTENTS_RAW (val),
|
||||
TYPE_LENGTH (VALUE_TYPE (val)),
|
||||
v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -968,3 +988,82 @@ value_complement (arg1)
|
||||
return value_from_longest (VALUE_TYPE (arg1), ~ value_as_long (arg1));
|
||||
}
|
||||
|
||||
/* The INDEX'th bit of SET value whose VALUE_TYPE is TYPE,
|
||||
and whose VALUE_CONTENTS is valaddr.
|
||||
Return -1 if out of range, -2 other error. */
|
||||
|
||||
int
|
||||
value_bit_index (type, valaddr, index)
|
||||
struct type *type;
|
||||
char *valaddr;
|
||||
int index;
|
||||
{
|
||||
struct type *range;
|
||||
int low_bound, high_bound, bit_length;
|
||||
LONGEST word;
|
||||
range = TYPE_FIELD_TYPE (type, 0);
|
||||
if (TYPE_CODE (range) != TYPE_CODE_RANGE)
|
||||
return -2;
|
||||
low_bound = TYPE_LOW_BOUND (range);
|
||||
high_bound = TYPE_HIGH_BOUND (range);
|
||||
if (index < low_bound || index > high_bound)
|
||||
return -1;
|
||||
bit_length = high_bound - low_bound + 1;
|
||||
index -= low_bound;
|
||||
if (bit_length <= TARGET_CHAR_BIT)
|
||||
word = unpack_long (builtin_type_unsigned_char, valaddr);
|
||||
else if (bit_length <= TARGET_SHORT_BIT)
|
||||
word = unpack_long (builtin_type_unsigned_short, valaddr);
|
||||
else
|
||||
{
|
||||
int word_start_index = (index / TARGET_INT_BIT) * TARGET_INT_BIT;
|
||||
index -= word_start_index;
|
||||
word = unpack_long (builtin_type_unsigned_int,
|
||||
valaddr + (word_start_index / HOST_CHAR_BIT));
|
||||
}
|
||||
#if BITS_BIG_ENDIAN
|
||||
if (bit_length <= TARGET_CHAR_BIT)
|
||||
index = TARGET_CHAR_BIT - 1 - index;
|
||||
else if (bit_length <= TARGET_SHORT_BIT)
|
||||
index = TARGET_SHORT_BIT - 1 - index;
|
||||
else
|
||||
index = TARGET_INT_BIT - 1 - index;
|
||||
#endif
|
||||
return (word >> index) & 1;
|
||||
}
|
||||
|
||||
value
|
||||
value_in (element, set)
|
||||
value element, set;
|
||||
{
|
||||
int member;
|
||||
if (TYPE_CODE (VALUE_TYPE (set)) != TYPE_CODE_SET)
|
||||
error ("Second argument of 'IN' has wrong type");
|
||||
if (TYPE_CODE (VALUE_TYPE (element)) != TYPE_CODE_INT
|
||||
&& TYPE_CODE (VALUE_TYPE (element)) != TYPE_CODE_CHAR
|
||||
&& TYPE_CODE (VALUE_TYPE (element)) != TYPE_CODE_ENUM
|
||||
&& TYPE_CODE (VALUE_TYPE (element)) != TYPE_CODE_BOOL)
|
||||
error ("First argument of 'IN' has wrong type");
|
||||
member = value_bit_index (VALUE_TYPE (set), VALUE_CONTENTS (set),
|
||||
value_as_long (element));
|
||||
if (member < 0)
|
||||
error ("First argument of 'IN' not in range");
|
||||
return value_from_longest (builtin_type_int, member);
|
||||
}
|
||||
|
||||
void
|
||||
_initialize_valarith ()
|
||||
{
|
||||
/* Can't just call init_type because we wouldn't know what names to give
|
||||
them. */
|
||||
if (sizeof (LONGEST) > TARGET_LONG_BIT / HOST_CHAR_BIT)
|
||||
{
|
||||
unsigned_operation_result = builtin_type_unsigned_long_long;
|
||||
signed_operation_result = builtin_type_long_long;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned_operation_result = builtin_type_unsigned_long;
|
||||
signed_operation_result = builtin_type_long;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user