<div dir="ltr"><div><div><div><div>Hi,<br><br></div>The first thing I tried was indeed to add "ip" to the context, and the result was always the same (the location of the tracepoint macro call (useless in this case)). <br><br></div>I will send the patch on Monday. Thanks a lot.<br><br></div>Best regards,<br></div>Olivier<br>
</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 9:41 PM, Mathieu Desnoyers <span dir="ltr"><<a href="mailto:mathieu.desnoyers@efficios.com" target="_blank">mathieu.desnoyers@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><hr><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"><span class=""><b>From: </b>"Olivier Delbeke" <<a href="mailto:Olivier.Delbeke@awtce.be" target="_blank">Olivier.Delbeke@awtce.be</a>><br><b>To: </b><a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a><br><b>Sent: </b>Tuesday, January 13, 2015 10:50:38 AM<br><b>Subject: </b>[lttng-dev] Addition of the return address to        liblttng-ust-libc-wrapper<br><div><br></div></span><span class=""><p><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">Hi guys,</span><br></p><div><br></div><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">I am using liblttng-ust-libc-wrapper to detect memory leaks in my applications. </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">In order to identify not only the thread where the unfreed allocations are done, but also the calling function, I extended the liblttng-ust-libc-wrapper to log the "return address" (__builtin_return_address(0)) in addition to the parameters of malloc(). It solves my problem and does not affect Trace Compass.</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">Was this the right thing to do ? </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">If it is, then I guess that it might interest other people too.</span></span></blockquote><div>After further thought, I'm interested to merge this into UST master.<br></div><div><br></div><div>Can you re-send either as an attachment, or as plain text without the<br></div><div>base64 encoding ?<br></div><div><br></div><div>Thanks!<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Mathieu<br></div><div><br></div><div><br></div></font></span><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><div class="h5"><div><br></div><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">diff -Nurd b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c c/liblttng-ust-libc-wrapper/lttng-ust-malloc.c</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">--- b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c        2015-01-06 17:14:34.000000000 +0100</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+++ c/liblttng-ust-libc-wrapper/lttng-ust-malloc.c        2015-01-06 17:16:40.811145106 +0100</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -260,7 +260,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         retval = cur_alloc.malloc(size);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                tracepoint(ust_libc, malloc, size, retval);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                tracepoint(ust_libc, malloc, size, retval, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         URCU_TLS(malloc_nesting)--;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         return retval;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -279,7 +279,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                tracepoint(ust_libc, free, ptr);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                tracepoint(ust_libc, free, ptr, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (cur_alloc.free == NULL) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -308,7 +308,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         retval = cur_alloc.calloc(nmemb, size);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                tracepoint(ust_libc, calloc, nmemb, size, retval);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                tracepoint(ust_libc, calloc, nmemb, size, retval, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         URCU_TLS(malloc_nesting)--;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         return retval;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -360,7 +360,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         retval = cur_alloc.realloc(ptr, size);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> end:</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                tracepoint(ust_libc, realloc, ptr, size, retval);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                tracepoint(ust_libc, realloc, ptr, size, retval, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         URCU_TLS(malloc_nesting)--;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         return retval;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -380,7 +380,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         retval = cur_alloc.memalign(alignment, size);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                tracepoint(ust_libc, memalign, alignment, size, retval);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                tracepoint(ust_libc, memalign, alignment, size, retval, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         URCU_TLS(malloc_nesting)--;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         return retval;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -401,7 +401,7 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         retval = cur_alloc.posix_memalign(memptr, alignment, size);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         if (URCU_TLS(malloc_nesting) == 1) {</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 tracepoint(ust_libc, posix_memalign, *memptr, alignment, size,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-                        retval);</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                        retval, __builtin_return_address(0) );</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         }</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         URCU_TLS(malloc_nesting)--;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         return retval;</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">diff -Nurd b/liblttng-ust-libc-wrapper/ust_libc.h c/liblttng-ust-libc-wrapper/ust_libc.h</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">--- b/liblttng-ust-libc-wrapper/ust_libc.h        2015-01-06 17:14:34.000000000 +0100</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+++ c/liblttng-ust-libc-wrapper/ust_libc.h        2015-01-06 17:16:40.811145106 +0100</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">@@ -33,54 +33,60 @@</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> #include <lttng/tracepoint.h></span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, malloc,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(size_t, size, void *, ptr),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(size_t, size, void *, ptr, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, size, size)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, ptr, ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, free,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(void *, ptr),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(void *, ptr, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, ptr, ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, calloc,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(size_t, nmemb, size_t, size, void *, ptr),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(size_t, nmemb, size_t, size, void *, ptr, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, nmemb, nmemb)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, size, size)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, ptr, ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, realloc,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(void *, in_ptr, size_t, size, void *, ptr),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(void *, in_ptr, size_t, size, void *, ptr, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, in_ptr, in_ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, size, size)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, ptr, ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, memalign,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(size_t, alignment, size_t, size, void *, ptr),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(size_t, alignment, size_t, size, void *, ptr, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, alignment, alignment)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, size, size)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, ptr, ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> TRACEPOINT_EVENT(ust_libc, posix_memalign,</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">-        TP_ARGS(void *, out_ptr, size_t, alignment, size_t, size, int, result),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+        TP_ARGS(void *, out_ptr, size_t, alignment, size_t, size, int, result, void *, ra),</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         TP_FIELDS(</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer_hex(void *, out_ptr, out_ptr)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, alignment, alignment)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(size_t, size, size)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">                 ctf_integer(int, result, result)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">+                ctf_integer_hex(void *, ra, ra)</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">         )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> )</span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2"> </span><br><span style="font-family:sans-serif;font-size:small" face="sans-serif" size="2">Best regards,</span><table border="0" cellpadding="0" cellspacing="0"><tbody><tr valign="top"><td rowspan="2" valign="middle" width="108"><div align="center"><img src="cid:1__=4EBBF75FDFC078EC8f9e8a93df93@aweurope.be" width="107" height="98" align="bottom"></div></td><td width="788"><img src="cid:2__=4EBBF75FDFC078EC8f9e8a93df93@aweurope.be" alt="" width="1" height="1" border="0"></td></tr><tr valign="top"><td valign="middle" width="788"><ul style="padding-left:0pt"><span style="color:#000080;font-family:Calibri;font-size:medium" face="Calibri" color="#000080" size="3"><b>Olivier Delbeke </b></span><span style="color:#000080;font-family:Calibri;font-size:medium" face="Calibri" color="#000080" size="3"><i>Senior Software Engineer</i></span><span style="color:#565051;font-family:Calibri;font-size:medium" face="Calibri" color="#565051" size="3"><br><a href="mailto:Olivier.Delbeke@awtce.be" target="_blank">Olivier.Delbeke@awtce.be</a> / T. <a href="tel:%2B32%202%20389%2025%2053" value="+3223892553" target="_blank">+32 2 389 25 53</a></span><hr style="color:#333399" noshade size="2" width="100%" align="left"><span style="font-family:serif;font-size:medium" face="serif" size="3"> </span><span style="color:#000080;font-family:Calibri;font-size:xx-small" face="Calibri" color="#000080" size="1"><b>AWTC Europe S.A. </b></span><span style="color:#565051;font-family:Calibri;font-size:xx-small" face="Calibri" color="#565051" size="1">- Avenue de l’Industrie, 19 - 1420 Braine-l’Alleud - Belgium - <a href="http://www.aweurope.eu" target="_blank">www.aweurope.eu</a> - <a href="http://www.aisin-aw.co.jp" target="_blank">www.aisin-aw.co.jp</a><br>VAT : BE 0474.474.114 - RPM Nivelles</span><span style="font-family:serif;font-size:medium" face="serif" size="3"> </span></ul></td></tr></tbody></table><br><span style="font-family:sans-serif" face="sans-serif">


This mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information.  If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this mail and/or any file transmitted with it, is strictly prohibited and may be unlawful.  If you have received this mail by mistake, please immediately notify the sender as well as our mail administrator at <a href="mailto:postmaster@aweurope.be" target="_blank">postmaster@aweurope.be</a>, and permanently destroy the original as well as any copy thereof.
</span><br></div></div><span class="">_______________________________________________<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="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><br></span></blockquote><span class=""><div><br><br></div><div><br></div><div>-- <br></div><div><span name="x"></span>Mathieu Desnoyers<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a><span name="x"></span><br></div></span></div></div><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" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><br>
<br></blockquote></div><br></div>