Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix build failure for 32-bit targets
Date: Fri,  1 Oct 2021 08:50:02 -0300	[thread overview]
Message-ID: <20211001115002.1681134-1-luis.machado@linaro.org> (raw)

When building master GDB, I ran into the following:

binutils-gdb/gdb/bt-utils.c: In function ‘int libbacktrace_print(void*, uintptr_t, const char*, int, const char*)’:
binutils-gdb/gdb/bt-utils.c:93:44: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uintptr_t {aka unsigned int}’ [-Werror=format=]
   snprintf (buf, sizeof (buf), "0x%lx ", pc);

Fix this by using phex and %s as opposed to 0x%lx.
---
 gdb/bt-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c
index 79e6e090d42..51791ccb9f6 100644
--- a/gdb/bt-utils.c
+++ b/gdb/bt-utils.c
@@ -90,7 +90,7 @@ libbacktrace_print (void *data, uintptr_t pc, const char *filename,
      files.  We are also careful to ensure we don't overflow this buffer.  */
   char buf[20];
 
-  snprintf (buf, sizeof (buf), "0x%lx ", pc);
+  snprintf (buf, sizeof (buf), "%s ", phex (pc, sizeof (pc));
   buf[sizeof (buf) - 1] = '\0';
   sig_write (buf);
   sig_write (function == nullptr ? "???" : function);
-- 
2.25.1


             reply	other threads:[~2021-10-01 11:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 11:50 Luis Machado via Gdb-patches [this message]
2021-10-01 15:25 ` Mike Frysinger via Gdb-patches
2021-10-01 15:53   ` Luis Machado via Gdb-patches
2021-10-01 16:08     ` Simon Marchi
2021-10-01 16:11       ` Simon Marchi
2021-10-01 16:32       ` Luis Machado via Gdb-patches

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=20211001115002.1681134-1-luis.machado@linaro.org \
    --to=gdb-patches@sourceware.org \
    --cc=luis.machado@linaro.org \
    /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