....
finalize(char *hdrs, sendip_data *headers[], int index,
sendip_data *data, sendip_data *pack)
{
........
For debugging purposes I want a hex dump of the data
and pack
structures, which are of type sendip_data
, a really complex structure. Actually they contain some binary information so I am not sure whether output of my project is correct or not. So for debugging purposes, I want to write the data into a file so that I can use hexdump as follows -
$hexdump -C file.txt
Also as this is a run time generation of a n/w packet so I am also not sure about the length of data
and pack
structure which I think fread / fwrite
will require ..So please suggest me something.
The following code will give you a hex dump of arbitrary memory from within your code.
You pass into
hexDump
a description, memory address and length, and it will output a hex dump (including character data) for examination. When you run it with the includedmain
, the output is:A hex dump for Android, should be suitable for other platforms as well.
LOGD()
, same asDLOG()
, plays the role ofprintf()
becauseprintf()
does not work in Android. For platforms other than Android, you may#define DLOG printf
.dlog.h:
dump.cpp:
Usage example:
Output:
UPDATE: see dump.cpp and re_dump.h in reDroid (github), it includes a recursive dump that checks if a pointer is valid.