summaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-03-01 15:13:21 -0700
committerTom Tromey <tromey@adacore.com>2023-03-27 08:20:29 -0600
commit303a881f8789733248f27af0c872d356a34be009 (patch)
tree9ffda24d7cd521e72e568bae8d8df20e5c94bc7a /gdb/valops.c
parentd784fa8fb2936fb9bd2ebb8e1854b855ca206d96 (diff)
downloadbinutils-gdb-303a881f8789733248f27af0c872d356a34be009.tar.gz
Use gdb_gmp for scalar arithmetic
This changes gdb to use scalar arithmetic for expression evaluation. I suspect this patch is not truly complete, as there may be code paths that still don't correctly handle 128-bit integers. However, many things do work now. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30190
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index bf9d6a78106..02747543a53 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -570,7 +570,7 @@ value_cast (struct type *type, struct value *arg2)
&& (scalar || code2 == TYPE_CODE_PTR
|| code2 == TYPE_CODE_MEMBERPTR))
{
- LONGEST longest;
+ gdb_mpz longest;
/* When we cast pointers to integers, we mustn't use
gdbarch_pointer_to_address to find the address the pointer
@@ -579,12 +579,14 @@ value_cast (struct type *type, struct value *arg2)
sees a cast as a simple reinterpretation of the pointer's
bits. */
if (code2 == TYPE_CODE_PTR)
- longest = extract_unsigned_integer
- (arg2->contents (), type_byte_order (type2));
+ longest = extract_unsigned_integer (arg2->contents (),
+ type_byte_order (type2));
else
- longest = value_as_long (arg2);
- return value_from_longest (to_type, convert_to_boolean ?
- (LONGEST) (longest ? 1 : 0) : longest);
+ longest = value_as_mpz (arg2);
+ if (convert_to_boolean)
+ longest = bool (longest);
+
+ return value_from_mpz (to_type, longest);
}
else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT
|| code2 == TYPE_CODE_ENUM