Reputation: 1929
I need to trace all pwrite(2) calls done to some specific file and print all buffers that are to be written byte by byte. The data expected is not in ASCII string format so i can't use:
printf("%s\n", copyinstr(arg1))
I learned about copyin(arg1, arg2), but that gives me a void* and all examples i've found covert it to string again by calling stringof, e.g.:
printf("%s\n", stringof(copyin(arg1, arg2)))
What i need is to somehow display all bytes in copyin'ed buffer. Any suggestions?
Thank you, Inso.
Upvotes: 2
Views: 1628
Reputation: 11
tracemem(address, size_t nbytes, size_t dbytes)
, where nbytes is a constant and dbytes can be dynamic and less than nbytes.
tracemem
void tracemem(address, size_t nbytes)
void tracemem(address, size_t nbytes, size_t dbytes)
The tracemem action takes a D expression as its first argument, address, and a constant as its second argument, nbytes. tracemem copies the memory from the address specified by addr into the directed buffer for the length specified by nbytes.
If the third argument, dbytes is supplied, only up to dbytes will be copied. dbytes is allowed to be a variable amount, but it must be less than or equal to nbytes. This is useful when you are looking at something that has a known upper bound, but the actual number of bytes may vary. For example, consider the case where you are dumping an Ethernet packet. The maximum size is based on the MTU, but the amount of data in the given packet is variable.
Upvotes: 1