*/
mono_profiler_thread_start (tid);
+ /* if the name was set before starting, we didn't invoke the profiler callback */
+ if (internal->name && (internal->flags & MONO_THREAD_FLAG_NAME_SET)) {
+ char *tname = g_utf16_to_utf8 (internal->name, -1, NULL, NULL, NULL);
+ mono_profiler_thread_name (internal->tid, tname);
+ g_free (tname);
+ }
/* start_func is set only for unmanaged start functions */
if (start_func) {
start_func (start_arg);
UNLOCK_THREAD (this_obj);
- if (this_obj->name) {
+ if (this_obj->name && this_obj->tid) {
char *tname = mono_string_to_utf8 (name);
-
- if (this_obj->tid) {
- mono_profiler_thread_name (this_obj->tid, tname);
- mono_thread_info_set_name (this_obj->tid, tname);
- }
+ mono_profiler_thread_name (this_obj->tid, tname);
+ mono_thread_info_set_name (this_obj->tid, tname);
mono_free (tname);
}
}
fprintf (outfile, "non-zero flags in thread\n");
return 0;
}
- nt = get_thread (ctx, ptr_base * ptrdiff);
+ nt = get_thread (ctx, ptr_base + ptrdiff);
nt->name = pstrdup ((char*)p);
if (debug)
fprintf (outfile, "thread %p named: %s\n", (void*)(ptr_base + ptrdiff), p);
static pthread_key_t tlsbuffer;
#endif
+static void safe_dump (MonoProfiler *profiler, LogBuffer *logbuffer);
+
static char*
pstrdup (const char *s)
{
runtime_initialized (MonoProfiler *profiler)
{
runtime_inited = 1;
+ /* ensure the main thread data and startup are available soon */
+ safe_dump (profiler, ensure_logbuf (0));
}
/*