|
From: Dirk M. <dm...@gm...> - 2005-11-02 19:42:11
|
Hi, is there already tool for valgrind that can detect unaligned accesses? Dirk |
|
From: Nicholas N. <nj...@cs...> - 2005-11-02 20:23:35
|
On Wed, 2 Nov 2005, Dirk Mueller wrote: > is there already tool for valgrind that can detect unaligned accesses? I don't know of one. It would be very easy to write, though. Lackey (the version in Subversion, not that in 3.0.1) would be a good place to start. Nick |
|
From: Julian S. <js...@ac...> - 2005-11-02 22:32:26
|
On Wednesday 02 November 2005 20:23, Nicholas Nethercote wrote:
> On Wed, 2 Nov 2005, Dirk Mueller wrote:
> > is there already tool for valgrind that can detect unaligned accesses?
>
> I don't know of one. It would be very easy to write, though. Lackey (the
> version in Subversion, not that in 3.0.1) would be a good place to start.
Hi Dirk
Presumably the %eflags.ac=1 trick doesn't work for you?
Anyway, I agree, a lackey derivative would be a possibility,
but the 5-minute solution is to look at mc_{STOREVn,LOADVn}_slow
in mc_main.c, which is where all misaligned accesses will end
up.
So if you add something like
if ((a % szB) != 0)
MAC_(record_address_error)( VG_(get_running_tid)(), a, szB, False );
then you might get what you want.
It doesn't matter that the % is slow since these functions are the
slow, general-case handlers which very rarely get used.
J
|
> is there already tool for valgrind that can detect unaligned accesses? On i586 hardware and later, setting bit 18 (Alignment Check) in the processor flags will do this at full hardware speed. It traps on non- aligned access from ring 3 (user mode), and linux gives you SIGBUS. In assembly language: pushf movl $(1<<18),%eax orl %eax,(%esp) popf or, because you probably want to catch the SIGBUS in a debugger anyway: (gdb) set $ps |= (1<<18) Continuing through the SIGBUS is somewhat awkward: (gdb) set $ps &= ~(1<<18) # clear AC bit (gdb) x/2i $pc # see where you are (gdb) tbreak *$_ # temporary breakpoint beyond trapping instruction (gdb) signal 0 # continue with no signal to temp breakpoint; delete bkpt (gdb) set $ps |= (1<<18) # re-enable Alignment Check Beware that some parts of glibc used to make unaligned accesses, and they might not all be eradicated yet. -- |
|
From: Dennis L. <pla...@tz...> - 2005-11-02 21:54:11
|
Am Mittwoch, den 02.11.2005, 12:54 -0800 schrieb John Reiser: > > is there already tool for valgrind that can detect unaligned accesses? > > Beware that some parts of glibc used to make unaligned accesses, > and they might not all be eradicated yet. Here the valgrind suppression mechanism would be very handy, so a tool would be nice. |