]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Make dump_object_code() work on cygwin.
authorAleksey Demakov <ademakov@gmail.com>
Tue, 13 Dec 2005 08:32:02 +0000 (08:32 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Tue, 13 Dec 2005 08:32:02 +0000 (08:32 +0000)
Make jit_assert() break only if its argument is zero.

ChangeLog
jit/jit-dump.c
jit/jit-gen-x86.h

index 594df7d4cb2f51c3c305fb164f4b1a5f4317290f..f350294338c28ca9eab2c1f57f7eb5d274d0113e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-12-12  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-dump.c (dump_object_code): in order to make dump work on cygwin
+       call "as" and "objdump" in two separate system() calls because it looks
+       like the ';' separator between commands does not work there. Also on Win32
+       use TMP and TEMP environment variables as the tmp directory names and
+       fallback to "c:/tmp".
+
+       * jit/jit-gen-x86.h (jit_assert): change definition to resolve problems
+       introduced at 2005-12-10.
+
 2005-12-10  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-gen-x86.h: Merged changes from the latest Mono project's version
index c2af40c6db47b6947054cf256e3ae949afc3cf18..871e09b163e089c37a8df0a5df0ebaed18a2792f 100644 (file)
@@ -647,8 +647,39 @@ static void dump_interp_code(FILE *stream, void **pc, void **end)
 static void dump_object_code(FILE *stream, void *start, void *end)
 {
        char cmdline[BUFSIZ];
-       FILE *file = fopen("/tmp/libjit-dump.s", "w");
        unsigned char *pc = (unsigned char *)start;
+       FILE *file;
+
+#if JIT_WIN32_PLATFORM
+       /*
+        * NOTE: If libjit is compiled on cygwin with -mno-cygwin flag then
+        * fopen("/tmp/foo.s", ...) will use the root folder of the current
+        * drive. That is the full file name will be like "c:/tmp/foo". But
+        * the ``as'' and ``objdump'' utilities still use the cygwin's root.
+        * So "as /tmp/foo.s" will look for "c:/cygwin/tmp/foo.s". To avoid
+        * this ambiguity the file name has to contian the drive spec (e.g.
+        * fopen("c:/tmp/foo.s", ...) and "as c;/tmp/foo.s"). Here we assume
+        * that the TMP or TEMP environment variables always contain it.
+        */
+       char s_path[BUFSIZ];
+       char o_path[BUFSIZ];
+       char *tmp_dir = getenv("TMP");
+       if(tmp_dir == NULL)
+       {
+               tmp_dir = getenv("TEMP");
+               if(tmp_dir == NULL)
+               {
+                       tmp_dir = "c:/tmp";
+               }
+       }
+       sprintf(s_path, "%s/libjit-dump.s", tmp_dir);
+       sprintf(o_path, "%s/libjit-dump.o", tmp_dir);
+#else
+       const char *s_path = "/tmp/libjit-dump.s";
+       const char *o_path = "/tmp/libjit-dump.s";
+#endif
+
+       file = fopen(s_path, "w");
        if(!file)
        {
                return;
@@ -660,12 +691,13 @@ static void dump_object_code(FILE *stream, void *start, void *end)
                ++pc;
        }
        fclose(file);
-       sprintf(cmdline, "as /tmp/libjit-dump.s -o /tmp/libjit-dump.o;"
-                                        "objdump --adjust-vma=%ld -d /tmp/libjit-dump.o%s",
-                       (long)(jit_nint)start, (stream == stderr ? " 1>&2" : ""));
+       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" : ""));
        system(cmdline);
-       unlink("/tmp/libjit-dump.s");
-       unlink("/tmp/libjit-dump.o");
+       unlink(s_path);
+       unlink(o_path);
        putc('\n', stream);
        fflush(stream);
 }
index d59baab2e6b4dc1db9d4bff4f8550569c338221d..6317f96a62c2f06214a5f753299b08bf2fc7bcc4 100644 (file)
@@ -17,7 +17,7 @@
 
 #ifndef JIT_GEN_X86_H
 #define JIT_GEN_X86_H
-#define        jit_assert(x)   break
+#define        jit_assert(x)   if (!(x)) break
 /*
 // x86 register numbers
 */