Little memdump
Bill Baxter
dnewsgroup at billbaxter.com
Thu Mar 15 02:03:44 PDT 2007
Jeff McGlynn wrote:
> On 2007-03-12 17:40:16 -0700, Tom <tom at nospam.com> said:
>
>> Hi people,
>>
>> I just wanted to share with you a *very-humble* memdump procedure
>> that has been very helpful to me in my tedious D-debugging nights.
>>
>> Kind regards,
>
> Here is the code that I use:
>
> import std.stdio;
> import std.ctype;
>
> void debug_dump(ubyte[] data) {
> uint len = data.length;
> writefln("=== GOT %d BYTES:", len);
>
> for(uint offset = 0; offset < len; offset += 20) {
> uint end = offset + 20;
> if (end > len) end = len;
>
> for(uint ix = offset; ix < end; ++ix) {
> writef("%02X ", data[ix]);
> }
>
> if (offset + 20 > len) {
> char[] space = new char[3 * (offset + 20 - len)];
> space[] = ' ';
>
> writef(space);
> }
>
> writef("| ");
>
> for(uint ix = offset; ix < end; ++ix) {
> if (isprint(data[ix])) {
> writef("%s", cast(char) data[ix]);
> } else {
> writef(".");
> }
> }
>
> writefln();
> }
>
> writefln();
> }
>
Just curious -- what are you guys doing that you have to dump memory so
often?
--bb
More information about the Digitalmars-d
mailing list