2013-03-15 17:41:58 +01:00
|
|
|
/*
|
|
|
|
* Helper to hexdump a buffer
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Red Hat, Inc.
|
|
|
|
* Copyright (c) 2013 Gerd Hoffmann <kraxel@redhat.com>
|
|
|
|
* Copyright (c) 2013 Peter Crosthwaite <peter.crosthwaite@xilinx.com>
|
|
|
|
* Copyright (c) 2013 Xilinx, Inc
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2016-01-29 18:49:55 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-03-15 17:41:58 +01:00
|
|
|
#include "qemu-common.h"
|
|
|
|
|
2013-05-16 17:32:28 +02:00
|
|
|
void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
|
2013-03-15 17:41:58 +01:00
|
|
|
{
|
|
|
|
unsigned int b;
|
|
|
|
|
|
|
|
for (b = 0; b < size; b++) {
|
|
|
|
if ((b % 16) == 0) {
|
|
|
|
fprintf(fp, "%s: %04x:", prefix, b);
|
|
|
|
}
|
|
|
|
if ((b % 4) == 0) {
|
|
|
|
fprintf(fp, " ");
|
|
|
|
}
|
|
|
|
fprintf(fp, " %02x", (unsigned char)buf[b]);
|
|
|
|
if ((b % 16) == 15) {
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((b % 16) != 0) {
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
}
|