Fix: liblttng-ust-fork Makefile flags mismatch
[lttng-ust.git] / liblttng-ust / lttng-context-procname.c
index b737084bf69aae013cee43c11e7ffa3484067ce5..0d42be9191958fc0042a74840cc97931cf1fb9f5 100644 (file)
@@ -1,10 +1,23 @@
 /*
- * (C) Copyright       2009-2011 -
- *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * lttng-context-procname.c
  *
  * LTTng UST procname context.
  *
- * Dual LGPL v2.1/GPL v2 license.
+ * 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
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <lttng/ust-events.h>
  * 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)
@@ -48,7 +64,7 @@ size_t procname_get_size(size_t offset)
 static
 void procname_record(struct lttng_ctx_field *field,
                 struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                struct ltt_channel *chan)
+                struct lttng_channel *chan)
 {
        char *procname;
 
@@ -81,3 +97,11 @@ int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
        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]));
+}
This page took 0.025114 seconds and 4 git commands to generate.