2010-02-10 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / mini / helpers.c
index 1b17098ec5db040dc6fb631693b1ee8c3839a773..af1235e317512555450b1e21e15e82fb1756237e 100644 (file)
@@ -7,7 +7,7 @@
 #include <ctype.h>
 #include <mono/metadata/opcodes.h>
 
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
 #include <unistd.h>
 #endif
 
@@ -62,6 +62,9 @@ opnames[] = {
 #define emit_debug_info  FALSE
 #endif
 
+#define ARCH_PREFIX ""
+//#define ARCH_PREFIX "powerpc64-linux-gnu-"
+
 const char*
 mono_inst_name (int op) {
        if (op >= OP_LOAD && op <= OP_LAST)
@@ -111,7 +114,7 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
        GHashTable *offset_to_bb_hash = NULL;
        int i, cindex, bb_num;
        FILE *ofd;
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
        const char *tmp = g_get_tmp_dir ();
 #endif
        const char *objdump_args = g_getenv ("MONO_OBJDUMP_ARGS");
@@ -119,7 +122,7 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
        char *o_file;
        char *cmd;
 
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
        as_file = g_strdup_printf ("%s/test.s", tmp);    
 
        if (!(ofd = fopen (as_file, "w")))
@@ -155,7 +158,7 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 
        cindex = 0;
        for (i = 0; i < size; ++i) {
-               if (emit_debug_info) {
+               if (emit_debug_info && cfg != NULL) {
                        bb_num = GPOINTER_TO_INT (g_hash_table_lookup (offset_to_bb_hash, GINT_TO_POINTER (i)));
                        if (bb_num) {
                                fprintf (ofd, "\n.stabd 68,0,%d\n", bb_num - 1);
@@ -208,14 +211,14 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 #define AS_CMD "as"
 #endif
 
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
        o_file = g_strdup_printf ("%s/test.o", tmp);
 #else  
        i = g_file_open_tmp (NULL, &o_file, NULL);
        close (i);
 #endif
 
-       cmd = g_strdup_printf (AS_CMD " %s -o %s", as_file, o_file);
+       cmd = g_strdup_printf (ARCH_PREFIX AS_CMD " %s -o %s", as_file, o_file);
        system (cmd); 
        g_free (cmd);
        if (!objdump_args)
@@ -226,16 +229,16 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
         * The arm assembler inserts ELF directives instructing objdump to display 
         * everything as data.
         */
-       cmd = g_strdup_printf ("strip -x %s", o_file);
+       cmd = g_strdup_printf (ARCH_PREFIX "strip -x %s", o_file);
        system (cmd);
        g_free (cmd);
 #endif
        
-       cmd = g_strdup_printf (DIS_CMD " %s %s", objdump_args, o_file);
+       cmd = g_strdup_printf (ARCH_PREFIX DIS_CMD " %s %s", objdump_args, o_file);
        system (cmd);
        g_free (cmd);
        
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
        unlink (o_file);
        unlink (as_file);
 #endif