Article View: gnu.gdb.bug
Article #8771minor bugs in gdb-4.5
From: Pierre Willard
Date: Thu, 03 Dec 1992 19:11
Date: Thu, 03 Dec 1992 19:11
74 lines
2780 bytes
2780 bytes
The following fixes 2 bugs in gdb-4.5. Those bugs
occured on my target where sizeof(int) != sizeof(LONGEST).
in c-exp.y, on my target where sizeof(int) = 2 and sizeof(LONGEST) =
4, 'print 50000' would give '-15536' without the following fix :
exp : INT
{ write_exp_elt_opcode (OP_LONG);
#if 1
if ($1 == (int) $1)
write_exp_elt_type (builtin_type_int);
else if ($1 == (unsigned int) $1)
write_exp_elt_type (builtin_type_unsigned_int);
#else
if ($1 == (int) $1 || $1 == (unsigned int) $1)
write_exp_elt_type (builtin_type_int);
#endif
else
write_exp_elt_type (BUILTIN_TYPE_LONGEST);
write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); }
;
exp : NAME_OR_INT
{ YYSTYPE val;
parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
write_exp_elt_opcode (OP_LONG);
#if 1
if (val.lval == (int) val.lval)
write_exp_elt_type (builtin_type_int);
else if (val.lval == (unsigned int) val.lval)
write_exp_elt_type (builtin_type_unsigned_int);
#else
if (val.lval == (int) val.lval ||
val.lval == (unsigned int) val.lval)
write_exp_elt_type (builtin_type_int);
#endif
else
write_exp_elt_type (BUILTIN_TYPE_LONGEST);
write_exp_elt_longcst (val.lval);
in valarith.c, value_neg() should do as value_binop() for
BINOP_SUB of 0,value. This means use BUILTIN_TYPE_LONGEST
for the result. Else, for example, if sizeof(int) = 2
and sizeof(LONGEST) = 4, 'print -50000' would give '15536'.
value
value_neg (arg1)
register value arg1;
{
register struct type *type;
COERCE_ENUM (arg1);
type = VALUE_TYPE (arg1);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
return value_from_double (type, - value_as_double (arg1));
else if (TYPE_CODE (type) == TYPE_CODE_INT)
#if 1
return value_from_longest (BUILTIN_TYPE_LONGEST, - value_as_long (arg1));
#else
return value_from_longest (type, - value_as_long (arg1));
#endif
else {
error ("Argument to negate operation not a number.");
return 0; /* For lint -- never reached */
}
}
Your comments are welcome.
regards
Pierre Willard
Technical Details
Message-ID:
<9212031911.AA12097@_la.tce.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierreShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,80452ba43f4fb60e,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1992-12-03 21:25:05 PST Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre From: pierre@la.tce.COM (Pierre Willard) Subject: minor bugs in gdb-4.5 Message-ID: <9212031911.AA12097@_la.tce.com> Sender: gnulists@ai.mit.edu Reply-To: pierre@la.tce.com Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 3 Dec 1992 19:11:34 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 75