<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><span id="zwchr" data-marker="__DIVIDER__">----- On Sep 9, 2015, at 4:49 PM, Brian Robbins <brianrob@microsoft.com> wrote:<br></span></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><style><!--

@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;}

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-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><div class="WordSection1"><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></p></div></blockquote><div><br></div><div><div>Hi Brian,<br></div><div><br></div><div>Yes, lttng-ust can be used either with a probe provider as a static dependency</div><div>of the application, or entirely dynamically, in a use-case where you don't want</div><div>requiring to deploy lttng-ust on all systems, but keep building the application with</div><div>tracepoints.</div><div><br></div><div>Both ways of doing things are documented in the lttng-ust(3) man page. I think the</div><div>use-case you are describing fits in section</div><div><br data-mce-bogus="1"></div><div>"BUILDING/LINKING THE TRACEPOINT PROVIDER</div><div>[...]</div><div>         2) Compile the Tracepoint Provider separately from the application,<br>            using dynamic linking:"<br></div><div><br></div><div>The key thing here is to split your tracepoint probe provider from your application</div><div>by building it into its own .so. Then, you can package the tracepoint probe provider</div><div>into an optional package, an "add-on" to your application. The static dependency</div><div>on lttng-ust is from the tracepoint probe provider, not the application tracepoints</div><div>per se.</div><div><br></div><div>Does it help ?</div><div><br></div><div>Thanks,</div><div><br></div><div>Mathieu</div><div><br></div><div><br></div><span id="zwchr" data-marker="__DIVIDER__"></span></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks.</span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">-Brian</span></p><p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span></a><br data-mce-bogus="1"></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"> Brian Robbins [mailto:brianrob@microsoft.com]
<br>
<b>Sent:</b> Wednesday, August 19, 2015 1:15 PM<br>
<b>To:</b> Jérémie Galarneau <jeremie.galarneau@efficios.com><br>
<b>Cc:</b> Rama Krishnan Raghupathy <ramarag@microsoft.com>; lttng-dev@lists.lttng.org<br>
<b>Subject:</b> Re: [lttng-dev] Instrumenting a Shared Object</span></p></div></div><p class="MsoNormal">Hi Jérémie,</p><p class="MsoNormal">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.</p><p class="MsoNormal">Mathieu – if you have any additional advice, that would be great.</p><p class="MsoNormal">Thank you much.</p><p class="MsoNormal">-Brian</p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span></p><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">
<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></p><div><p class="MsoNormal">Hi Brian,</p><div><p class="MsoNormal">Mathieu will probably weigh in on this shortly. In the meantime, here's my understanding of the problem.</p></div><div><p class="MsoNormal">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.</p></div><div><p class="MsoNormal">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.</p></div><div><p class="MsoNormal">If you can guarantee this doesn't happen, you should be pretty much good to go.</p></div><div><p class="MsoNormal">Regards,</p></div><div><p class="MsoNormal">Jérémie</p></div></div><div><div><p class="MsoNormal">On Thu, Aug 13, 2015 at 7:40 PM, Brian Robbins <<a href="mailto:brianrob@microsoft.com" target="_blank">brianrob@microsoft.com</a>> wrote:</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">Hello,</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">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 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>,
 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.</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">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?</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thank you very much.</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888">-Brian</span></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888"> </span></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:#888888"> </span></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><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><br data-mce-bogus="1"></p></blockquote></div><p class="MsoNormal"><br><br clear="all"></p><p class="MsoNormal">-- </p><div><p class="MsoNormal">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><br data-mce-bogus="1"></p></div></div></div><br>_______________________________________________<br>lttng-dev mailing list<br>lttng-dev@lists.lttng.org<br>http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev<br></blockquote></div><div><br></div><div data-marker="__SIG_POST__">-- <br></div><div>Mathieu Desnoyers<br>EfficiOS Inc.<br>http://www.efficios.com</div></div></body></html>