From 62d643164f0915899cfd32db22e4e77110ea1dc2 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Thu, 4 May 2006 06:35:45 +0000 Subject: [PATCH] make dump work for any stream not just stdout and stderr --- ChangeLog | 5 +++++ jit/jit-dump.c | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8dd111a..d1f282b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-04 Radek Polak + + * jit/jit-dump.c (dump_object_code): Now can dump to any stream + not just stdout and stderr. + 2006-05-01 Aleksey Demakov * jit/jit-rules-x86.sel, jit/jit-rules-x86.ins: fix problem with diff --git a/jit/jit-dump.c b/jit/jit-dump.c index 1edc107..439e60f 100644 --- a/jit/jit-dump.c +++ b/jit/jit-dump.c @@ -641,14 +641,14 @@ static void dump_interp_code(FILE *stream, void **pc, void **end) #else /* !JIT_BACKEND_INTERP */ /* - * Dump the native object code representation of a function. - * Can only dump to stdout or stderr at the moment. + * Dump the native object code representation of a function to stream. */ static void dump_object_code(FILE *stream, void *start, void *end) { char cmdline[BUFSIZ]; unsigned char *pc = (unsigned char *)start; FILE *file; + int ch; #if JIT_WIN32_PLATFORM /* @@ -693,9 +693,18 @@ static void dump_object_code(FILE *stream, void *start, void *end) fclose(file); sprintf(cmdline, "as %s -o %s", s_path, o_path); system(cmdline); - sprintf(cmdline, "objdump --adjust-vma=%ld -d %s%s", - (long)(jit_nint)start, o_path, (stream == stderr ? " 1>&2" : "")); + sprintf(cmdline, "objdump --adjust-vma=%ld -d %s > %s", + (long)(jit_nint)start, o_path, s_path); system(cmdline); + file = fopen(s_path, "r"); + if(file) + { + while((ch = getc(file)) != EOF) + { + putc(ch, stream); + } + fclose(file); + } unlink(s_path); unlink(o_path); putc('\n', stream); @@ -706,7 +715,7 @@ static void dump_object_code(FILE *stream, void *start, void *end) /*@ * @deftypefun void jit_dump_function ({FILE *} stream, jit_function_t func, {const char *} name) - * Dump the three-address instructions within a function to a stdio stream. + * Dump the three-address instructions within a function to a stream. * The @code{name} is attached to the output as a friendly label, but * has no other significance. * -- 2.47.3