Cache the procname per-thread rather than per-process to take into
account that prctl() can be used to set thread names.
prctl() should be issued before tracing each thread's first event if we
care about the thread name.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
void lttng_fixup_event_tls(void);
void lttng_fixup_vtid_tls(void);
void lttng_fixup_event_tls(void);
void lttng_fixup_vtid_tls(void);
+void lttng_fixup_procname_tls(void);
#endif /* _LTT_TRACER_CORE_H */
#endif /* _LTT_TRACER_CORE_H */
*
* LTTng UST procname context.
*
*
* LTTng UST procname context.
*
- * Copyright (C) 2009-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* each event.
* Upon exec, procname changes, but exec takes care of throwing away
* this cached version.
* each event.
* Upon exec, procname changes, but exec takes care of throwing away
* this cached version.
+ * The procname can also change by calling prctl(). The procname should
+ * be set for a thread before the first event is logged within this
+ * thread.
-static char cached_procname[17];
+static __thread char cached_procname[17];
static inline
char *wrapper_getprocname(void)
static inline
char *wrapper_getprocname(void)
field->record = procname_record;
return 0;
}
field->record = procname_record;
return 0;
}
+
+/*
+ * Force a read (imply TLS fixup for dlopen) of TLS variables.
+ */
+void lttng_fixup_procname_tls(void)
+{
+ asm volatile ("" : : "m" (cached_procname[0]));
+}
lttng_fixup_ringbuffer_tls();
lttng_fixup_vtid_tls();
lttng_fixup_nest_count_tls();
lttng_fixup_ringbuffer_tls();
lttng_fixup_vtid_tls();
lttng_fixup_nest_count_tls();
+ lttng_fixup_procname_tls();
/*
* We want precise control over the order in which we construct
/*
* We want precise control over the order in which we construct