* gdbtypes.c (create_set_type): Set TYPE_LENGTH in bytes, not bits.
* valops.c (value_bitstring): TYPE_LENGTH is bytes, not bits. * gdbtypes.c (force_to_range_type): Calculate upper limit of TYPE_CODE_CHAR depending on TYPE_LENGTH (instead of just using 255).
This commit is contained in:
parent
a56552441f
commit
b46805224b
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Sep 19 15:28:58 1995 Per Bothner <bothner@kalessin.cygnus.com>
|
||||||
|
|
||||||
|
* gdbtypes.c (create_set_type): Set TYPE_LENGTH in bytes, not bits.
|
||||||
|
* valops.c (value_bitstring): TYPE_LENGTH is bytes, not bits.
|
||||||
|
|
||||||
|
* gdbtypes.c (force_to_range_type): Calculate upper limit of
|
||||||
|
TYPE_CODE_CHAR depending on TYPE_LENGTH (instead of just using 255).
|
||||||
|
|
||||||
Mon Sep 18 01:43:42 1995 Jeff Law (law@snake.cs.utah.edu)
|
Mon Sep 18 01:43:42 1995 Jeff Law (law@snake.cs.utah.edu)
|
||||||
|
|
||||||
* somsolib.c (auto_solib_add_at_startup): Delete definition. No
|
* somsolib.c (auto_solib_add_at_startup): Delete definition. No
|
||||||
|
|
|
@ -368,7 +368,8 @@ force_to_range_type (type)
|
||||||
}
|
}
|
||||||
case TYPE_CODE_CHAR:
|
case TYPE_CODE_CHAR:
|
||||||
{
|
{
|
||||||
struct type *range_type = create_range_type (NULL, type, 0, 255);
|
int char_max = 1 << (TYPE_LENGTH (type) * HOST_CHAR_BIT) - 1;
|
||||||
|
struct type *range_type = create_range_type (NULL, type, 0, char_max);
|
||||||
TYPE_NAME (range_type) = TYPE_NAME (range_type);
|
TYPE_NAME (range_type) = TYPE_NAME (range_type);
|
||||||
TYPE_DUMMY_RANGE (range_type) = 1;
|
TYPE_DUMMY_RANGE (range_type) = 1;
|
||||||
return range_type;
|
return range_type;
|
||||||
|
@ -469,8 +470,7 @@ create_set_type (result_type, domain_type)
|
||||||
high_bound = TYPE_HIGH_BOUND (domain_type);
|
high_bound = TYPE_HIGH_BOUND (domain_type);
|
||||||
bit_length = high_bound - low_bound + 1;
|
bit_length = high_bound - low_bound + 1;
|
||||||
TYPE_LENGTH (result_type)
|
TYPE_LENGTH (result_type)
|
||||||
= ((bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT)
|
= (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
|
||||||
* TARGET_CHAR_BIT;
|
|
||||||
}
|
}
|
||||||
TYPE_FIELD_TYPE (result_type, 0) = domain_type;
|
TYPE_FIELD_TYPE (result_type, 0) = domain_type;
|
||||||
return (result_type);
|
return (result_type);
|
||||||
|
|
22
gdb/valops.c
22
gdb/valops.c
|
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
@ -577,6 +577,21 @@ Can't handle bitfield which doesn't fit in a single register.");
|
||||||
error ("Left operand of assignment is not an lvalue.");
|
error ("Left operand of assignment is not an lvalue.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the field does not entirely fill a LONGEST, then zero the sign bits.
|
||||||
|
If the field is signed, and is negative, then sign extend. */
|
||||||
|
if ((VALUE_BITSIZE (toval) > 0)
|
||||||
|
&& (VALUE_BITSIZE (toval) < 8 * sizeof (LONGEST)))
|
||||||
|
{
|
||||||
|
LONGEST fieldval = value_as_long (fromval);
|
||||||
|
LONGEST valmask = (((unsigned LONGEST) 1) << VALUE_BITSIZE (toval)) - 1;
|
||||||
|
|
||||||
|
fieldval &= valmask;
|
||||||
|
if (!TYPE_UNSIGNED (type) && (fieldval & (valmask ^ (valmask >> 1))))
|
||||||
|
fieldval |= ~valmask;
|
||||||
|
|
||||||
|
fromval = value_from_longest (type, fieldval);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a value just like TOVAL except with the contents of FROMVAL
|
/* Return a value just like TOVAL except with the contents of FROMVAL
|
||||||
(except in the case of the type if TOVAL is an internalvar). */
|
(except in the case of the type if TOVAL is an internalvar). */
|
||||||
|
|
||||||
|
@ -586,8 +601,7 @@ Can't handle bitfield which doesn't fit in a single register.");
|
||||||
type = VALUE_TYPE (fromval);
|
type = VALUE_TYPE (fromval);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = allocate_value (type);
|
val = value_copy (toval);
|
||||||
memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val);
|
|
||||||
memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
|
memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
|
||||||
TYPE_LENGTH (type));
|
TYPE_LENGTH (type));
|
||||||
VALUE_TYPE (val) = type;
|
VALUE_TYPE (val) = type;
|
||||||
|
@ -1404,7 +1418,7 @@ value_bitstring (ptr, len)
|
||||||
struct type *type = create_set_type ((struct type*) NULL, domain_type);
|
struct type *type = create_set_type ((struct type*) NULL, domain_type);
|
||||||
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
|
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
|
||||||
val = allocate_value (type);
|
val = allocate_value (type);
|
||||||
memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type) / TARGET_CHAR_BIT);
|
memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue