]>
Commit | Line | Data |
---|---|---|
6ff66f50 PC |
1 | /* |
2 | * Helper to hexdump a buffer | |
3 | * | |
4 | * Copyright (c) 2013 Red Hat, Inc. | |
5 | * Copyright (c) 2013 Gerd Hoffmann <[email protected]> | |
6 | * Copyright (c) 2013 Peter Crosthwaite <[email protected]> | |
7 | * Copyright (c) 2013 Xilinx, Inc | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | * Contributions after 2012-01-13 are licensed under the terms of the | |
13 | * GNU GPL, version 2 or (at your option) any later version. | |
14 | */ | |
15 | ||
16 | #include "qemu-common.h" | |
17 | ||
3568ac2a | 18 | void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size) |
6ff66f50 PC |
19 | { |
20 | unsigned int b; | |
21 | ||
22 | for (b = 0; b < size; b++) { | |
23 | if ((b % 16) == 0) { | |
24 | fprintf(fp, "%s: %04x:", prefix, b); | |
25 | } | |
26 | if ((b % 4) == 0) { | |
27 | fprintf(fp, " "); | |
28 | } | |
29 | fprintf(fp, " %02x", (unsigned char)buf[b]); | |
30 | if ((b % 16) == 15) { | |
31 | fprintf(fp, "\n"); | |
32 | } | |
33 | } | |
34 | if ((b % 16) != 0) { | |
35 | fprintf(fp, "\n"); | |
36 | } | |
37 | } |