Commit 08e87774 authored by Peter Pentchev's avatar Peter Pentchev

Fix hexdump_stub() for 16*n-byte blocks!

parent 36d240f7
......@@ -8,6 +8,7 @@ Changelog for libdebug.
printable, the rest is very much locale-dependent and
multibyte locales are much more common these days
- tests/Makefile: rebuild the executables if the library changes
- hex: fix hexdump_stub() for 16*n-byte blocks!
0.4.4 2011/07/19
- fix a compiler warning about an unused variable in memory.c
......
......@@ -43,38 +43,35 @@ static __inline__ int printable (int c)
static void dump16 (char *buf,const uint8_t *s,uintptr_t offset,size_t len)
{
if (len)
{
size_t i,n;
size_t i,n;
n = sprintf (buf,"%08lx - ",(unsigned long)offset);
n = sprintf (buf,"%08lx - ",(unsigned long)offset);
for (i = 0; i < len; i++)
{
if (i && !(i & 3))
buf[n++] = ' ';
for (i = 0; i < len; i++)
{
if (i && !(i & 3))
buf[n++] = ' ';
n += sprintf (buf + n,"%02x ",s[i]);
}
n += sprintf (buf + n,"%02x ",s[i]);
}
for ( ; i < 16; i++)
{
if (i && !(i & 3))
buf[n++] = ' ';
for ( ; i < 16; i++)
{
if (i && !(i & 3))
buf[n++] = ' ';
buf[n++] = ' ';
buf[n++] = ' ';
buf[n++] = ' ';
}
buf[n++] = ' ';
buf[n++] = ' ';
buf[n++] = ' ';
}
buf[n++] = ' ';
buf[n++] = ' ';
for (i = 0; i < len; i++)
buf[n++] = printable (s[i]) ? s[i] : '.';
for (i = 0; i < len; i++)
buf[n++] = printable (s[i]) ? s[i] : '.';
buf[n++] = '\n';
buf[n] = '\0';
}
buf[n++] = '\n';
buf[n] = '\0';
}
void hexdump_stub (const char *filename,int line,const char *function,int level,
......@@ -90,7 +87,10 @@ void hexdump_stub (const char *filename,int line,const char *function,int level,
log_puts_stub (filename,line,function,level,buf);
}
dump16 (buf,s,(uintptr_t) s - (uintptr_t) ptr,size & 15);
log_puts_stub (filename,line,function,level,buf);
if ((size & 15) != 0)
{
dump16 (buf,s,(uintptr_t) s - (uintptr_t) ptr,size & 15);
log_puts_stub (filename,line,function,level,buf);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment