Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH 3/4] Allow display of negative offsets in print_address_symbolic()
Date: Sat, 08 Jun 2019 19:55:00 -0000	[thread overview]
Message-ID: <20190608195434.26512-4-kevinb@redhat.com> (raw)
In-Reply-To: <20190608195434.26512-1-kevinb@redhat.com>

When examining addresses associated with blocks with non-contiguous
address ranges, it's not uncommon to see large positive offsets which,
for some address width, actually represent a smaller negative offset.
Here's an example taken from the test case:

    (gdb) x/i foo_cold
       0x40110d <foo+4294967277>:	push   %rbp

This commit causes cases like the above to be displayed like this (below)
instead:

    (gdb) x/i foo_cold
       0x40110d <foo-19>:	push   %rbp

gdb/ChangeLog:

	* printcmd.c (print_address_symbolic): Print negative offsets.
	(build_address_symbolic): Force signed arithmetic when computing
	offset.
---
 gdb/printcmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index e00a9c671a..8ceddd633a 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -537,7 +537,7 @@ print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
     fputs_filtered ("<", stream);
   fputs_styled (name.c_str (), function_name_style.style (), stream);
   if (offset != 0)
-    fprintf_filtered (stream, "+%u", (unsigned int) offset);
+    fprintf_filtered (stream, "%+d", offset);
 
   /* Append source filename and line number if desired.  Give specific
      line # of this addr, if we have it; else line # of the nearest symbol.  */
@@ -666,7 +666,7 @@ build_address_symbolic (struct gdbarch *gdbarch,
       && name_location + max_symbolic_offset > name_location)
     return 1;
 
-  *offset = addr - name_location;
+  *offset = (LONGEST) addr - name_location;
 
   *name = name_temp;
 
-- 
2.21.0


  reply	other threads:[~2019-06-08 19:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-08 19:55 [PATCH 0/4] Non-contiguous address range bug fixes / improvements Kevin Buettner
2019-06-08 19:55 ` Kevin Buettner [this message]
2019-06-21 14:45   ` [PATCH 3/4] Allow display of negative offsets in print_address_symbolic() Pedro Alves
2019-07-03 23:09     ` Kevin Buettner
2019-07-04  1:06       ` Kevin Buettner
2019-06-08 19:55 ` [PATCH 2/4] dwarf2-frame.c: Fix FDE processing bug involving non-contiguous ranges Kevin Buettner
2019-06-21 14:34   ` Pedro Alves
2019-06-08 19:55 ` [PATCH 1/4] Prefer symtab symbol over minsym for function names in non-contiguous blocks Kevin Buettner
2019-06-21 14:26   ` Pedro Alves
2019-06-26 17:30     ` Tom Tromey
2019-07-03 23:16       ` Kevin Buettner
2019-06-08 19:55 ` [PATCH 4/4] Improve test gdb.dwarf2/dw2-ranges-func.exp Kevin Buettner
2019-06-26 17:24 ` [PATCH 0/4] Non-contiguous address range bug fixes / improvements Tom Tromey
2019-07-03 20:10   ` Kevin Buettner

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=20190608195434.26512-4-kevinb@redhat.com \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sourceware.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