Added a separator between hex and ascii sides.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,42 +6,37 @@
|
|||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
void dump_memory
|
void dump_memory(const char *prefix, const void *data, size_t len)
|
||||||
(
|
|
||||||
const char * prefix,
|
|
||||||
const void * data,
|
|
||||||
size_t len
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
uint32 i,j;
|
uint32 i,j;
|
||||||
char text[96]; // only 3*16 + 16 max by line needed
|
char text[96]; // only 3*16 + 3 + 16 max by line needed
|
||||||
uint8 * byte;
|
uint8 *byte;
|
||||||
char * ptr;
|
char *ptr;
|
||||||
|
|
||||||
byte = (uint8 *) data;
|
byte = (uint8 *) data;
|
||||||
|
|
||||||
for ( i = 0; i < len; i += 16 )
|
for ( i = 0; i < len; i += 16 ) {
|
||||||
{
|
|
||||||
ptr = text;
|
ptr = text;
|
||||||
|
|
||||||
for ( j = i; j < i+16 ; j++ )
|
for ( j = i; j < i+16 ; j++ ) {
|
||||||
{
|
|
||||||
if ( j < len )
|
if ( j < len )
|
||||||
sprintf(ptr, "%02x ", byte[j]);
|
sprintf(ptr, "%02x ", byte[j]);
|
||||||
else
|
else
|
||||||
sprintf(ptr, " ");
|
sprintf(ptr, " ");
|
||||||
ptr += 3;
|
ptr += 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (j = i; j < len && j < i+16;j++)
|
strcat(ptr, "| ");
|
||||||
{
|
ptr += 2;
|
||||||
|
|
||||||
|
for (j = i; j < len && j < i+16;j++) {
|
||||||
if ( byte[j] >= 0x20 && byte[j] < 0x7e )
|
if ( byte[j] >= 0x20 && byte[j] < 0x7e )
|
||||||
*ptr = byte[j];
|
*ptr = byte[j];
|
||||||
else
|
else
|
||||||
*ptr = '.';
|
*ptr = '.';
|
||||||
|
|
||||||
ptr++;
|
ptr++;
|
||||||
};
|
};
|
||||||
*ptr = '\n';
|
*ptr = '\n';
|
||||||
ptr++;
|
ptr++;
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
@@ -51,5 +46,5 @@ void dump_memory
|
|||||||
dprintf(text);
|
dprintf(text);
|
||||||
|
|
||||||
// next line
|
// next line
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user