X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-procname.c;h=0d42be9191958fc0042a74840cc97931cf1fb9f5;hb=a719be6472181c3d633c17b7f8e877f420d0c358;hp=d165be88277daada8bbb616c2db60572050f9aa2;hpb=9501d22f55b3a23f382f631c99b2325d1419b5da;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-procname.c b/liblttng-ust/lttng-context-procname.c index d165be88..0d42be91 100644 --- a/liblttng-ust/lttng-context-procname.c +++ b/liblttng-ust/lttng-context-procname.c @@ -3,7 +3,7 @@ * * LTTng UST procname context. * - * Copyright (C) 2009-2011 Mathieu Desnoyers + * 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 @@ -31,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) @@ -61,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; @@ -94,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])); +}