From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id C6F9D386F434 for ; Sun, 24 May 2020 14:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C6F9D386F434 X-ASG-Debug-ID: 1590330043-0c856e6d38fa060001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id haLVVWqP1Zu6Ue8d (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 24 May 2020 10:20:43 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from localhost.localdomain (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by smtp.ebox.ca (Postfix) with ESMTP id 11873441B21; Sun, 24 May 2020 10:20:43 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 173-246-6-90.qc.cable.ebox.net[173.246.6.90] X-Barracuda-Apparent-Source-IP: 173.246.6.90 X-Barracuda-RBL-IP: 173.246.6.90 To: gdb-patches@sourceware.org Cc: Cristiano De Alti Subject: [PATCH 2/2] gdb: make avr_integer_to_address generate code or data address based on type Date: Sun, 24 May 2020 10:20:40 -0400 X-ASG-Orig-Subj: [PATCH 2/2] gdb: make avr_integer_to_address generate code or data address based on type Message-Id: <20200524142040.209234-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524142040.209234-1-simon.marchi@polymtl.ca> References: <20200524142040.209234-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1590330043 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2588 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.82071 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2020 14:20:45 -0000 From: Cristiano De Alti I (Simon Marchi) am re-sending this patch written by Cristiano De Alti: https://sourceware.org/legacy-ml/gdb-patches/2016-03/msg00318.html The commit message is new but the code has not changed. The AVR architecture is a Harvard one, meaning it has different memory spaces for code and data. In GDB, this is dealt with by having the data (SRAM) addresses start at 0x00800000. When interpreting an integer as an address (converting to a CORE_ADDR), we currently always generate a data address. This doesn't work for some cases described below, where the integer is meant to represent a code address. This patch changes avr_integer_to_address so that it generates the correct type of address (code or data) based on the passed type. Using the simavr.exp board, I didn't see any regressions when running the gdb.base/*.exp tests. A few tests go from fail to pass, but none from pass to fail. There are a few new fails and unresolved, but it's just because some tests manage to make more progress before failing in a different way. In practice, it fixes disassembling by address, as described in the PR: - (gdb) disassemble 0x12a,0x12b - Dump of assembler code from 0x12a to 0x12b: - 0x0000012a : push r28 - End of assembler dump. + (gdb) disassemble 0x12a,0x12b + Dump of assembler code from 0x80012a to 0x80012b: + 0x0080012a: nop + End of assembler dump. And also, setting a breakpoint by address: - (gdb) p &main - $1 = (int (*)(void)) 0x12a
- (gdb) b *0x12a - Breakpoint 1 at 0x80012a + (gdb) p &main + $1 = (int (*)(void)) 0x12a
+ (gdb) b *0x12a + Breakpoint 1 at 0x12a: file test-avr.c, line 3. + Note: automatically using hardware breakpoints for read-only addresses. gdb/ChangeLog: PR gdb/13519 * avr-tdep.c (avr_integer_to_address): Return data or code address accordingly to the second 'type' argument of the function. --- gdb/avr-tdep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index fd602e35e50d..74ab531711e9 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -363,7 +363,10 @@ avr_integer_to_address (struct gdbarch *gdbarch, { ULONGEST addr = unpack_long (type, buf); - return avr_make_saddr (addr); + if (TYPE_DATA_SPACE (type)) + return avr_make_saddr (addr); + else + return avr_make_iaddr (addr); } static CORE_ADDR -- 2.26.2