From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,198bbd75fa94559b X-Google-Attributes: gid111c93,public From: Xiaozhou Qiu Subject: Re: fixing unaligned memory access on linux/alpha Date: 1999/08/25 Message-ID: <37C4ABC1.A457FB82@mars.iol.unh.edu>#1/1 X-Deja-AN: 517241034 Content-Transfer-Encoding: 7bit References: <37C36297.C2473305@eng.monash.edu.au> X-Accept-Language: en Content-Type: text/plain; charset=gb2312 X-Complaints-To: abuse@mv.com X-Trace: pyrite.mv.net 935626799 22512 207.22.43.192 (26 Aug 1999 00:19:59 GMT) Organization: MV Communications, Inc. Mime-Version: 1.0 NNTP-Posting-Date: 26 Aug 1999 00:19:59 GMT Newsgroups: comp.os.linux.alpha Hi, there is a small program written by Sean recently which solve your problem. You can find the code in the following: ftp://mars.iol.unh.edu/pub/linux/applications/unalign.c I also attach Sean's explantion about useful tool. Xiaozhou Qiu Linux Consortium UNH Sean's mail: Here is the wrapper program I wrote to assist with the debugging of unaligned traps. Its the bastard child of something similar Richard Henderson posted here, and the execcap program that Andrew Morgan wrote for the libcap package, with a few bits of mine thrown in. Thanks to Michal Jaegermann for the pointers. Basically, it runs the program given on the commandline in gdb with the given arguments, but sets the flags so that the program will recieve a SIGBUS on encountering an unaligned trap. What you do is compile the code below thussly... gcc unaligned.c -o unaligned ...then you run your naughty program. Say I want to debug the horrid "ping" program that came with redhat 6 (yes I know there's an update, this is just an example). What you do is get the source, build it (without stripping the debugging symbols), change to the directory so that gdb can find the relevant source files (in this case the directory is called "ping"), and go unaligned ping harold ... the "harold" is because I'm testing it by pinging one of the hosts on my network here. You'd substitute a suitable alternative. You'll see the following.... Extra arguments passed to gdb in file /tmp/file6krPqZ. Be sure to delete it when you're done. GNU gdb 4.17.0.11 with Linux support Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "alpha-redhat-linux". PING harold.uncarved.co.uk (10.0.1.1): 56 data bytes Program received signal SIGBUS, Bus error. 0x12000359c in tvsub (out=0x11ffffa30, in=0x1201187fc) at ping.c:885 885 if ((out->tv_usec -= in->tv_usec) < 0) { (gdb) In otherwords, gdb has run the program and helpfully stopped at the offending line. Now, you just have to figure out how to fix the error... Sean Andrew Brydon wrote: > Hi, > I am porting my code to Linux/alpha, and am receiving unaligned traps in the > system logs. Clearly fixing this would be nice. > > My question is, is there an equivalent to the 'uac' command on Tru64 that will > turn the warning into an SIGBUS, leaving me to find the problem in gdb. Pointers > in the direction of appropriate system calls would be fine too. > > TIA > Andrew > > -- > | Andrew Brydon | phone: +61 3 9905 4429 | > | Dept. Maths & Stats | fax: +61 3 9905 3867 | > | Monash University | mailto:Andrew.Brydon@eng.monash.edu.au | > | Clayton Australia 3168 | http://www-personal.monash.edu.au/~brydon |