mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 12:32:47 -05:00
Debugging improvements. Started using Dave Hinton's dmemdump
function (woohoo!), improved that function so it provides an ASCII dump as well as hex (whee!), removed all remaining spurious \r in debug statements (ooh!), and made enabling of packet debugging in SSH a matter of one ifdef rather than lots (phew!). [originally from svn r1091]
This commit is contained in:
12
misc.c
12
misc.c
@ -334,6 +334,7 @@ void dprintf(char *fmt, ...) {
|
||||
void debug_memdump (void *buf, int len, int L) {
|
||||
int i;
|
||||
unsigned char *p = buf;
|
||||
char foo[17];
|
||||
if (L) {
|
||||
int delta;
|
||||
dprintf ("\t%d (0x%x) bytes:\n", len, len);
|
||||
@ -342,20 +343,25 @@ void debug_memdump (void *buf, int len, int L) {
|
||||
len += delta;
|
||||
}
|
||||
for (; 0 < len; p += 16, len -= 16) {
|
||||
dputs ("\t");
|
||||
if (L) dprintf ("%p: ", p);
|
||||
dputs (" ");
|
||||
if (L) dprintf ("%p: ", p);
|
||||
strcpy(foo, "................"); /* sixteen dots */
|
||||
for (i = 0; i < 16 && i < len; ++i) {
|
||||
if (&p[i] < (unsigned char *) buf) {
|
||||
dputs (" "); /* 3 spaces */
|
||||
foo[i] = ' ';
|
||||
} else {
|
||||
dprintf (
|
||||
"%c%02.2x",
|
||||
&p[i] != (unsigned char *) buf && i % 4 ? '.' : ' ',
|
||||
p[i]
|
||||
);
|
||||
if (p[i] >= ' ' && p[i] <= '~')
|
||||
foo[i] = (char)p[i];
|
||||
}
|
||||
}
|
||||
dputs ("\n");
|
||||
foo[i] = '\0';
|
||||
dprintf("%*s%s\n", (16-i)*3+2, "", foo);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user