if (managed2 || ji->method->wrapper_type) {
char *source_location, *tmpaddr, *fname;
- gint32 address, iloffset;
+ gint32 offset, iloffset;
- address = (char *)ip - (char *)ji->code_start;
+ if (!managed2)
+ /* ctx->ip points into native code */
+ offset = (char*)MONO_CONTEXT_GET_IP (new_ctx) - (char*)ji->code_start;
+ else
+ offset = (char *)ip - (char *)ji->code_start;
if (native_offset)
- *native_offset = address;
+ *native_offset = offset;
if (managed)
if (!ji->method->wrapper_type)
*managed = TRUE;
if (trace) {
- source_location = mono_debug_source_location_from_address (ji->method, address, NULL, domain);
- iloffset = mono_debug_il_offset_from_address (ji->method, address, domain);
+ source_location = mono_debug_source_location_from_address (ji->method, offset, NULL, domain);
+ iloffset = mono_debug_il_offset_from_address (ji->method, offset, domain);
if (iloffset < 0)
- tmpaddr = g_strdup_printf ("<0x%05x>", address);
+ tmpaddr = g_strdup_printf ("<0x%05x>", offset);
else
tmpaddr = g_strdup_printf ("[0x%05x]", iloffset);
MonoLMF *lmf = jit_tls->lmf;
MonoJitInfo *ji, rji;
MonoContext ctx, new_ctx;
- unsigned int stackptr;
+ gssize stackptr;
mono_arch_flush_register_windows ();
#ifdef _MSC_VER
__asm mov stackptr, ebp;
#else
- stackptr = (unsigned int) __builtin_frame_address (0);
+ stackptr = (gssize)__builtin_frame_address (0);
#endif
MONO_CONTEXT_SET_IP (&ctx, ves_icall_get_frame_info);
typedef struct {
guint32 skips;
- GList *stack;
+ MonoArray *stack;
+ guint32 count;
+ guint32 maximum;
} MonoSecurityStack;
+static void
+grow_array (MonoSecurityStack *stack)
+{
+ MonoDomain *domain = mono_domain_get ();
+ guint32 newsize = (stack->maximum << 1);
+ MonoArray *newstack = mono_array_new (domain, mono_defaults.runtimesecurityframe_class, newsize);
+ int i;
+ for (i=0; i < stack->maximum; i++) {
+ gpointer frame = mono_array_get (stack->stack, gpointer, i);
+ mono_array_set (newstack, gpointer, i, frame);
+ }
+ stack->maximum = newsize;
+ stack->stack = newstack;
+}
+
static gboolean
callback_get_stack_frames_security_info (MonoDomain *domain, MonoContext *ctx, MonoJitInfo *ji, gpointer data)
{
return FALSE;
}
- ss->stack = g_list_prepend (ss->stack, mono_declsec_create_frame (domain, ji));
+ if (ss->count == ss->maximum)
+ grow_array (ss);
+
+ mono_array_set (ss->stack, gpointer, ss->count++, mono_declsec_create_frame (domain, ji));
/* continue down the stack */
return FALSE;
MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
MonoSecurityStack ss;
MonoContext ctx;
- MonoArray *stack;
#ifdef _MSC_VER
/* seems that MSC doesn't like having __asm in macros */
#endif
ss.skips = skip;
- ss.stack = NULL;
+ ss.count = 0;
+ ss.maximum = MONO_CAS_INITIAL_STACK_SIZE;
+ ss.stack = mono_array_new (domain, mono_defaults.runtimesecurityframe_class, ss.maximum);
mono_walk_stack (domain, jit_tls, &ctx, callback_get_stack_frames_security_info, (gpointer)&ss);
-
- stack = glist_to_array (ss.stack, mono_defaults.runtimesecurityframe_class);
- if (ss.stack)
- g_list_free (ss.stack);
-
- return stack;
+ /* g_warning ("STACK RESULT: %d out of %d", ss.count, ss.maximum); */
+ return ss.stack;
}
#ifndef CUSTOM_EXCEPTION_HANDLING