/*
+ * sgen-protocol.c: Binary protocol of internal activity, to aid
+ * debugging.
+ *
* Copyright 2001-2003 Ximian, Inc
* Copyright 2003-2010 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Copyright (C) 2012 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifdef HAVE_SGEN_GC
+
#include "config.h"
+#include "sgen-gc.h"
#include "sgen-protocol.h"
+#include "sgen-memory-governor.h"
+#include "utils/mono-mmap.h"
#ifdef SGEN_BINARY_PROTOCOL
g_assert (buffer->index > 0);
fwrite (buffer->buffer, 1, buffer->index, binary_protocol_file);
- sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer));
+ sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
}
void
if (buffer && buffer->index + length <= BINARY_PROTOCOL_BUFFER_SIZE)
return buffer;
- new_buffer = sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), TRUE, "debugging memory");
+ new_buffer = sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, "debugging memory");
new_buffer->next = buffer;
new_buffer->index = 0;
if (InterlockedCompareExchangePointer ((void**)&binary_protocol_buffers, new_buffer, buffer) != buffer) {
- sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer));
+ sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
goto retry;
}
}
void
-binary_protocol_collection (int generation)
+binary_protocol_collection_begin (int index, int generation)
+{
+ SGenProtocolCollection entry = { index, generation };
+ binary_protocol_flush_buffers (FALSE);
+ protocol_entry (SGEN_PROTOCOL_COLLECTION_BEGIN, &entry, sizeof (SGenProtocolCollection));
+}
+
+void
+binary_protocol_collection_end (int index, int generation)
{
- SGenProtocolCollection entry = { generation };
+ SGenProtocolCollection entry = { index, generation };
binary_protocol_flush_buffers (FALSE);
- protocol_entry (SGEN_PROTOCOL_COLLECTION, &entry, sizeof (SGenProtocolCollection));
+ protocol_entry (SGEN_PROTOCOL_COLLECTION_END, &entry, sizeof (SGenProtocolCollection));
}
void
protocol_entry (SGEN_PROTOCOL_EMPTY, &entry, sizeof (SGenProtocolEmpty));
}
+void
+binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip)
+{
+ SGenProtocolThreadSuspend entry = { thread, stopped_ip };
+ protocol_entry (SGEN_PROTOCOL_THREAD_SUSPEND, &entry, sizeof (SGenProtocolThreadSuspend));
+}
+
void
binary_protocol_thread_restart (gpointer thread)
{
SGenProtocolThreadRestart entry = { thread };
protocol_entry (SGEN_PROTOCOL_THREAD_RESTART, &entry, sizeof (SGenProtocolThreadRestart));
-
}
void
}
+void
+binary_protocol_card_scan (gpointer start, int size)
+{
+ SGenProtocolCardScan entry = { start, size };
+ protocol_entry (SGEN_PROTOCOL_CARD_SCAN, &entry, sizeof (SGenProtocolCardScan));
+}
+
+void
+binary_protocol_cement (gpointer obj, gpointer vtable, int size)
+{
+ SGenProtocolCement entry = { obj, vtable, size };
+ protocol_entry (SGEN_PROTOCOL_CEMENT, &entry, sizeof (SGenProtocolCement));
+}
+
+void
+binary_protocol_cement_reset (void)
+{
+ protocol_entry (SGEN_PROTOCOL_CEMENT_RESET, NULL, 0);
+}
#endif
+
+#endif /* HAVE_SGEN_GC */