From efb964024ea2f3a2f01cab056348733d9c0a27e0 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Tue, 13 Dec 2005 08:32:02 +0000 Subject: [PATCH] Make dump_object_code() work on cygwin. Make jit_assert() break only if its argument is zero. --- ChangeLog | 11 +++++++++++ jit/jit-dump.c | 44 ++++++++++++++++++++++++++++++++++++++------ jit/jit-gen-x86.h | 2 +- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 594df7d..f350294 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-12-12 Aleksey Demakov + + * 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 * jit/jit-gen-x86.h: Merged changes from the latest Mono project's version diff --git a/jit/jit-dump.c b/jit/jit-dump.c index c2af40c..871e09b 100644 --- a/jit/jit-dump.c +++ b/jit/jit-dump.c @@ -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); } diff --git a/jit/jit-gen-x86.h b/jit/jit-gen-x86.h index d59baab..6317f96 100644 --- a/jit/jit-gen-x86.h +++ b/jit/jit-gen-x86.h @@ -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 */ -- 2.47.3