<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.hoenzb
{mso-style-name:hoenzb;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">HI Mathieu,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I wanted to ask a couple of follow-up questions on this. If you build an so containing the probe provider, do you have to then use LD_PRELOAD to load it? Ideally,
we’d like to do any dynamic loading programmatically so that there’s no environment setup needed, while at the same time ensuring that the probe provider so is dynamic so that it is not required to run the application.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">On a side-note, I did a bit of inspection and it looks to me like most every call from the probe definition macros is dynamic (through dlopen/dlsym). The only
ones that I saw that are static were for registration/unregistration. Is it possible that we just did something wrong, and there is a way to make registration dynamic as well?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Brian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Mathieu Desnoyers [mailto:mathieu.desnoyers@efficios.com]
<br>
<b>Sent:</b> Saturday, September 12, 2015 9:59 AM<br>
<b>To:</b> Brian Robbins <brianrob@microsoft.com><br>
<b>Cc:</b> Jeremie Galarneau <jeremie.galarneau@efficios.com>; Rama Krishnan Raghupathy <ramarag@microsoft.com>; lttng-dev <lttng-dev@lists.lttng.org><br>
<b>Subject:</b> Re: [lttng-dev] Instrumenting a Shared Object<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">----- On Sep 9, 2015, at 4:49 PM, Brian Robbins <<a href="mailto:brianrob@microsoft.com">brianrob@microsoft.com</a>> wrote:<br>
<br>
<o:p></o:p></span></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">One additional question on this. It appears that the tracepoint initialization code will dlopen liblttng-ust-tracepoint.so.0 and essentially no-op if it can’t
find it. However, I’ve noticed that the executable still has a static dependency on liblttng-ust.so.0 and liblttng-ust-tracepoint.so.0, I believe for registration. Is there any way to make these static dependencies dynamic as well so that if liblttng-ust
is not installed on an arbitrary machine, then the application still works but no tracing is possible?</span><span style="color:black"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Hi Brian,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Yes, lttng-ust can be used either with a probe provider as a static dependency<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">of the application, or entirely dynamically, in a use-case where you don't want<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">requiring to deploy lttng-ust on all systems, but keep building the application with<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">tracepoints.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Both ways of doing things are documented in the lttng-ust(3) man page. I think the<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">use-case you are describing fits in section<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">"BUILDING/LINKING THE TRACEPOINT PROVIDER<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">[...]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"> 2) Compile the Tracepoint Provider separately from the application,<br>
using dynamic linking:"<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">The key thing here is to split your tracepoint probe provider from your application<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">by building it into its own .so. Then, you can package the tracepoint probe provider<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">into an optional package, an "add-on" to your application. The static dependency<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">on lttng-ust is from the tracepoint probe provider, not the application tracepoints<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">per se.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Does it help ?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Mathieu<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks.</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Brian</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><span style="color:black"><o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Brian Robbins [<a href="mailto:brianrob@microsoft.com">mailto:brianrob@microsoft.com</a>]
<br>
<b>Sent:</b> Wednesday, August 19, 2015 1:15 PM<br>
<b>To:</b> Jérémie Galarneau <<a href="mailto:jeremie.galarneau@efficios.com">jeremie.galarneau@efficios.com</a>><br>
<b>Cc:</b> Rama Krishnan Raghupathy <<a href="mailto:ramarag@microsoft.com">ramarag@microsoft.com</a>>;
<a href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a><br>
<b>Subject:</b> Re: [lttng-dev] Instrumenting a Shared Object</span><span style="color:black"><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="color:black">Hi Jérémie,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black">Thank you very much. That helps a bunch. I think in general, we can make some guarantees around when tracepoints are no-longer called, so we should just be able to dlclose liblttng-ust after that point.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black">Mathieu – if you have any additional advice, that would be great.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black">Thank you much.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black">-Brian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">
<a href="mailto:jeremie.galarneau@gmail.com" target="_blank">jeremie.galarneau@gmail.com</a> [<a href="mailto:jeremie.galarneau@gmail.com" target="_blank">mailto:jeremie.galarneau@gmail.com</a>]
<b>On Behalf Of </b>Jérémie Galarneau<br>
<b>Sent:</b> Monday, August 17, 2015 3:22 PM<br>
<b>To:</b> Brian Robbins <<a href="mailto:brianrob@microsoft.com" target="_blank">brianrob@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a>; Rama Krishnan Raghupathy <<a href="mailto:ramarag@microsoft.com" target="_blank">ramarag@microsoft.com</a>>; Mathieu Desnoyers <<a href="mailto:mathieu.desnoyers@efficios.com" target="_blank">mathieu.desnoyers@efficios.com</a>><br>
<b>Subject:</b> Re: [lttng-dev] Instrumenting a Shared Object</span><span style="color:black"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:black">Hi Brian,<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:black">Mathieu will probably weigh in on this shortly. In the meantime, here's my understanding of the problem.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">In order to produce a trace, you have to ensure both liblttng-ust and your provider(s) are linked into the application. That can be done either by LD_PRELOAD-ing, dynamically linking, or dlopen-ing() both. Not
linking against liblttng-ust will simply result in your application not producing a trace (since the application will never register to the session daemon), but will have no adverse effect.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">The real concern with dlclose-ing the providers is that you have to be entirely sure that no tracepoints will be triggered after the provider is unloaded/dlclose. There is no reference counting to ensure the provider
remains loaded as long as any probes remain reachable or any other mechanism of the sort. Therefore, triggering a tracepoint after the provider has been unloaded will result in a crash. Keep in mind that triggering tracepoints remains entirely safe if the
providers are never loaded. Only triggering after a dlopen/dlclose of providers may cause problems.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">If you can guarantee this doesn't happen, you should be pretty much good to go.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Regards,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Jérémie<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="color:black">On Thu, Aug 13, 2015 at 7:40 PM, Brian Robbins <<a href="mailto:brianrob@microsoft.com" target="_blank">brianrob@microsoft.com</a>> wrote:<o:p></o:p></span></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">Hello,<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">I’m looking to instrument a shared object using LTTng-UST tracepoints. The expectation is that users of the library will use dlopen to open it at the
beginning of their application and dlclose right before process exit. From what I’ve read at
</span><span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black"><a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flttng.org%2fdocs%2f%23doc-building-tracepoint-providers-and-user-application&data=01%7c01%7cbrianrob%40microsoft.com%7c3ae11714ef9b4072f3ee08d2a75249b9%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=YO4WlsmA6UBLU%2fvAmnn6JL4S5JnsXWguw%2bXgkC2M9aI%3d" target="_blank">http://lttng.org/docs/#doc-building-tracepoint-providers-and-user-application</a></span><span style="color:black">,
it sounds like there is some complexity with this as the tracepoint definition must remain in memory, but I want to make sure I fully understand.<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">If I want to instrument a shared object, is my only option to dynamically link and use LD_PRELOAD? Also, do my options change if I know that the process
will exit right after it calls dlclose on the library?<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">Thank you very much.<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888">-Brian</span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888"> </span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888"> </span><span style="color:black"><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="color:black"><br>
_______________________________________________<br>
lttng-dev mailing list<br>
<a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a><br>
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.lttng.org%2fcgi-bin%2fmailman%2flistinfo%2flttng-dev&data=01%7c01%7cbrianrob%40microsoft.com%7c3ae11714ef9b4072f3ee08d2a75249b9%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=kvzDR%2b%2bP1EKVMNduwrayFrWR2zqBlH8OF71zm0sA8eQ%3d" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><o:p></o:p></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span style="color:black"><br>
<br clear="all">
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black">-- <o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:black">Jérémie Galarneau<br>
EfficiOS Inc.<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fwww.efficios.com&data=01%7c01%7cbrianrob%40microsoft.com%7c3ae11714ef9b4072f3ee08d2a75249b9%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=3a%2bQApyhm%2bk4UaN%2fn1a0f8SS%2bn6e0Nq4B2YJGqgkpzs%3d" target="_blank">http://www.efficios.com</a><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif;color:black"><br>
_______________________________________________<br>
lttng-dev mailing list<br>
<a href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a><br>
<a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><o:p></o:p></span></p>
</blockquote>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">-- <o:p>
</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black">Mathieu Desnoyers<br>
EfficiOS Inc.<br>
<a href="http://www.efficios.com">http://www.efficios.com</a><o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>