public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: make avr_integer_to_address generate code or data address based on type
@ 2020-05-25 15:57 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2020-05-25 15:57 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1218a4bf49919878d41ad37cbe906f412d6fbdad

commit 1218a4bf49919878d41ad37cbe906f412d6fbdad
Author: Cristiano De Alti <cristiano_dealti@hotmail.com>
Date:   Mon May 25 11:55:56 2020 -0400

    gdb: make avr_integer_to_address generate code or data address based on type
    
    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 <main+0>: 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 <main>
        - (gdb) b *0x12a
        - Breakpoint 1 at 0x80012a
    
        + (gdb) p &main
        + $1 = (int (*)(void)) 0x12a <main>
        + (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.
    
    Change-Id: Iaea1587d053e86f4ab8aebdcabec8d31a6d262cd

Diff:
---
 gdb/ChangeLog  | 7 +++++++
 gdb/avr-tdep.c | 5 ++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a43ab08dd6c..2e21613640c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2020-05-25  Cristiano De Alti  <cristiano_dealti@hotmail.com>
+
+	PR gdb/13519
+	* avr-tdep.c (avr_integer_to_address): Return data or code
+	address accordingly to the second 'type' argument of the
+	function.
+
 2020-05-25  Michael Weghorn  <m.weghorn@posteo.de>
 
 	* infcmd.c, inferior.h: (construct_inferior_arguments):
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index fd602e35e50..74ab531711e 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-25 15:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 15:57 [binutils-gdb] gdb: make avr_integer_to_address generate code or data address based on type Simon Marchi

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).