|
From: Nicholas N. <nj...@cs...> - 2006-03-08 01:36:47
|
On Wed, 8 Mar 2006, Dave Airlie wrote:
> I wrote a trivial store interceptor copying from lackey, and I've set
> it up to intercept mmap (changed new_mem_mmap to see the offset) and
> if I like the offset I want to dump info in that area.
>
> This is fine and I can tell when the app writes to the address, and
> what address it is and how much, however I'm not really sure how I can
> actually extract the data the app is writing.
>
> Do I need to do something along the lines of memcheck with all the
> shadowing stuff in order to get what data is being written into the
> area in my handler function?
Nope. You have the address -- just dereference it!
> static VG_REGPARM(3) void trace_store(Addr addr, SizeT size)
> {
> if ((addr > mmt_gpu_reg.addr) && (addr < mmt_gpu_reg.addr+mmt_gpu_reg.len))
> VG_(printf)("store: %p, %d\n", addr-mmt_gpu_reg.addr, size);
> }
Here you need something like this (warning, untested code):
ULong data;
switch (size) {
case 1: data = *(UChar*)addr;
case 2: data = *(UShort*)addr;
case 4: data = *(UInt*)addr;
case 8: data = *(ULong*)addr;
default: /*barf*/
}
I think that'll work.
Nick
|