public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: "Dave Brolley" <brolley@redhat.com>
To: "'Dave Brolley'" <brolley@redhat.com>,
	"'Frank Ch. Eigler'" <fche@redhat.com>
Cc: <sid@sources.redhat.com>
Subject: RE: Misaligned read/write of memory by GDB
Date: Thu, 01 Jul 2004 17:02:00 -0000	[thread overview]
Message-ID: <200407011702.i61H2NP28370@potter.sfbay.redhat.com> (raw)
In-Reply-To: <40E1D329.1060705@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

In response to Frank's comments, I have removed my previous patch and
committed this one in its place.

The cache component now handles misaligned accesses except those which cross
a cache line boundary. For those it returns bus::misaligned

The GDB component reverts to the byte-at-a-time method of access if
bus::misaligned is returned from downstream.

Dave


[-- Attachment #2: sid-gdbalign.ChangeLog --]
[-- Type: application/octet-stream, Size: 659 bytes --]

2004-07-01  Dave Brolley  <brolley@redhat.com>

	* gdb.cxx (read_bus_word): Now returns bus::status. Return status
	from bus->read.
	(write_bus_word): Ditto for status from bus->write.
	(process_get_mem): Back out previous patch. Retry access
	one byte at a time if bus::misaligned is returned from downstream.
	(process_set_mem): Ditto.

2004-07-01  Dave Brolley  <brolley@redhat.com>

	* cache.cxx (write_any): Allow misaligned access. Return
	bus::misaligned for accesses which cross line boundary.
	(read_any): Ditto.

2004-07-01  Dave Brolley  <brolley@redhat.com>

	* sidcomp.cache/misaligned.exp: 16 bit access should now be a hit.


[-- Attachment #3: sid-gdbalign.patch.txt --]
[-- Type: text/plain, Size: 6797 bytes --]

Index: sid/component/gdb/gdb.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/gdb/gdb.cxx,v
retrieving revision 1.11
diff -c -p -r1.11 gdb.cxx
*** sid/component/gdb/gdb.cxx	22 Mar 2004 21:27:23 -0000	1.11
--- sid/component/gdb/gdb.cxx	1 Jul 2004 16:46:54 -0000
*************** gdb::process_get_exp_regs ()
*** 532,538 ****
  // Helper functions
  
  template <class Type>
! void 
  read_bus_word(gdbserv* gdbserv, 
  	      sid::bus* bus,
  	      host_int_4 address,
--- 532,538 ----
  // Helper functions
  
  template <class Type>
! bus::status
  read_bus_word(gdbserv* gdbserv, 
  	      sid::bus* bus,
  	      host_int_4 address,
*************** read_bus_word(gdbserv* gdbserv, 
*** 545,557 ****
        for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
  	gdbserv_output_byte (gdbserv, value.read_byte(i));
      }
!   else
      gdbserv_output_string (gdbserv, "E05");
  }
  
  
  template <class Type>
! void 
  write_bus_word(gdbserv* gdbserv, 
  	       int binary,
  	       sid::bus* bus,
--- 545,559 ----
        for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
  	gdbserv_output_byte (gdbserv, value.read_byte(i));
      }
!   // misaligned will be handled by the caller
!   else if (s != bus::misaligned)
      gdbserv_output_string (gdbserv, "E05");
+   return s;
  }
  
  
  template <class Type>
! bus::status
  write_bus_word(gdbserv* gdbserv, 
  	       int binary,
  	       sid::bus* bus,
*************** write_bus_word(gdbserv* gdbserv, 
*** 572,581 ****
      }
  
    bus::status s = bus->write (address, value);
!   if (s == bus::ok)
!     ; // No response means "OK"
    else
      gdbserv_output_string (gdbserv, "E05");
  }
  
  
--- 574,584 ----
      }
  
    bus::status s = bus->write (address, value);
!   if (s == bus::ok || s == bus::misaligned)
!     ; // No response means "OK" -- misaligned will be handled by the caller
    else
      gdbserv_output_string (gdbserv, "E05");
+   return s;
  }
  
  
*************** gdb::process_get_mem (struct gdbserv_reg
*** 620,642 ****
      }
    host_int_4 addr = addr8; // truncate
  
    if (len==1 && e==endian_big) 
!     read_bus_word (gdbserv, memory, addr, big_int_1());
    else if (len==1 && e==endian_little)
!     read_bus_word (gdbserv, memory, addr, little_int_1());
    else if (len==2 && e==endian_big) 
!     read_bus_word (gdbserv, memory, addr, big_int_2());
    else if (len==2 && e==endian_little)
!     read_bus_word (gdbserv, memory, addr, little_int_2());
    else if (len==4 && e==endian_big) 
!     read_bus_word (gdbserv, memory, addr, big_int_4());
    else if (len==4 && e==endian_little)
!     read_bus_word (gdbserv, memory, addr, little_int_4());
    else if (len==8 && e==endian_big) 
!     read_bus_word (gdbserv, memory, addr, big_int_8());
    else if (len==8 && e==endian_little)
!     read_bus_word (gdbserv, memory, addr, little_int_8());
!   else if (e==endian_little)
      {
        for (unsigned long i=0; i<len; i++)
  	read_bus_word (gdbserv, memory, addr + i, little_int_1());
--- 623,651 ----
      }
    host_int_4 addr = addr8; // truncate
  
+   bus::status b = bus::misaligned;
    if (len==1 && e==endian_big) 
!     b = read_bus_word (gdbserv, memory, addr, big_int_1());
    else if (len==1 && e==endian_little)
!     b = read_bus_word (gdbserv, memory, addr, little_int_1());
    else if (len==2 && e==endian_big) 
!     b = read_bus_word (gdbserv, memory, addr, big_int_2());
    else if (len==2 && e==endian_little)
!     b = read_bus_word (gdbserv, memory, addr, little_int_2());
    else if (len==4 && e==endian_big) 
!     b = read_bus_word (gdbserv, memory, addr, big_int_4());
    else if (len==4 && e==endian_little)
!     b = read_bus_word (gdbserv, memory, addr, little_int_4());
    else if (len==8 && e==endian_big) 
!     b = read_bus_word (gdbserv, memory, addr, big_int_8());
    else if (len==8 && e==endian_little)
!     b = read_bus_word (gdbserv, memory, addr, little_int_8());
! 
!   if (b != bus::misaligned)
!     return;
!   
!   // Unaligned access or unsupported size.
!   if (e==endian_little)
      {
        for (unsigned long i=0; i<len; i++)
  	read_bus_word (gdbserv, memory, addr + i, little_int_1());
*************** gdb::process_set_mem (struct gdbserv_reg
*** 700,722 ****
      }
    host_int_4 addr = addr8; // truncate
  
    if (len==1 && e==endian_big) 
!     write_bus_word (gdbserv, binary, memory, addr, big_int_1());
!   else if (len==1 && e==endian_little)
!     write_bus_word (gdbserv, binary, memory, addr, little_int_1());
!   else if (len==2 && e==endian_big) 
!     write_bus_word (gdbserv, binary, memory, addr, big_int_2());
!   else if (len==2 && e==endian_little)
!     write_bus_word (gdbserv, binary, memory, addr, little_int_2());
!   else if (len==4 && e==endian_big) 
!     write_bus_word (gdbserv, binary, memory, addr, big_int_4());
!   else if (len==4 && e==endian_little)
!     write_bus_word (gdbserv, binary, memory, addr, little_int_4());
!   else if (len==8 && e==endian_big) 
!     write_bus_word (gdbserv, binary, memory, addr, big_int_8());
!   else if (len==8 && e==endian_little)
!     write_bus_word (gdbserv, binary, memory, addr, little_int_8());
!   else if (e==endian_little)
      {
        for (unsigned long i=0; i<len; i++)
  	write_bus_word (gdbserv, binary, memory, addr + i, little_int_1());
--- 709,737 ----
      }
    host_int_4 addr = addr8; // truncate
  
+   bus::status b = bus::misaligned;
    if (len==1 && e==endian_big) 
!     b = write_bus_word (gdbserv, binary, memory, addr, big_int_1());
!   if (len==1 && e==endian_little)
!     b = write_bus_word (gdbserv, binary, memory, addr, little_int_1());
!   if (len==2 && e==endian_big) 
!     b = write_bus_word (gdbserv, binary, memory, addr, big_int_2());
!   if (len==2 && e==endian_little)
!     b = write_bus_word (gdbserv, binary, memory, addr, little_int_2());
!   if (len==4 && e==endian_big) 
!     b = write_bus_word (gdbserv, binary, memory, addr, big_int_4());
!   if (len==4 && e==endian_little)
!     b = write_bus_word (gdbserv, binary, memory, addr, little_int_4());
!   if (len==8 && e==endian_big) 
!     b = write_bus_word (gdbserv, binary, memory, addr, big_int_8());
!   if (len==8 && e==endian_little)
!     b = write_bus_word (gdbserv, binary, memory, addr, little_int_8());
! 
!   if (b != bus::misaligned)
!     return;
! 
!   // Unaligned access or unsupported size.
!   if (e==endian_little)
      {
        for (unsigned long i=0; i<len; i++)
  	write_bus_word (gdbserv, binary, memory, addr + i, little_int_1());

      reply	other threads:[~2004-07-01 17:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-28 21:18 Dave Brolley
2004-06-28 22:50 ` Dave Brolley
2004-06-29 18:27   ` Frank Ch. Eigler
2004-06-29 19:14     ` Dave Brolley
2004-06-29 19:18       ` Frank Ch. Eigler
2004-06-29 20:40         ` Dave Brolley
2004-07-01 17:02           ` Dave Brolley [this message]

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=200407011702.i61H2NP28370@potter.sfbay.redhat.com \
    --to=brolley@redhat.com \
    --cc=fche@redhat.com \
    --cc=sid@sources.redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).