Author: rolf
Date: 2007-10-09 03:55:05 -0400 (Tue, 09 Oct 2007)
New Revision: 87146

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/debug.cpp
   trunk/moon/src/debug.h
Log:
* src/debug.cpp, src/debug.h: Conditionally compile support for managed
  stack frames.

Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-10-09 07:54:26 UTC (rev 87145)
+++ trunk/moon/src/ChangeLog    2007-10-09 07:55:05 UTC (rev 87146)
@@ -1,3 +1,8 @@
+2007-10-09  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
+       * debug.cpp, debug.h: Conditionally compile support for managed stack
+         frames.
+
 2007-10-08  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * text.cpp (OnPropertyChanged): We may need to relayout even if

Modified: trunk/moon/src/debug.cpp
===================================================================
--- trunk/moon/src/debug.cpp    2007-10-09 07:54:26 UTC (rev 87145)
+++ trunk/moon/src/debug.cpp    2007-10-09 07:55:05 UTC (rev 87146)
@@ -11,7 +11,10 @@
  
 #if STACK_DEBUG
 
+#define MONO_STACK_ENABLED 1
+
 // Type safety at it's best.
+#if MONO_STACK_ENABLED
 #define MonoMethod void
 #define MonoJitInfo void
 #define MonoDomain void
@@ -36,10 +39,22 @@
        guint32 row, column;
        guint32 il_offset;
 };
+#endif
 
+static bool vm_stack_trace_enabled = FALSE;
+void
+enable_vm_stack_trace (bool enable)
+{
+       vm_stack_trace_enabled = enable;
+}
+
 static char*
 get_method_from_ip (void *ip)
 {
+       if (!vm_stack_trace_enabled)
+               return NULL;
+       
+#if MONO_STACK_ENABLED
        MonoJitInfo *ji;
        MonoMethod *mi;
        char *method;
@@ -70,6 +85,9 @@
        g_free (method);
 
        return res;
+#else
+       return NULL;
+#endif
 }
 
 char* get_stack_trace () 
@@ -157,9 +175,20 @@
        return result;
 }
 
+static char* addr2line_offset (gpointer ip, bool use_offset);
 
+static char* 
+addr2line (gpointer ip) 
+{
+       char* result = addr2line_offset (ip, true);
+       if (result == NULL)
+               result = addr2line_offset (ip, false);
+       return result;
+}
+
+
 static char*
-addr2line (gpointer ip)
+addr2line_offset (gpointer ip, bool use_offset)
 {
        char *res;
        Addr2LineData *addr2line;
@@ -196,7 +225,10 @@
        }
                
        gpointer offset;
-       offset = (gpointer) (((size_t) ip) - ((size_t) addr2line->base));
+       if (use_offset)
+               offset = (gpointer) (((size_t) ip) - ((size_t) 
addr2line->base));
+       else
+               offset = ip;
        
        // printf ("Checking ip: %p, offset: %p, base: %p\n", ip, offset, 
addr2line->base);
        fprintf (addr2line->pipein, "%p\n", offset);

Modified: trunk/moon/src/debug.h
===================================================================
--- trunk/moon/src/debug.h      2007-10-09 07:54:26 UTC (rev 87145)
+++ trunk/moon/src/debug.h      2007-10-09 07:55:05 UTC (rev 87146)
@@ -24,14 +24,19 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define MAX_STACK_FRAMES 15
+#define MAX_STACK_FRAMES 30
 
 char* get_stack_trace_prefix (const char* prefix);
 void print_stack_trace_prefix (const char* prefix); 
 
+G_BEGIN_DECLS
+
 char* get_stack_trace ();
 void print_stack_trace ();
+void enable_vm_stack_trace (bool enable);
 
+G_END_DECLS
+
 #endif
 
 #endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to