From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14303 invoked by alias); 11 Aug 2004 21:07:02 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 14229 invoked from network); 11 Aug 2004 21:07:00 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 11 Aug 2004 21:07:00 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i7BL6xe1001809 for ; Wed, 11 Aug 2004 17:06:59 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i7BL6rX09605 for ; Wed, 11 Aug 2004 17:06:59 -0400 Received: from redhat.com (IDENT:MLDmsatds5YluCRD3azxQ5UpoXRye+IK@vpn50-73.rdu.redhat.com [172.16.50.73]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i7BL6pV26681 for ; Wed, 11 Aug 2004 14:06:52 -0700 Message-ID: <411A89D3.4090909@redhat.com> Date: Wed, 11 Aug 2004 21:07:00 -0000 From: Dave Brolley User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021216 MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch] Unaligned reads/writes to/from GDB: Refinement Content-Type: multipart/mixed; boundary="------------040906050209010900070709" X-SW-Source: 2004-q3/txt/msg00017.txt.bz2 This is a multi-part message in MIME format. --------------040906050209010900070709 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 414 I've committed this patch which is a correction for my previous work on non-aligned memory reads/writes from GDB. It's too late to handle bus::unaligned by retrying one byte at a time in process_set_mem because by then the input data is no longer in the input stream. I've moved the retry to write_bus_word. For consistency, I've also moved the retry for reading from process_get_mem to read_bus_word. Dave --------------040906050209010900070709 Content-Type: text/plain; name="sid-gdb-align2.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-gdb-align2.ChangeLog" Content-length: 240 2004-08-11 Dave Brolley * gdb.cxx (read_bus_word): Handle bus::misaligned. Return type now 'void' again. (write_bus_word): Ditto. (process_get_mem): Don't handle bus::misaligned here. (process_set_mem): Ditto. --------------040906050209010900070709 Content-Type: text/plain; name="sid-gdb-align2.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-gdb-align2.patch.txt" Content-length: 7319 Index: sid/component/gdb/gdb.cxx =================================================================== RCS file: /cvs/src/src/sid/component/gdb/gdb.cxx,v retrieving revision 1.13 diff -c -p -r1.13 gdb.cxx *** sid/component/gdb/gdb.cxx 1 Jul 2004 16:54:47 -0000 1.13 --- sid/component/gdb/gdb.cxx 11 Aug 2004 20:53:30 -0000 *************** gdb::process_get_exp_regs () *** 532,538 **** // Helper functions template ! bus::status read_bus_word(gdbserv* gdbserv, sid::bus* bus, host_int_4 address, --- 532,538 ---- // Helper functions template ! void read_bus_word(gdbserv* gdbserv, sid::bus* bus, host_int_4 address, *************** read_bus_word(gdbserv* gdbserv, *** 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 ! bus::status write_bus_word(gdbserv* gdbserv, int binary, sid::bus* bus, --- 545,570 ---- for (unsigned i=0; i < sizeof(typename Type::value_type); i++) gdbserv_output_byte (gdbserv, value.read_byte(i)); } ! else if (s == bus::misaligned) ! { ! // Try it one byte at a time ! for (unsigned i=0; i < sizeof(typename Type::value_type); i++) ! { ! big_int_1 b; // endianness of a single byte is irrelevent ! s = bus->read (address + i, b); ! if (s == bus::ok) ! gdbserv_output_byte (gdbserv, b); ! else ! gdbserv_output_string (gdbserv, "E05"); ! } ! } ! else gdbserv_output_string (gdbserv, "E05"); } template ! void write_bus_word(gdbserv* gdbserv, int binary, sid::bus* bus, *************** write_bus_word(gdbserv* gdbserv, *** 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; } --- 585,604 ---- } bus::status s = bus->write (address, value); ! if (s == bus::misaligned) ! { ! // Try it a byte at a time ! for (unsigned i=0; i < sizeof(typename Type::value_type); i++) ! { ! // endianness of a single byte is irrelevent ! big_int_1 b = value.read_byte (i); ! s = bus->write (address + i, b); ! if (s != bus::ok) ! gdbserv_output_string (gdbserv, "E05"); ! } ! } ! else if (s != bus::ok) gdbserv_output_string (gdbserv, "E05"); } *************** gdb::process_get_mem (struct gdbserv_reg *** 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