* Misaligned read/write of memory by GDB @ 2004-06-28 21:18 Dave Brolley 2004-06-28 22:50 ` Dave Brolley 0 siblings, 1 reply; 7+ messages in thread From: Dave Brolley @ 2004-06-28 21:18 UTC (permalink / raw) To: sid [-- Attachment #1: Type: text/plain, Size: 568 bytes --] 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.ChangeLog --] [-- Type: text/plain, Size: 157 bytes --] 2004-06-28 Dave Brolley <brolley@redhat.com> * gdb.cxx (process_get_mem): Use byte-at-a-time access for unaligned requests. (process_set_mem): Ditto. [-- Attachment #3: sid-gdb.patch.txt --] [-- Type: text/plain, Size: 6825 bytes --] Index: sid/component/consoles/socketio.cxx =================================================================== RCS file: /cvs/src/src/sid/component/consoles/socketio.cxx,v retrieving revision 1.5 diff -c -p -r1.5 socketio.cxx *** sid/component/consoles/socketio.cxx 4 Mar 2002 20:38:56 -0000 1.5 --- sid/component/consoles/socketio.cxx 22 Mar 2004 18:48:32 -0000 *************** *** 1,7 **** // socketio.cxx - A console that uses a socket to do its I/O. // -*- C++ -*- ! // Copyright (C) 1999, 2000, 2002 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,7 ---- // socketio.cxx - A console that uses a socket to do its I/O. // -*- C++ -*- ! // Copyright (C) 1999-2002, 2004 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** void *** 297,302 **** --- 297,306 ---- socketio::fini_handler (host_int_4) { this->poll_control.cancel (); + + // Flush out any remaining data + if (this->connected_p) + this->poll_transmit (); if (this->connected_p) { Index: sid/component/gdb/gdb.cxx =================================================================== RCS file: /cvs/src/src/sid/component/gdb/gdb.cxx,v retrieving revision 1.10 diff -c -p -r1.10 gdb.cxx *** sid/component/gdb/gdb.cxx 8 May 2002 19:15:30 -0000 1.10 --- sid/component/gdb/gdb.cxx 22 Mar 2004 18:48:32 -0000 *************** *** 1,6 **** // gdb.cxx - GDB stub implementation. -*- C++ -*- ! // Copyright (C) 1999-2002 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,6 ---- // gdb.cxx - GDB stub implementation. -*- C++ -*- ! // Copyright (C) 1999-2002, 2004 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** gdb::deinit_handler (host_int_4) *** 1550,1556 **** { // disconnect if needed if (this->connected_p) ! this->remote_rx_eof_handler (); } --- 1550,1562 ---- { // disconnect if needed if (this->connected_p) ! { ! // shut down target ! target_power (false); ! // signal gdb ! gdbserv_fromtarget_exit (gdbserv, 0); ! this->remote_rx_eof_handler (); ! } } Index: sid/main/dynamic/commonCfg.cxx =================================================================== RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v retrieving revision 1.6 diff -c -p -r1.6 commonCfg.cxx *** sid/main/dynamic/commonCfg.cxx 27 Oct 2003 18:55:34 -0000 1.6 --- sid/main/dynamic/commonCfg.cxx 22 Mar 2004 18:48:34 -0000 *************** SessionCfg::SessionCfg (const string nam *** 530,536 **** tcl_bridge (NULL), loader (NULL), verbose (false), ! use_stdio (true) { add_child (host_sched); add_child (sim_sched); --- 530,538 ---- tcl_bridge (NULL), loader (NULL), verbose (false), ! use_stdio (true), ! board_count (0), ! gdb_count (0) { add_child (host_sched); add_child (sim_sched); *************** void SessionCfg::use_tcl_bridge () *** 657,662 **** --- 659,684 ---- init_seq->add_output (7, tcl_bridge, "!event"); } + void SessionCfg::write_config (Writer &w) + { + AggregateCfg::write_config (w); + + // Stop the host scheduler if all of the GDB stubs are stopped + if (gdb_count) + { + assert (host_sched); + Setting (host_sched, "yield-host-time-threshold", + sidutil::make_attribute (gdb_count)).write_to (w); + Setting (host_sched, "yield-host-time?", "0").write_to (w); + } + + // Stop the sim scheduler if any of the GDB stubs are stopped + assert (sim_sched); + Setting (sim_sched, "enable-threshold", + sidutil::make_attribute (board_count)).write_to (w); + Setting (sim_sched, "enabled?", + sidutil::make_attribute (board_count)).write_to (w); + } // LoaderCfg LoaderCfg::~LoaderCfg () {} *************** void BoardCfg::set_gdb (const string por *** 920,925 **** --- 942,948 ---- gdb = new GdbCfg ("gdb", port, cpu, this, sess); add_child (gdb); sess->use_no_stdio (); + sess->add_gdb (); } Index: sid/main/dynamic/commonCfg.h =================================================================== RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.h,v retrieving revision 1.3 diff -c -p -r1.3 commonCfg.h *** sid/main/dynamic/commonCfg.h 21 Oct 2003 21:39:04 -0000 1.3 --- sid/main/dynamic/commonCfg.h 22 Mar 2004 18:48:34 -0000 *************** struct UlogCfg *** 182,187 **** --- 182,188 ---- // you should really only make one of these, with an empty name, // unless you want some crazy multi-session support. + class BoardCfg; class LoaderCfg; struct SessionCfg : *************** struct SessionCfg : *** 214,219 **** --- 215,226 ---- bool use_stdio; void add_ulog_file (const string filename); map<const string, AtomicCfg *> ulog_map; + void add_gdb () { ++gdb_count; } + void add_board (ComponentCfg *b) { ++board_count; add_child (b); } + virtual void write_config (Writer &w); + private: + sid::host_int_4 board_count; + sid::host_int_4 gdb_count; }; class CpuCfg : *************** public: *** 277,283 **** virtual ~GprofCfg (); }; - class BoardCfg; class GdbCfg : virtual public AggregateCfg { --- 284,289 ---- Index: sid/main/dynamic/mainDynamic.cxx =================================================================== RCS file: /cvs/src/src/sid/main/dynamic/mainDynamic.cxx,v retrieving revision 1.5 diff -c -p -r1.5 mainDynamic.cxx *** sid/main/dynamic/mainDynamic.cxx 21 Oct 2003 21:39:04 -0000 1.5 --- sid/main/dynamic/mainDynamic.cxx 22 Mar 2004 18:48:34 -0000 *************** main(int argc, char* argv[]) *** 617,623 **** { need_sess (sess); if (curr_board) ! sess->add_child (curr_board); curr_board = NULL; string new_board_type = optstring(); string new_board_name (new_board_type + "-" + --- 617,623 ---- { need_sess (sess); if (curr_board) ! sess->add_board (curr_board); curr_board = NULL; string new_board_type = optstring(); string new_board_name (new_board_type + "-" + *************** main(int argc, char* argv[]) *** 878,884 **** } if (sess && curr_board) ! sess->add_child (curr_board); if (persistent_p) config_items.push_back (make_pair (false, string("set main persistent? true"))); --- 878,884 ---- } if (sess && curr_board) ! sess->add_board (curr_board); if (persistent_p) config_items.push_back (make_pair (false, string("set main persistent? true"))); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Misaligned read/write of memory by GDB 2004-06-28 21:18 Misaligned read/write of memory by GDB Dave Brolley @ 2004-06-28 22:50 ` Dave Brolley 2004-06-29 18:27 ` Frank Ch. Eigler 0 siblings, 1 reply; 7+ messages in thread From: Dave Brolley @ 2004-06-28 22:50 UTC (permalink / raw) To: Dave Brolley; +Cc: sid [-- 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()); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Misaligned read/write of memory by GDB 2004-06-28 22:50 ` Dave Brolley @ 2004-06-29 18:27 ` Frank Ch. Eigler 2004-06-29 19:14 ` Dave Brolley 0 siblings, 1 reply; 7+ messages in thread From: Frank Ch. Eigler @ 2004-06-29 18:27 UTC (permalink / raw) To: Dave Brolley; +Cc: sid OK, but did you consider an alternate of having a memory target that is unable to handle an unaligned access return sid::bus::misaligned, and then have gdb back down to byte-by-byte access? - FChE ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Misaligned read/write of memory by GDB 2004-06-29 18:27 ` Frank Ch. Eigler @ 2004-06-29 19:14 ` Dave Brolley 2004-06-29 19:18 ` Frank Ch. Eigler 0 siblings, 1 reply; 7+ messages in thread From: Dave Brolley @ 2004-06-29 19:14 UTC (permalink / raw) To: Frank Ch. Eigler; +Cc: sid Frank Ch. Eigler wrote: >OK, but did you consider an alternate of having a memory target that >is unable to handle an unaligned access return sid::bus::misaligned, >and then have gdb back down to byte-by-byte access? > > I thought about the possibility of fixing existing memory targets to handle misaligned access, either by implementing support, returning sid::bus::misaligned, or whatever else might be appropriate. However it occurred to me that this would require implementors of all future memory targets to be aware of potential GDB access of this type. This just seemed like something that will always work regardless of the implementation of the downstream memory. Dave ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Misaligned read/write of memory by GDB 2004-06-29 19:14 ` Dave Brolley @ 2004-06-29 19:18 ` Frank Ch. Eigler 2004-06-29 20:40 ` Dave Brolley 0 siblings, 1 reply; 7+ messages in thread From: Frank Ch. Eigler @ 2004-06-29 19:18 UTC (permalink / raw) To: Dave Brolley; +Cc: sid [-- Attachment #1: Type: text/plain, Size: 774 bytes --] Hi - > >OK, but did you consider an alternate of having a memory target that > >is unable to handle an unaligned access return sid::bus::misaligned, > >and then have gdb back down to byte-by-byte access? > > > I thought about the possibility of fixing existing memory targets to > handle misaligned access, either by implementing support, returning > sid::bus::misaligned, or whatever else might be appropriate. How many offenders (that did neither) did you encounter? > However it occurred to me that this would require implementors of all > future memory targets to be aware of potential GDB access of this > type. [...] True, except that such accesses could originate elsewhere - a simulated CPU, or a gloss component, for example. - FChE [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Misaligned read/write of memory by GDB 2004-06-29 19:18 ` Frank Ch. Eigler @ 2004-06-29 20:40 ` Dave Brolley 2004-07-01 17:02 ` Dave Brolley 0 siblings, 1 reply; 7+ messages in thread From: Dave Brolley @ 2004-06-29 20:40 UTC (permalink / raw) To: Frank Ch. Eigler; +Cc: sid Frank Ch. Eigler wrote: >>I thought about the possibility of fixing existing memory targets to >>handle misaligned access, either by implementing support, returning >>sid::bus::misaligned, or whatever else might be appropriate. >> >> > >How many offenders (that did neither) did you encounter? > Just one. The cache component. It silently reads directly from the backing memory, thus (potentially) returning the wrong value. >>However it occurred to me that this would require implementors of all >>future memory targets to be aware of potential GDB access of this >>type. [...] >> >> > >True, except that such accesses could originate elsewhere - a simulated >CPU, or a gloss component, for example. > > I guess one could argue that all complete component implementations should handle all possible input possibilities. The failure was not obvious in my case because of the silent misbehavior of the cache component. I guess I was just wanting to prevent a similar misfortune from happening to someone else (or me again!) in the future. Your gloss example convinces me that the cache component should be fixed, however. Once done, I can implement the GDB access in the way you've suggested. Dave ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Misaligned read/write of memory by GDB 2004-06-29 20:40 ` Dave Brolley @ 2004-07-01 17:02 ` Dave Brolley 0 siblings, 0 replies; 7+ messages in thread From: Dave Brolley @ 2004-07-01 17:02 UTC (permalink / raw) To: 'Dave Brolley', 'Frank Ch. Eigler'; +Cc: sid [-- 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()); ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-07-01 17:02 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-06-28 21:18 Misaligned read/write of memory by GDB 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 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).