diff options
Diffstat (limited to 'tools/llvm-c-test/disassemble.c')
-rw-r--r-- | tools/llvm-c-test/disassemble.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/llvm-c-test/disassemble.c b/tools/llvm-c-test/disassemble.c index 4b3d37b7d9..eb40bf3d44 100644 --- a/tools/llvm-c-test/disassemble.c +++ b/tools/llvm-c-test/disassemble.c @@ -20,8 +20,9 @@ #include <stdlib.h> static void pprint(int pos, unsigned char *buf, int len, const char *disasm) { + int i; printf("%04x: ", pos); - for (int i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { if (i < len) { printf("%02x ", buf[i]); } else { @@ -34,14 +35,15 @@ static void pprint(int pos, unsigned char *buf, int len, const char *disasm) { static void do_disassemble(const char *triple, unsigned char *buf, int siz) { LLVMDisasmContextRef D = LLVMCreateDisasm(triple, NULL, 0, NULL, NULL); + char outline[1024]; + int pos; if (!D) { printf("ERROR: Couldn't create disassebler for triple %s\n", triple); return; } - char outline[1024]; - int pos = 0; + pos = 0; while (pos < siz) { size_t l = LLVMDisasmInstruction(D, buf + pos, siz - pos, 0, outline, sizeof(outline)); @@ -61,10 +63,11 @@ static void handle_line(char **tokens, int ntokens) { unsigned char disbuf[128]; size_t disbuflen = 0; char *triple = tokens[0]; + int i; printf("triple: %s\n", triple); - for (int i = 1; i < ntokens; i++) { + for (i = 1; i < ntokens; i++) { disbuf[disbuflen++] = strtol(tokens[i], NULL, 16); if (disbuflen >= sizeof(disbuf)) { fprintf(stderr, "Warning: Too long line, truncating\n"); |