Skip to content

Instantly share code, notes, and snippets.

@knocte knocte/gist:6637263
Created Sep 20, 2013

Embed
What would you like to do?
debug patch to try to debug bug https://bugzilla.xamarin.com/show_bug.cgi?id=14834
diff --git a/mono/metadata/sgen-descriptor.h b/mono/metadata/sgen-descriptor.h
index cd53a86..178353a 100644
--- a/mono/metadata/sgen-descriptor.h
+++ b/mono/metadata/sgen-descriptor.h
@@ -172,22 +172,36 @@ sgen_gc_descr_has_references (mword desc)
#ifdef __GNUC__
#define OBJ_BITMAP_FOREACH_PTR(desc,obj) do { \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR\n"); \
/* there are pointers */ \
void **_objptr = (void**)(obj); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR2\n"); \
gsize _bmap = (desc) >> 16; \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR3\n"); \
_objptr += OBJECT_HEADER_WORDS; \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR4\n"); \
{ \
int _index = __builtin_ctz (_bmap); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR5\n"); \
_objptr += _index; \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR6\n"); \
_bmap >>= (_index + 1); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR7\n"); \
HANDLE_PTR (_objptr, (obj)); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR8\n"); \
_objptr ++; \
- } \
+ g_print ("___in oBJ_BITMAP_FOREACH_PTR9\n"); \
+} \
while (_bmap) { \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR10\n"); \
int _index = __builtin_ctz (_bmap); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR11\n"); \
_objptr += _index; \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR12\n"); \
_bmap >>= (_index + 1); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR13\n"); \
HANDLE_PTR (_objptr, (obj)); \
+g_print ("___in oBJ_BITMAP_FOREACH_PTR14\n"); \
_objptr ++; \
} \
} while (0)
diff --git a/mono/metadata/sgen-gc.c b/mono/metadata/sgen-gc.c
index da5e372..d8d1449 100644
--- a/mono/metadata/sgen-gc.c
+++ b/mono/metadata/sgen-gc.c
@@ -659,41 +659,55 @@ is_xdomain_ref_allowed (gpointer *ptr, char *obj, MonoDomain *domain)
static void
check_reference_for_xdomain (gpointer *ptr, char *obj, MonoDomain *domain)
{
+g_print ("___in HANDLE_PTRd1\n");
MonoObject *o = (MonoObject*)(obj);
+g_print ("___in HANDLE_PTRd2\n");
MonoObject *ref = (MonoObject*)*(ptr);
+g_print ("___in HANDLE_PTRd3\n");
int offset = (char*)(ptr) - (char*)o;
+g_print ("___in HANDLE_PTRd4\n");
MonoClass *class;
MonoClassField *field;
char *str;
-
+g_print ("___in HANDLE_PTRd5\n");
if (!ref || ref->vtable->domain == domain)
return;
+g_print ("___in HANDLE_PTRd6\n");
if (is_xdomain_ref_allowed (ptr, obj, domain))
return;
+g_print ("___in HANDLE_PTRd7\n");
field = NULL;
+g_print ("___in HANDLE_PTRd8\n");
for (class = o->vtable->klass; class; class = class->parent) {
+g_print ("___in HANDLE_PTRd9\n");
int i;
for (i = 0; i < class->field.count; ++i) {
+g_print ("___in HANDLE_PTRd10\n");
if (class->fields[i].offset == offset) {
+g_print ("___in HANDLE_PTRd11\n");
field = &class->fields[i];
+g_print ("___in HANDLE_PTRd12\n");
break;
}
}
if (field)
break;
}
+g_print ("___in HANDLE_PTRd13\n");
- if (ref->vtable->klass == mono_defaults.string_class)
- str = mono_string_to_utf8 ((MonoString*)ref);
+ if (ref->vtable->klass == mono_defaults.string_class) {g_print ("___in HANDLE_PTRd14\n");
+ str = mono_string_to_utf8 ((MonoString*)ref);}
else
str = NULL;
g_print ("xdomain reference in %p (%s.%s) at offset %d (%s) to %p (%s.%s) (%s) - pointed to by:\n",
o, o->vtable->klass->name_space, o->vtable->klass->name,
offset, field ? field->name : "",
ref, ref->vtable->klass->name_space, ref->vtable->klass->name, str ? str : "");
+g_print ("___in HANDLE_PTRd15\n");
mono_gc_scan_for_specific_ref (o, TRUE);
+g_print ("___in HANDLE_PTRd16\n");
if (str)
g_free (str);
}
@@ -713,10 +727,13 @@ static gboolean scan_object_for_specific_ref_precise = TRUE;
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
+ g_print ("___in HANDLE_PTRa1\n"); \
if ((MonoObject*)*(ptr) == key) { \
+ g_print ("___in HANDLE_PTRa2\n"); \
g_print ("found ref to %p in object %p (%s) at offset %td\n", \
key, (obj), safe_name ((obj)), ((char*)(ptr) - (char*)(obj))); \
} \
+ g_print ("___in HANDLE_PTRa3\n"); \
} while (0)
static void
@@ -1189,7 +1206,10 @@ sgen_drain_gray_stack (int max_objs, ScanCopyContext ctx)
if (!obj)
return TRUE;
SGEN_LOG (9, "Precise gray object scan %p (%s)", obj, safe_name (obj));
- scan_func (obj, queue);
+ if (scan_func == NULL)
+ g_error ("Invalid current generation %d", current_collection_generation);
+ else
+ scan_func (obj, queue);
}
} else {
int i;
@@ -4391,11 +4411,16 @@ void mono_gc_wbarrier_value_copy_bitmap (gpointer _dest, gpointer _src, int size
#ifdef SGEN_BINARY_PROTOCOL
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
+ g_print ("___in HANDLE_PTRb1\n"); \
gpointer o = *(gpointer*)(ptr); \
+ g_print ("___in HANDLE_PTRb2\n"); \
if ((o)) { \
+ g_print ("___in HANDLE_PTRb3\n"); \
gpointer d = ((char*)dest) + ((char*)(ptr) - (char*)(obj)); \
+ g_print ("___in HANDLE_PTRb4\n"); \
binary_protocol_wbarrier (d, o, (gpointer) LOAD_VTABLE (o)); \
} \
+ g_print ("___in HANDLE_PTRb5\n"); \
} while (0)
static void
@@ -4482,15 +4507,24 @@ typedef struct {
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
+ g_print ("___in HANDLE_PTRc1\n"); \
if (*(ptr)) { \
+ g_print ("___in HANDLE_PTRc2\n"); \
if (hwi->count == REFS_SIZE) { \
+ g_print ("___in HANDLE_PTRc3\n"); \
hwi->callback ((MonoObject*)start, mono_object_class (start), hwi->called? 0: size, hwi->count, hwi->refs, hwi->offsets, hwi->data); \
+ g_print ("___in HANDLE_PTRc4\n"); \
hwi->count = 0; \
+ g_print ("___in HANDLE_PTRc5\n"); \
hwi->called = 1; \
+ g_print ("___in HANDLE_PTRc6\n"); \
} \
+ g_print ("___in HANDLE_PTRc7\n"); \
hwi->offsets [hwi->count] = (char*)(ptr)-(char*)start; \
+ g_print ("___in HANDLE_PTRc8\n"); \
hwi->refs [hwi->count++] = *(ptr); \
} \
+ g_print ("___in HANDLE_PTRc9\n"); \
} while (0)
static void
diff --git a/mono/metadata/sgen-minor-scan-object.h b/mono/metadata/sgen-minor-scan-object.h
index 7a34dfd..2526e6b 100644
--- a/mono/metadata/sgen-minor-scan-object.h
+++ b/mono/metadata/sgen-minor-scan-object.h
@@ -39,16 +39,27 @@ extern long long stat_scan_object_called_nursery;
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
+g_print ("___in HANDLE_PTRe1\n"); \
void *__old = *(ptr); \
+g_print ("___in HANDLE_PTRe2\n"); \
void *__copy; \
+g_print ("___in HANDLE_PTRe3\n"); \
SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
+g_print ("___in HANDLE_PTRe4\n"); \
if (__old) { \
+g_print ("___in HANDLE_PTRe5\n"); \
PARALLEL_COPY_OBJECT ((ptr), queue); \
+g_print ("___in HANDLE_PTRe6\n"); \
__copy = *(ptr); \
+g_print ("___in HANDLE_PTRe7\n"); \
SGEN_COND_LOG (9, __old != __copy, "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
+g_print ("___in HANDLE_PTRe8\n"); \
if (G_UNLIKELY (sgen_ptr_in_nursery (__copy) && !sgen_ptr_in_nursery ((ptr)))) \
+g_print ("___in HANDLE_PTRe9\n"); \
sgen_add_to_global_remset ((ptr), __copy); \
+g_print ("___in HANDLE_PTRe10\n"); \
} \
+g_print ("___in HANDLE_PTRe11\n"); \
} while (0)
/*
@@ -91,12 +102,22 @@ PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOC
#undef HANDLE_PTR
/* Global remsets are handled in SERIAL_COPY_OBJECT_FROM_OBJ */
#define HANDLE_PTR(ptr,obj) do { \
- void *__old = *(ptr); \
+g_print ("___in HANDLE_PTRf1\n"); \
+if (!ptr) { \
+g_print ("___in HANDLE_PTRfUCK1\n"); \
+} else { g_print ("___in HANDLE_PTRfit's good!1\n"); } \
+ void *__old = (void*)*(ptr); \
+g_print ("___in HANDLE_PTRf2\n"); \
SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
+g_print ("___in HANDLE_PTRf3\n"); \
if (__old) { \
+g_print ("___in HANDLE_PTRf4\n"); \
SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue); \
+g_print ("___in HANDLE_PTRf5\n"); \
SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
+g_print ("___in HANDLE_PTRf6\n"); \
} \
+g_print ("___in HANDLE_PTRf7\n"); \
} while (0)
static void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.