X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-procname.c;h=0d42be9191958fc0042a74840cc97931cf1fb9f5;hb=refs%2Fheads%2Fstable-2.1;hp=b737084bf69aae013cee43c11e7ffa3484067ce5;hpb=c993aa602df5d770ea1da811c4f7f643dde1ed34;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-procname.c b/liblttng-ust/lttng-context-procname.c index b737084b..0d42be91 100644 --- a/liblttng-ust/lttng-context-procname.c +++ b/liblttng-ust/lttng-context-procname.c @@ -1,10 +1,23 @@ /* - * (C) Copyright 2009-2011 - - * Mathieu Desnoyers + * lttng-context-procname.c * * LTTng UST procname context. * - * Dual LGPL v2.1/GPL v2 license. + * Copyright (C) 2009-2012 Mathieu Desnoyers + * + * 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 @@ -18,8 +31,11 @@ * 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])); +}