From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wWc+JilN1mqhODMAWB0awg (envelope-from ) for ; Mon, 19 Oct 2026 13:02:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 97AE91E050; Mon, 19 Oct 2026 13:02:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E0CA91E04E for ; Mon, 19 Oct 2026 13:02:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 161F04BA2E1E for ; Mon, 19 Oct 2026 17:02:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 161F04BA2E1E Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A95B64BA23DB; Mon, 19 Oct 2026 16:59:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A95B64BA23DB Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A95B64BA23DB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792429175; cv=none; b=VLiOCwPuTpUzVj56lWwT1xGPK1FggKfSWmOrW8xhKoQxkDX/vWV9re1kwY7a0+w/xDI1RLnrOlg1azoN9vdvCRYl2H9vuAznK2HgNH+uyy8bUKwJwInq/ae38rINKyLMseCtByhtBzt0pI4iQRUo0iwM7ChWKqDa8ilIj6tWDEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792429175; c=relaxed/simple; bh=ZivC5uihsvBdeUazWhs5ETV38fAE4PaOrgmoHFq34hs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=eg7rDxIIlU9LRVyqnr3X7ZjNk0msQUNTJ+fYOm9gGuGw5dLzWNkJn9iB9Mrfnpbf+MqQ1FQ5lVQvjhDeJuk10Dk2eVIRBuxp0MinNSg90jLl2JGzYSNtWzN3Wk531e0S3dG5JKK4gwOjqz6A/reCmn/rWpF7KydtCSlPFjKtSDk= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A95B64BA23DB Received: by simark.ca (Postfix) id 054721E090; Mon, 19 Oct 2026 12:59:34 -0400 (EDT) From: Simon Marchi To: gcc-patches@sourceware.org, gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/6] gdb/gmp-utils: rename gdb_mp{z,q,f}::str to to_string Date: Mon, 19 Oct 2026 12:58:20 -0400 Message-ID: <20261019165929.792697-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261019165929.792697-1-simon.marchi@efficios.com> References: <20261019165929.792697-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This makes the following patch a bit easier, allowing those objects to be printed as part of a SELF_CHECK expression. Rename hex to to_hex_string, for symmetry. Change-Id: I65333129d7074a167f19abae63b3b82da7c1b6a7 --- gdb/ada-typeprint.c | 2 +- gdb/cp-name-parser.c | 2 +- gdb/expprint.c | 3 ++- gdb/gdbtypes.c | 2 +- gdb/gmp-utils.c | 10 +++++----- gdb/gmp-utils.h | 12 +++++++----- gdb/typeprint.c | 2 +- gdb/valprint.c | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 15045a02f356..eaceac9cc3a6 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -1050,7 +1050,7 @@ ada_print_type (struct type *type0, const char *varstring, } else modulus = 0; - gdb_printf (stream, "mod %s", modulus.str ().c_str ()); + gdb_printf (stream, "mod %s", modulus.to_string ().c_str ()); } else { diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c index fe2ffd61a6c8..0c34942ff678 100644 --- a/gdb/cp-name-parser.c +++ b/gdb/cp-name-parser.c @@ -342,7 +342,7 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, value += dig; } - std::string printed = value.str (); + std::string printed = value.to_string (); const char *copy = obstack_strdup (&demangle_info->obstack, printed); if (long_p == 0) diff --git a/gdb/expprint.c b/gdb/expprint.c index 4859d48f6a4e..26f54eed0d78 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -102,7 +102,8 @@ dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr) 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 ()); + gdb_printf (stream, _("%*sConstant: %s\n"), depth, "", + val.to_string ().c_str ()); } void diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index e0c25c58d83b..2db3f7ebe733 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4881,7 +4881,7 @@ static void print_fixed_point_type_info (struct type *type, int spaces) { gdb_printf ("%*sscaling factor: %s\n", spaces + 2, "", - type->fixed_point_scaling_factor ().str ().c_str ()); + type->fixed_point_scaling_factor ().to_string ().c_str ()); } static struct obstack dont_print_type_obstack; diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c index 6438a4615d42..fb9548d2b6ed 100644 --- a/gdb/gmp-utils.c +++ b/gdb/gmp-utils.c @@ -47,8 +47,8 @@ extern void ATTRIBUTE_USED debug (const gdb_mpz &); void ATTRIBUTE_USED debug (const gdb_mpz &val) { - std::string dec = val.str (); - std::string hex = val.hex (); + std::string dec = val.to_string (); + std::string hex = val.to_hex_string (); gdb_printf (gdb_stdlog, "%s (%s)\n", dec.c_str (), hex.c_str ()); gdb_flush (gdb_stdlog); } @@ -123,11 +123,11 @@ gdb_mpz::export_bits (gdb::array_view buf, int endian, bool unsigned_p if (mpz_cmp (m_val, lo.m_val) < 0 || mpz_cmp (m_val, hi.m_val) > 0) error (_("Cannot export value %s as %zu-bits %s integer" " (must be between %s and %s)"), - this->str ().c_str (), + this->to_string ().c_str (), max_usable_bits, unsigned_p ? _("unsigned") : _("signed"), - lo.str ().c_str (), - hi.str ().c_str ()); + lo.to_string ().c_str (), + hi.to_string ().c_str ()); } gdb_mpz truncated = *this; diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h index 04f8d0c83dc4..92a21457895f 100644 --- a/gdb/gmp-utils.h +++ b/gdb/gmp-utils.h @@ -159,10 +159,12 @@ struct gdb_mpz } /* Return a string containing VAL. */ - std::string str () const { return gmp_string_printf ("%Zd", m_val); } + std::string to_string () const + { return gmp_string_printf ("%Zd", m_val); } - /* As str, but in hex. */ - std::string hex () const { return gmp_string_printf ("%#Zx", m_val); } + /* As to_string, but in hex. */ + std::string to_hex_string () const + { return gmp_string_printf ("%#Zx", m_val); } /* The destructor. */ ~gdb_mpz () { mpz_clear (m_val); } @@ -540,7 +542,7 @@ struct gdb_mpq } /* Return a string representing VAL as " / ". */ - std::string str () const { return gmp_string_printf ("%Qd", m_val); } + std::string to_string () const { return gmp_string_printf ("%Qd", m_val); } /* Return VAL rounded to the nearest integer. */ gdb_mpz get_rounded () const; @@ -621,7 +623,7 @@ struct gdb_mpf /* Convert this value to a string. FMT is the format to use, and should have a single '%' substitution. */ - std::string str (const char *fmt) const + std::string to_string (const char *fmt) const { return gmp_string_printf (fmt, m_val); } /* The destructor. */ diff --git a/gdb/typeprint.c b/gdb/typeprint.c index a23b5b54c0ab..2fd023bce60e 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -619,7 +619,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream) void print_type_fixed_point (struct type *type, struct ui_file *stream) { - std::string small_img = type->fixed_point_scaling_factor ().str (); + std::string small_img = type->fixed_point_scaling_factor ().to_string (); gdb_printf (stream, "%s-byte fixed point (small = %s)", pulongest (type->length ()), small_img.c_str ()); diff --git a/gdb/valprint.c b/gdb/valprint.c index 7e41943f66fa..affddc387de9 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -876,7 +876,7 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, type->fixed_point_scaling_factor ()); const char *fmt = type->length () < 4 ? "%.11Fg" : "%.17Fg"; - std::string str = f.str (fmt); + std::string str = f.to_string (fmt); gdb_printf (stream, "%s", str.c_str ()); } } -- 2.56.0