public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Keith Seitz <keiths@redhat.com>
Subject: Re: [PATCH] Fix gdb/coffread.c build on 32bit architectures
Date: Mon, 28 Aug 2023 16:32:08 +0200	[thread overview]
Message-ID: <2bb7620b4404446cc3ab92da5b79db9a4c45ea69.camel@klomp.org> (raw)
In-Reply-To: <87a5ubuunf.fsf@tromey.com>

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

On Mon, 2023-08-28 at 08:08 -0600, Tom Tromey wrote:
> > > > > > "Mark" == Mark Wielaard <mark@klomp.org> writes:
> 
> Hi Mark.  Thanks for the patch.
> 
> Mark> +	error (_("COFF Error: string table offset (%" PRIxPTR ") outside string table (length %ld)"),
> 
> gdb doesn't use these PRI macros.

Not always, but there are various uses in the code base.
e.g. gdb/dwarf2/cooked-index.c uses
gdb_printf ("    DIE offset: 0x%" PRIx64 "\n", ...
As do gdb/bt-utils.c, gdb/btrace.c, gdb/netbsd-nat.c.
And bfd, opcodes, sim, etc. do use it.

>   Instead you'd write something like:
> 
>     error ("...%s...", hex_string (value))

OK, the attached seems to work on both 32 and 64 bit systems.

Cheers,

Mark

[-- Attachment #2: 0001-Use-hex_string-in-gdb-coffread.c-instead-of-PRIxPTR.patch --]
[-- Type: text/x-patch, Size: 1123 bytes --]

From 3aaddda2c6e3679579c455e7a71981ffe1724206 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Mon, 28 Aug 2023 16:30:14 +0200
Subject: [PATCH] Use hex_string in gdb/coffread.c instead of PRIxPTR

The getsymname function uses PRIxPTR to print and uintptr_t value in
an error message. Use hex_string instead.
---
 gdb/coffread.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index c609c963453..c2fe9fa1761 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1325,8 +1325,8 @@ getsymname (struct internal_syment *symbol_entry)
   if (symbol_entry->_n._n_n._n_zeroes == 0)
     {
       if (symbol_entry->_n._n_n._n_offset > stringtab_length)
-	error (_("COFF Error: string table offset (%" PRIxPTR ") outside string table (length %ld)"),
-	       symbol_entry->_n._n_n._n_offset, stringtab_length);
+	error (_("COFF Error: string table offset (%s) outside string table (length %ld)"),
+	       hex_string (symbol_entry->_n._n_n._n_offset), stringtab_length);
       result = stringtab + symbol_entry->_n._n_n._n_offset;
     }
   else
-- 
2.41.0


  parent reply	other threads:[~2023-08-28 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3b0896a6-04d4-4c7c-ac32-9ae78acdb66c@redhat.com/>
2023-08-25 21:16 ` Mark Wielaard
2023-08-25 21:19   ` Keith Seitz
2023-08-28 14:08   ` Tom Tromey
2023-08-28 14:20     ` Keith Seitz
2023-08-28 14:27       ` Keith Seitz
2023-08-28 14:32     ` Mark Wielaard [this message]
2023-08-28 14:41       ` Andreas Schwab
2023-08-28 16:31       ` Tom Tromey
2023-08-28 16:33       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bb7620b4404446cc3ab92da5b79db9a4c45ea69.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).