From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 3B782385841C; Mon, 17 Apr 2023 17:03:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B782385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681751020; bh=sC3NGGktDDDtbJ7Od1uroBhGEbcaVyiXfbQ4aHJ3ajQ=; h=From:To:Subject:Date:From; b=a+Z/YJhr9tOuAQF4kklQxms+oiATfNXVqWlZ0PzVSfskxc0MlEbyFhT398Uo6S4Uo gqPyMqWDgjAeuMd7azl5fwDZf9MqltxcgEgerQnzHUALTFCv7meAN0Z+hdNssKFL/M m9YShP6NhRGXs1/zdaGEM4RdcgyvtxX+VwAzjSsU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Convert long_const_operation to use gdb_mpz X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 767c4b92bc4333cb1b49a42b8d012170a40900fe X-Git-Newrev: 5309ce2f04d8b76ff8a8005f6115cdf544d83bf7 Message-Id: <20230417170340.3B782385841C@sourceware.org> Date: Mon, 17 Apr 2023 17:03:40 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5309ce2f04d8= b76ff8a8005f6115cdf544d83bf7 commit 5309ce2f04d8b76ff8a8005f6115cdf544d83bf7 Author: Tom Tromey Date: Mon Mar 27 12:54:51 2023 -0600 Convert long_const_operation to use gdb_mpz =20 This changes long_const_operation to use gdb_mpz for its storage. Diff: --- gdb/ada-lang.c | 4 ++-- gdb/ax-gdb.c | 4 ++-- gdb/expop.h | 26 +++++++++++++++++++++++--- gdb/expprint.c | 6 ++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d2d7dca5c1e..2a25d42338e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10590,10 +10590,10 @@ ada_char_operation::replace (operation_up &&owner, =20 if (context_type !=3D nullptr && context_type->code () =3D=3D TYPE_CODE_= ENUM) { + LONGEST val =3D as_longest (); gdb_assert (result.get () =3D=3D this); std::get<0> (m_storage) =3D context_type; - std::get<1> (m_storage) - =3D convert_char_literal (context_type, std::get<1> (m_storage)); + std::get<1> (m_storage) =3D convert_char_literal (context_type, val); } =20 return result; diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 1ed648ce002..9dda7fe524d 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1630,8 +1630,8 @@ long_const_operation::do_generate_ax (struct expressi= on *exp, struct axs_value *value, struct type *cast_type) { - gen_int_literal (ax, value, std::get<1> (m_storage), - std::get<0> (m_storage)); + LONGEST val =3D as_longest (); + gen_int_literal (ax, value, val, std::get<0> (m_storage)); } =20 void diff --git a/gdb/expop.h b/gdb/expop.h index d973d2314bb..854945c8688 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -274,6 +274,12 @@ check_objfile (ULONGEST val, struct objfile *objfile) return false; } =20 +static inline bool +check_objfile (const gdb_mpz &val, struct objfile *objfile) +{ + return false; +} + template static inline bool check_objfile (enum_flags val, struct objfile *objfile) @@ -319,6 +325,8 @@ extern void dump_for_expression (struct ui_file *stream= , int depth, struct type *type); extern void dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr); +extern void dump_for_expression (struct ui_file *stream, int depth, + const gdb_mpz &addr); extern void dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar); extern void dump_for_expression (struct ui_file *stream, int depth, @@ -468,6 +476,12 @@ check_constant (ULONGEST cst) return true; } =20 +static inline bool +check_constant (const gdb_mpz &cst) +{ + return true; +} + static inline bool check_constant (struct symbol *sym) { @@ -665,18 +679,21 @@ protected: }; =20 class long_const_operation - : public tuple_holding_operation + : public tuple_holding_operation { public: =20 using tuple_holding_operation::tuple_holding_operation; =20 + long_const_operation (struct type *type, LONGEST val) + : long_const_operation (type, gdb_mpz (val)) + { } + value *evaluate (struct type *expect_type, struct expression *exp, enum noside noside) override { - return value_from_longest (std::get<0> (m_storage), - std::get<1> (m_storage)); + return value_from_mpz (std::get<0> (m_storage), std::get<1> (m_storage= )); } =20 enum exp_opcode opcode () const override @@ -687,6 +704,9 @@ public: =20 protected: =20 + LONGEST as_longest () const + { return std::get<1> (m_storage).as_integer_truncate (); } + void do_generate_ax (struct expression *exp, struct agent_expr *ax, struct axs_value *value, diff --git a/gdb/expprint.c b/gdb/expprint.c index 0c7cc754179..e0ec25573c2 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -108,6 +108,12 @@ dump_for_expression (struct ui_file *stream, int depth= , CORE_ADDR addr) core_addr_to_string (addr)); } =20 +void +dump_for_expression (struct ui_file *stream, int depth, const gdb_mpz &val) +{ + gdb_printf (stream, _("%*sConstant: %s\n"), depth, "", val.str ().c_str = ()); +} + void dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar) {