]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
make dump work for any stream not just stdout and stderr
authorAleksey Demakov <ademakov@gmail.com>
Thu, 4 May 2006 06:35:45 +0000 (06:35 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Thu, 4 May 2006 06:35:45 +0000 (06:35 +0000)
ChangeLog
jit/jit-dump.c

index 8dd111af8d0768cc151695cd698e57d9926eca5d..d1f282b1408d40ef3310963bcd3b248b070a0a98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-04  Radek Polak  <psonek2@seznam.cz>
+
+       * jit/jit-dump.c (dump_object_code): Now can dump to any stream
+       not just stdout and stderr.
+
 2006-05-01  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-rules-x86.sel, jit/jit-rules-x86.ins: fix problem with
index 1edc1074b15a4023572b3e46173a809ca029f1e3..439e60ff12e626d9e2954825da129c3bc65b107c 100644 (file)
@@ -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.
  *