Log profiler: portability checks.
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 29 Nov 2010 14:44:21 +0000 (15:44 +0100)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 29 Nov 2010 14:44:56 +0000 (15:44 +0100)
configure.in
mono/profiler/proflog.c

index 170443341271384966a8185472f812721c072d80..38ea790819d4a11ffb87cc05ebfc67a19eb02003 100644 (file)
@@ -984,6 +984,7 @@ if test x$target_win32 = xno; then
        AC_CHECK_FUNCS(getpriority)
        AC_CHECK_FUNCS(setpriority)
        AC_CHECK_FUNCS(dl_iterate_phdr)
+       AC_CHECK_FUNCS(dladdr)
        AC_CHECK_FUNCS(sysconf)
 
        AC_CHECK_FUNCS(sched_setaffinity)
index bb765bc7b096b362b9c84b3fa379f5fd727e576c..e58c8a77fea9fdd9bed2d1eb3bf72a4862a8fab2 100644 (file)
@@ -1130,9 +1130,10 @@ thread_name (MonoProfiler *prof, uintptr_t tid, const char *name)
        EXIT_LOG (logbuffer);
 }
 
-#ifdef HOST_WIN32
+#include "mono/io-layer/atomic.h"
+//#ifdef HOST_WIN32
 #define cmp_exchange InterlockedCompareExchangePointer
-#else
+/*#else
 static void*
 cmp_exchange (volatile void **dest, void *exch, void *comp)
 {
@@ -1149,6 +1150,7 @@ cmp_exchange (volatile void **dest, void *exch, void *comp)
        return old;
 }
 #endif
+*/
 
 static void
 mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
@@ -1432,21 +1434,24 @@ elf_dl_callback (struct dl_phdr_info *info, size_t size, void *data)
        return 0;
 }
 
-static void
+static int
 load_binaries (MonoProfiler *prof)
 {
        dl_iterate_phdr (elf_dl_callback, prof);
+       return 1;
 }
 #else
-static void
+static int
 load_binaries (MonoProfiler *prof)
 {
+       return 0;
 }
 #endif
 
 static const char*
 symbol_for (uintptr_t code)
 {
+#ifdef HAVE_DLADDR
        void *ip = (void*)code;
        Dl_info di;
        if (dladdr (ip, &di)) {
@@ -1462,6 +1467,7 @@ symbol_for (uintptr_t code)
                }
                */
        }
+#endif
        return NULL;
 }
 
@@ -1472,8 +1478,8 @@ dump_unmanaged_coderefs (MonoProfiler *prof)
        const char* last_symbol;
        uintptr_t addr, page_end;
 
-       load_binaries (prof);
-       return;
+       if (load_binaries (prof))
+               return;
        for (i = 0; i < size_code_pages; ++i) {
                const char* sym;
                if (!code_pages [i] || code_pages [i] & 1)