#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-os-mutex.h>
+#include <mono/utils/mono-os-semaphore.h>
#include <mono/utils/mono-conc-hashtable.h>
#include <mono/utils/lock-free-alloc.h>
#include <mono/utils/lock-free-queue.h>
+#include <mono/utils/hazard-pointer.h>
+#include <mono/utils/mono-threads.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
static gint32 class_loads;
static gint32 class_unloads;
-typedef struct _LogBuffer LogBuffer;
-
/*
* file format:
* [header] [buffer]*
// Pending data to be written to the log, for a single thread.
// Threads periodically flush their own LogBuffers by calling safe_send
+typedef struct _LogBuffer LogBuffer;
struct _LogBuffer {
// Next (older) LogBuffer in processing queue
LogBuffer *next;
#define EXIT_LOG(lb) (lb)->locked--;
typedef struct _BinaryObject BinaryObject;
-
struct _BinaryObject {
BinaryObject *next;
void *addr;
GPtrArray *coverage_filters;
};
-typedef struct _WriterQueueEntry WriterQueueEntry;
-struct _WriterQueueEntry {
+typedef struct {
MonoLockFreeQueueNode node;
GPtrArray *methods;
LogBuffer *buffer;
-};
+} WriterQueueEntry;
-typedef struct _MethodInfo MethodInfo;
-struct _MethodInfo {
+typedef struct {
MonoMethod *method;
MonoJitInfo *ji;
uint64_t time;
-};
+} MethodInfo;
#ifdef TLS_INIT
#undef TLS_INIT
sample = mono_lock_free_alloc (&profiler->sample_allocator);
sample->prof = profiler;
+ mono_lock_free_queue_node_init (&sample->node, TRUE);
InterlockedIncrement (&sample_allocations);
}
- mono_lock_free_queue_node_init (&sample->node, TRUE);
-
sample->count = 0;
mono_stack_walk_async_safe (&async_walk_stack, context, sample);
static GPtrArray *coverage_data = NULL;
static int previous_offset = 0;
-typedef struct _MethodNode MethodNode;
-struct _MethodNode {
+typedef struct {
MonoLockFreeQueueNode node;
MonoMethod *method;
-};
+} MethodNode;
-typedef struct _CoverageEntry CoverageEntry;
-struct _CoverageEntry {
+typedef struct {
int offset;
int counter;
char *filename;
int line;
int column;
-};
+} CoverageEntry;
static void
free_coverage_entry (gpointer data, gpointer userdata)
MonoThread *thread = NULL;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler helper");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler helper");
//fprintf (stderr, "Server listening\n");
command_socket = -1;
MonoProfiler *prof = (MonoProfiler *)arg;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler writer");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler writer");
dump_header (prof);
SampleHit *sample;
if ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->dumper_queue))) {
- mono_lock_free_queue_node_init (&sample->node, TRUE);
-
for (int i = 0; i < sample->count; ++i) {
MonoMethod *method = sample->frames [i].method;
MonoDomain *domain = sample->frames [i].domain;
MonoProfiler *prof = (MonoProfiler *)arg;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler dumper");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler dumper");
while (InterlockedRead (&prof->run_dumper_thread)) {
mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);