Name: Anonymous 2012-08-18 19:35
Why the fuck is it so absolutely convoluted just to get it to display a standard 16 byte + ASCII hexdump of what's in memory at a particular address, unlike almost every other debugger out there?
printfs to your code than to use the debugger.
19000100 49 20 6B 6E 6F 77 20 61-62 6F 75 74 20 78 2C 20 I know about x,
19000110 62 75 74 20 74 68 61 74-20 64 6F 65 73 6E 27 74 but that doesn't
19000120 20 70 72 69 6E 74 20 6F-75 74 20 61 20 73 74 61 print out a sta
19000130 6E 64 61 72 64 20 68 65-78 64 75 6D 70 2C 20 77 ndard hexdump, w
19000140 68 69 63 68 20 69 6E 20-63 61 73 65 20 79 6F 75 hich in case you
19000150 20 64 6F 6E 27 74 20 6B-6E 6F 77 2C 20 6C 6F 6F don't know, loo
19000160 6B 73 20 6C 69 6B 65 20-74 68 69 73 2E 00 00 00 ks like this....
19000170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
typedef unsigned char u1;
#define times(i,e) for(i=0; i<(e); i++)
static void hd(u1 *P, int S) {
int X, Y, I;
times(Y, (S+15)/16) {
printf("%04X |", Y*16);
times(X, 16) {
I = Y*16 + X;
if ((I&0xf) == 8) printf(" ");
if (I<S) printf(" %02X", P[I]);
else printf(" ");
}
printf(" |");
times(X, 16) {
I = Y*16 + X;
if (I<S && isprint(P[I]) && P[I]!='\n' && P[I]!='\t') printf("%c", P[I]);
else printf(" ");
}
printf("\n");
}
}
printf is a lot weaker than the Algol 68, PL/I or Common Lisp equivalents.$16r4d" |", 2(" "8(16r2d" ")), "|"16a, l$00000000 49 20 6b 6e 6f 77 20 61 62 6f 75 74 20 78 2c 20 |I know about x, |
00000010 62 75 74 20 74 68 61 74 20 64 6f 65 73 6e 74 20 |but that doesnt |
00000020 70 72 69 6e 74 20 6f 75 74 20 61 20 73 74 61 6e |print out a stan|
00000030 64 61 72 64 20 68 65 78 64 75 6d 70 2c 20 77 68 |dard hexdump, wh|
00000040 69 63 68 20 69 6e 20 63 61 73 65 20 79 6f 75 20 |ich in case you |
00000050 64 6f 6e 74 20 6b 6e 6f 77 2c 20 6c 6f 6f 6b 73 |dont know, looks|
00000060 20 6c 69 6b 65 20 74 68 69 73 | like this|
0000006a
(gdb) x/32x 0x08048732
0x8048732 <main+3>: 0x81f0e483 0x0068f0ec 0x2444c700 0x00680008
0x8048742 <main+19>: 0x2444c700 0x00000004 0x24448d00 0x2404891c
0x8048752 <main+35>: 0xfffcd5e8 0x2444c7ff 0x00006808 0x2444c700
0x8048762 <main+51>: 0x00000004 0x24848d00 0x0000681c 0xe8240489
0x8048772 <main+67>: 0xfffffcb6 0xec2484c7 0x00000068 0xeb000000
0x8048782 <main+83>: 0x24948b28 0x000068ec 0xec24848b 0xc1000068
0x8048792 <main+99>: 0xc1890ae0 0x1c24448d 0x8489c801 0x00688494
0x80487a2 <main+115>: 0x24848300 0x000068ec 0x24bc8301 0x000068ec
(gdb) x/32s 0x08048732
0x8048732 <main+3>: "\203\344\360\201\354\360h"
0x804873a <main+11>: ""
0x804873b <main+12>: "\307D$\b"
0x8048740 <main+17>: "h"
0x8048742 <main+19>: ""
0x8048743 <main+20>: "\307D$\004"
0x8048748 <main+25>: ""
0x8048749 <main+26>: ""
0x804874a <main+27>: ""
0x804874b <main+28>: "\215D$\034\211\004$\350\325\374\377\377\307D$\bh"
0x804875d <main+46>: ""
0x804875e <main+47>: ""
0x804875f <main+48>: "\307D$\004"
0x8048764 <main+53>: ""
0x8048765 <main+54>: ""
0x8048766 <main+55>: ""
0x8048767 <main+56>: "\215\204$\034h"
0x804876d <main+62>: ""
0x804876e <main+63>: "\211\004$\350\266\374\377\377DŽ$\354h"
0x804877c <main+77>: ""
0x804877d <main+78>: ""
0x804877e <main+79>: ""
0x804877f <main+80>: ""
0x8048780 <main+81>: ""
0x8048781 <main+82>: "\353(\213\224$\354h"
0x8048789 <main+90>: ""
0x804878a <main+91>: "\213\204$\354h"
0x8048790 <main+97>: ""
0x8048791 <main+98>: "\301\340\n\211\301\215D$\034\001ȉ\204\224\204h"
0x80487a2 <main+115>: ""
0x80487a3 <main+116>: "\203\204$\354h"
0x80487a9 <main+122>: ""
(gdb)
x is fine as long as you know what you're looking at (bytes, words, ASCII chars) beforehand. For wild and crazy shit, though, you're going to want to reach for IDA...