public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Dave Brolley <brolley@redhat.com>
To: Dave Brolley <brolley@redhat.com>
Cc: sid@sources.redhat.com
Subject: Re: Misaligned read/write of memory by GDB
Date: Mon, 28 Jun 2004 22:50:00 -0000	[thread overview]
Message-ID: <40E0A0B0.3020001@redhat.com> (raw)
In-Reply-To: <40E08B13.7000404@redhat.com>

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

Ooops, sent the wrong patch......

Dave Brolley wrote:

> Hi,
>
> Some sid components don't support misaligned reads/writes. The current 
> cache components are the example which caused my particular problem. 
> They punt on misaligned reads/writes, presumably so that they don't 
> have to worry about accesses which cross cache line boundaries. This 
> causes a problem when GDB attempts to read memory at unaligned addresses.
>
> This patch to gdb::process_get_mem and gdb::process_set_mem forces any 
> unaligned requests to use the existing byte-at-a-time method.
>
> I've committed this patch. Let me know if there are any problems.
>
> Dave
>

[-- Attachment #2: sid-gdb-align.patch.txt --]
[-- Type: text/plain, Size: 4924 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	28 Jun 2004 21:10:43 -0000
*************** 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());
--- 620,647 ----
      }
    host_int_4 addr = addr8; // truncate
  
!   if (addr % len == 0)
!     {
!       if (len==1 && e==endian_big) 
! 	{ read_bus_word (gdbserv, memory, addr, big_int_1()); return; }
!       if (len==1 && e==endian_little)
! 	{ read_bus_word (gdbserv, memory, addr, little_int_1()); return; }
!       if (len==2 && e==endian_big) 
! 	{ read_bus_word (gdbserv, memory, addr, big_int_2()); return; }
!       if (len==2 && e==endian_little)
! 	{ read_bus_word (gdbserv, memory, addr, little_int_2()); return; }
!       if (len==4 && e==endian_big) 
! 	{ read_bus_word (gdbserv, memory, addr, big_int_4()); return; }
!       if (len==4 && e==endian_little)
! 	{ read_bus_word (gdbserv, memory, addr, little_int_4()); return; }
!       if (len==8 && e==endian_big) 
! 	{ read_bus_word (gdbserv, memory, addr, big_int_8()); return; }
!       if (len==8 && e==endian_little)
! 	{ read_bus_word (gdbserv, memory, addr, little_int_8()); 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());
--- 705,732 ----
      }
    host_int_4 addr = addr8; // truncate
  
!   if (addr % len == 0)
!     {
!       if (len==1 && e==endian_big) 
! 	{ write_bus_word (gdbserv, binary, memory, addr, big_int_1()); return; }
!       if (len==1 && e==endian_little)
! 	{ write_bus_word (gdbserv, binary, memory, addr, little_int_1()); return; }
!       if (len==2 && e==endian_big) 
! 	{ write_bus_word (gdbserv, binary, memory, addr, big_int_2()); return; }
!       if (len==2 && e==endian_little)
! 	{ write_bus_word (gdbserv, binary, memory, addr, little_int_2()); return; }
!       if (len==4 && e==endian_big) 
! 	{ write_bus_word (gdbserv, binary, memory, addr, big_int_4()); return; }
!       if (len==4 && e==endian_little)
! 	{ write_bus_word (gdbserv, binary, memory, addr, little_int_4()); return; }
!       if (len==8 && e==endian_big) 
! 	{ write_bus_word (gdbserv, binary, memory, addr, big_int_8()); return; }
!       if (len==8 && e==endian_little)
! 	{ write_bus_word (gdbserv, binary, memory, addr, little_int_8()); 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-06-28 22:50 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 [this message]
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

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=40E0A0B0.3020001@redhat.com \
    --to=brolley@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).