From patchwork Sat Jun 8 19:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 33053 Received: (qmail 124365 invoked by alias); 8 Jun 2019 19:55:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 124315 invoked by uid 89); 8 Jun 2019 19:55:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=computing, core_addr, stream, CORE_ADDR X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Jun 2019 19:55:16 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57869C04BD48 for ; Sat, 8 Jun 2019 19:55:15 +0000 (UTC) Received: from f30-1.lan (ovpn-116-84.phx2.redhat.com [10.3.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F68B608AB; Sat, 8 Jun 2019 19:55:15 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Kevin Buettner Subject: [PATCH 3/4] Allow display of negative offsets in print_address_symbolic() Date: Sat, 8 Jun 2019 12:54:33 -0700 Message-Id: <20190608195434.26512-4-kevinb@redhat.com> In-Reply-To: <20190608195434.26512-1-kevinb@redhat.com> References: <20190608195434.26512-1-kevinb@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 : push %rbp This commit causes cases like the above to be displayed like this (below) instead: (gdb) x/i foo_cold 0x40110d : 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;