Hi -<div><br></div><div>Sorry for the delayed response. Very busy few days. You need to specify on the command line the name of the symbol you want to trace. I&#39;m actually not sure if -c works with libdl symbols, but I THINK it does. Please let me know. If not, I can fix it.</div>
<div><br></div><div>You name the symbol on the command line with -x, so for example I usually use ltrace like this:</div><div><br></div><div>ltrace -ttTgx functionB -x functionC -x functionD</div><div><br></div><div>tt - prefix line with time of day in microsecs</div>
<div>T - amount of time spent in the call</div><div>g - an option I added to tell ltrace NOT to trace libc -- tracing libc can be noisy and annoying</div><div>x - the symbol name I want to trace</div><div><br></div><div>x will look for the symbol name in the binary and all currently linked libraries (i.e. if you ltrace attached after dlsym, it&#39;ll pick it up just fine) and if nothing is found it&#39;ll listen and attach when the symbol is dlsym&#39;d later (i.e. if you start your application with ltrace and dlsym hasnt happened yet).</div>
<div><br></div><div>let me know if it works for you --</div><div>joe</div><meta charset="utf-8"><div><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 1:13 PM, Rodrigo Dominguez <span dir="ltr">&lt;<a href="mailto:roddomi@hotmail.com">roddomi@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



<div>
Joe,<br>
<br>
Option 2 below compiles on my system. However, I am not sure I am
getting the libdl features you added. I wrote a small test program that
uses dlopen to load a library file  I created (libB.so):<br>
<br>
#include &lt;dlfcn.h&gt;<br>
<br>
int main(void)<br>
{<br>
    void *handle;<br>
    int (*myFunctionB)(void);<br>
<br>
    handle = dlopen(&quot;./libB.so&quot;, RTLD_LAZY);<br>
    myFunctionB = dlsym(handle, &quot;functionB&quot;);<br>
    (*myFunctionB)();<br>
<br>
    return 0;<br>
}<br>
<br>Neither the system ltrace nor your ltrace show the call to functionB. This is the output:<br>
<br>
$ ltrace -c ./a.out<br>
Inside libB::functionB<br>
% time     seconds  usecs/call     calls      function<br>
------ ----------- ----------- --------- --------------------<br>
 99.36    0.003254        3254         1 dlopen<br>
  0.64    0.000021          21         1 dlsym<br>
------ ----------- ----------- --------- --------------------<br>
100.00    0.003275                     2 total<br>
<br>
Am I missing something? Or am I misunderstanding the libdl support you added?<br>
<br>
Thank you.<br><br><hr>Date: Tue, 30 Mar 2010 11:53:02 -0700<div class="im"><br>Subject: Re: [Ltrace-devel] Tracing dependent libraries<br></div>From: <a href="mailto:ice799@gmail.com" target="_blank">ice799@gmail.com</a><br>
To: <a href="mailto:roddomi@hotmail.com" target="_blank">roddomi@hotmail.com</a>; <a href="mailto:ltrace-devel@lists.alioth.debian.org" target="_blank">ltrace-devel@lists.alioth.debian.org</a><div><div></div><div class="h5">
<br><br>Replying to this on-list just incase other people have this problem.<div><br></div><div>Not sure if I ever submit this patch back to the list, but I added support for backtraces so you can see the function call stack for traced functions.</div>

<div><br></div><div>The problem with this feature is that I didn&#39;t take the time to fix the configure script so that it would disable that code if you don&#39;t have libunwind on your system.</div><div><br></div><div>

There are two solutions:</div><div><br></div><div>1.) The simplest solution (until I or some one else fixes the configure script) is to install libunwind library and header files on your system and try building my branch again.</div>

<div><br></div><div>or</div><div><br></div><div>2.) Rewind the source tree in git to before that commit was made. To do this you can just: git checkout a95f1 -b before_unwind</div><div><br></div><div>That will create a local branch called &quot;before_unwind&quot; (the first byte of the sha before the libunwind commit are a95f1).</div>

<div><br></div><div>The downside is that if you do this you lose some of the man page cleanup and a small bugfix.</div><div><br></div><div>Sorry for the pain.</div><div><br></div><div>joe</div><div><br><div>
On Tue, Mar 30, 2010 at 11:11 AM, Rodrigo Dominguez <span dir="ltr">&lt;<a href="mailto:roddomi@hotmail.com" target="_blank">roddomi@hotmail.com</a>&gt;</span> wrote:<br><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex">











<div lang="EN-US">

<div>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">Thanks. I was able to checkout your code.</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">I am getting the following errors after ‘./configure
&amp;&amp; make’</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">make -C sysdeps/linux-gnu</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">make[1]: Entering directory
`/home/rdomingu/ltrace/sysdeps/linux-gnu&#39;</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">gcc -Wall -g -O2 -iquote /home/rdomingu/ltrace -iquote
/home/rdomingu/ltrace/sysdeps/linux-gnu
-DSYSCONFDIR=\&quot;/usr/local/etc\&quot;  -I /usr/include/libelf
-I/home/rdomingu/ltrace/sysdeps/linux-gnu/x86_64  -c -o events.o events.c</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">In file included from events.c:12:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/common.h:1:23: error: libunwind.h: No such
file or directory</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">In file included from /home/rdomingu/ltrace/common.h:11,</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">                
from events.c:12:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/elf.h:4:18: error: gelf.h: No such file or
directory</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">In file included from /home/rdomingu/ltrace/common.h:11,</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">                
from events.c:12:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/elf.h:9: error: expected
specifier-qualifier-list before âElfâ</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/elf.h:50: error: expected â=â,
â,â, â;â, âasmâ or â__attribute__â
before âarch_plt_sym_valâ</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">In file included from events.c:12:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/common.h:193: error: expected
specifier-qualifier-list before âunw_addr_space_tâ</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">In file included from events.c:12:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/common.h:234: error: expected declaration
specifiers or â...â before âGElf_Symâ</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">/home/rdomingu/ltrace/common.h:236: error: expected
â)â before âaddrâ</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">make[1]: *** [events.o] Error 1</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">make[1]: Leaving directory
`/home/rdomingu/ltrace/sysdeps/linux-gnu&#39;</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">make: *** [sysdeps/sysdep.o] Error 2</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<div style="border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt">

<div>

<div style="border-style:solid none none;border-color:rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;border-width:1pt medium medium;padding:3pt 0in 0in">

<p><b><span style="font-size:10pt">From:</span></b><span style="font-size:10pt"> Joe Damato
[mailto:<a href="mailto:ice799@gmail.com" target="_blank">ice799@gmail.com</a>] <br>
<b>Sent:</b> Tuesday, March 30, 2010 1:12 PM</span></p><div><div></div><div><br>
<b>To:</b> Rodrigo Dominguez<br>
<b>Cc:</b> <a href="mailto:ltrace-devel@lists.alioth.debian.org" target="_blank">ltrace-devel@lists.alioth.debian.org</a><br>
<b>Subject:</b> Re: [Ltrace-devel] Tracing dependent libraries</div></div><br>

</div>

</div><div><div></div><div>

<p> </p>

<p>Not a dumb question at all. My code isn&#39;t part of the
official repository, but it is on github at: git://<a href="http://github.com/ice799/ltrace.git" target="_blank">github.com/ice799/ltrace.git</a>
</p>

<div>

<p> </p>

</div>

<div>

<p>My code is in the branch &quot;libdl&quot;</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>So you should:</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>git clone git://<a href="http://github.com/ice799/ltrace.git" target="_blank">github.com/ice799/ltrace.git</a></p>

</div>

<div>

<p>git checkout -b libdl origin/libdl</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>and you will be sitting in the libdl branch.</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>You can take a look at the commits on that branch by doing
git log. If a particular commit interests you, you can git show &lt;sha&gt; to
look at the diff.</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>If you have any other questions/issues getting my code or
getting it to build feel free to email me off list.</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>joe</p>

</div>

<div>

<p> </p>

<div>

<p>On Tue, Mar 30, 2010 at 9:35 AM, Rodrigo Dominguez &lt;<a href="mailto:roddomi@hotmail.com" target="_blank">roddomi@hotmail.com</a>&gt;
wrote:</p>

<div>

<div>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">Joe,</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">I am sorry for the dumb question but how
do you checkout a branch from github. I am not familiar with git. I ran:</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">git clone git://<a href="http://git.debian.org/git/collab-maint/ltrace.git" target="_blank">git.debian.org/git/collab-maint/ltrace.git</a></span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">but this only gets me the master branch.</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)">Thank you.</span></p>

<p><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>

<div style="border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;border-width:medium medium medium 1.5pt;padding:0in 0in 0in 4pt">

<div>

<div style="border-style:solid none none;border-color:rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;border-width:1pt medium medium;padding:3pt 0in 0in">

<p><b><span style="font-size:10pt">From:</span></b><span style="font-size:10pt"> Joe
Damato [mailto:<a href="mailto:ice799@gmail.com" target="_blank">ice799@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, March 09, 2010 5:20 PM<br>
<b>To:</b> Rodrigo Dominguez<br>
<b>Cc:</b> <a href="mailto:ltrace-devel@lists.alioth.debian.org" target="_blank">ltrace-devel@lists.alioth.debian.org</a><br>
<b>Subject:</b> Re: [Ltrace-devel] Tracing dependent libraries</span></p>

</div>

</div>

<div>

<div>

<p> </p>

<p style="margin-bottom:12pt">I
implemented support for libdl and you can get that tree from github: <a href="http://github.com/ice799/ltrace/tree/libdl" target="_blank">http://github.com/ice799/ltrace/tree/libdl</a></p>

<div>

<p>I
have *not* implemented tracing calls from libraries to other libraries, though.
doing that should be pretty straightforward. i don&#39;t really have the cycles
right now to implement that in the near term but I am willing to point people
in the right direction if they are interested in implementing it.</p>

</div>

<div>

<p> </p>

</div>

<div>

<p>otherwise
as soon as i have time to do it (probably later this month), i can implement it.</p>

<div>

<p> </p>

</div>

<div>

<p>joe </p>

<div>

<p> </p>

</div>

<div>

<p>On
Tue, Mar 9, 2010 at 2:13 PM, Rodrigo Dominguez &lt;<a href="mailto:roddomi@hotmail.com" target="_blank">roddomi@hotmail.com</a>&gt;
wrote:</p>

<p>How
can I get ltrace to trace dependent libraries (libraries called from<br>
within libraries)? All I was able to find was this old post:<br>
<br>
<a href="http://sourceware.org/ml/binutils/2006-09/msg00009.html" target="_blank">http://sourceware.org/ml/binutils/2006-09/msg00009.html</a><br>
<br>
Has this been implemented since then?<br>
<br>
Thank you.<br>
<br>
<br>
_______________________________________________<br>
Ltrace-devel mailing list<br>
<a href="mailto:Ltrace-devel@lists.alioth.debian.org" target="_blank">Ltrace-devel@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel" target="_blank">http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel</a></p>

</div>

<p> </p>

</div>

</div>

</div>

</div>

</div>

</div>

</div>

</div>

<p> </p>

</div>

</div></div></div>

</div>

</div>


</blockquote></div><br></div>                                               </div></div></div>
</blockquote></div><br></div>