Skip to contentSkip to conversation

tracepoint provider: static versus dynamic linking (TRACEPOINT_PROBE_DYNAMIC_LINKAGE)

DISCUSSION Mathieu Desnoyers 1 participant 1 message May 3, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi David,

Sorry for the late reply,

Quoted 4 lines · * David Bryant ([email protected]) wrote:

Hello,

What are the pros and cons of static versus dynamic linking of the tracepoint provider? I can't find much information looking around.

static linking: no need to use LD_PRELOAD.

dynamic linking: can ship tracepoint provider as separate .so, packaging separately from the instrumented application.

Quoted 2 lines

Are their any licensing related issues? For example, is closed-source software not allowed to use static linking?

The headers used to build the tracepoint providers are MIT-licensed, so there is absolutely no licensing issue here with static linking of tracepoint providers with closed-source apps. However, liblttng-ust per se is _always_ dynamically linked.

Thanks,

Mathieu

Quoted 53 lines

Is it just an optimisation - allowing the program to run without probes connected?

Thanks,
Dave

Notes from my digging of how it works:

Looking at the preprocessor output of sample.c without/with TRACEPOINT_PROBE_DYNAMIC_LINKAGE defined I see:

$ diff -u sample.i.static sample.i.dynamic
sample.i.dynamic 2012-11-08 13:29:04.169062438 +1030 renamed from sample.i.static 2012-11-08 13:29:04.049059515 +1030 +1 -1
@@ -746,7 +746,7 @@
 struct tracepoint __tracepoint_sample_component___message  
 __attribute__((section("__tracepoints"))) = {
     __tp_strtab_sample_component___message,
     0,
     ((void *)0),
-    &__tracepoint_provider_sample_component,
+    ((void *)0),
     "char *, text",

};

(line breaks added by me).

So the "int * tracepoint::tracepoint_provider_ref" member is set to ((void *)0) in struct tracepoint:

struct tracepoint {
const char *name;
int state;
struct tracepoint_probe *probes;
int *tracepoint_provider_ref; /* XXX */
const char *signature;
char padding[16];
};

So the static version is not dependent on the symbol "__tracepoint_provider_sample_component". Running LD_PRELOAD=libprovider.so ./sample (somehow?) reinstates that symbol. (Can't quite see how that works).

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com