summaryrefslogtreecommitdiff
path: root/util/hexdump.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-03-18 07:34:24 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-18 07:34:24 -0500
commite531761d63b7f8fe6b6423fafb3616ebbff768aa (patch)
treea4ca2537f1e887d8c81ff6820baccb039634d320 /util/hexdump.c
parentb1999e87b4d42305419329cae459e1b43f706d96 (diff)
parent1562e53112fd1082c656a06d953a7447ab17e6e1 (diff)
downloadqemu-e531761d63b7f8fe6b6423fafb3616ebbff768aa.tar.gz
qemu-e531761d63b7f8fe6b6423fafb3616ebbff768aa.tar.bz2
qemu-e531761d63b7f8fe6b6423fafb3616ebbff768aa.zip
Merge remote-tracking branch 'kraxel/pixman.v8' into staging
# By Gerd Hoffmann (18) and others # Via Blue Swirl (1) and Gerd Hoffmann (1) * kraxel/pixman.v8: (37 commits) console: remove ds_get_* helper functions console: zap color_table console: stop using DisplayState in gfx hardware emulation console: zap displaystate from dcl callbacks cocoa: stop using DisplayState spice: stop using DisplayState sdl: stop using DisplayState vnc: stop using DisplayState gtk: stop using DisplayState console: add surface_*() getters console: rework DisplaySurface handling [dcl/ui side] console: rework DisplaySurface handling [vga emu side] sdl: drop dead code qxl: better vga init in enter_vga_mode qxl: zap qxl0 global spice: zap sdpy global console: kill DisplayState->opaque console: fix displaychangelisteners interface s390: Fix cpu refactoring fallout. target-mips: fix rndrashift_short_acc and code for EXTR_ instructions ...
Diffstat (limited to 'util/hexdump.c')
-rw-r--r--util/hexdump.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/util/hexdump.c b/util/hexdump.c
new file mode 100644
index 0000000000..0d0efc86de
--- /dev/null
+++ b/util/hexdump.c
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#include "qemu-common.h"
+
+void hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
+{
+ 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");
+ }
+}