[lttng-dev] Addition of the return address toliblttng-ust-libc-wrapper

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Jan 19 11:48:44 EST 2015


----- Original Message -----

> From: "Olivier Delbeke" <Olivier.Delbeke at awtce.be>
> To: "Mathieu Desnoyers" <mathieu.desnoyers at efficios.com>
> Sent: Monday, January 19, 2015 2:03:07 AM
> Subject: Re: [lttng-dev] Addition of the return address
> toliblttng-ust-libc-wrapper

> Hi Mathieu,

> Here is the patch you asked me : (See attached file:
> lttng-return-address.patch)

> First , I named the variable for return address "ra", then changed it to
> "caller". Of course, you're free to change it (to make it more clear or more
> in line with the rest of your code).
Great! 

Can I add your Signed-off-by tag to the patch header ? 

Thanks, 

Mathieu 

> Best regards,

> 

> Olivier Delbeke Senior Software Engineer Olivier.Delbeke at awtce.be / T. +32 2
> 389 25 53 AWTC Europe S.A. - Avenue de l’Industrie, 19 - 1420
> Braine-l’Alleud - Belgium - www.aweurope.eu - www.aisin-aw.co.jp VAT : BE
> 0474.474.114 - RPM Nivelles

> Mathieu Desnoyers ---01/16/2015 09:41:08 PM---Mathieu Desnoyers
> <mathieu.desnoyers at efficios.com>

> Mathieu Desnoyers <mathieu.desnoyers at efficios.com>

> 01/16/2015 09:41 PM
> To
> 

> Olivier Delbeke <Olivier.Delbeke at awtce.be>

> cc
> 

> lttng-dev at lists.lttng.org

> Subject
> 

> Re: [lttng-dev] Addition of the return address to liblttng-ust-libc-wrapper
> ----- Original Message -----

> From: "Olivier Delbeke" <Olivier.Delbeke at awtce.be> To:
> lttng-dev at lists.lttng.org Sent: Tuesday, January 13, 2015 10:50:38 AM
> Subject: [lttng-dev] Addition of the return address to
> liblttng-ust-libc-wrapper

> Hi guys,

> I am using liblttng-ust-libc-wrapper to detect memory leaks in my
> applications. 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. Was this the right
> thing to do ? If it is, then I guess that it might interest other people
> too.
> After further thought, I'm interested to merge this into UST master.

> Can you re-send either as an attachment, or as plain text without the
> base64 encoding ?

> Thanks!

> Mathieu

> diff -Nurd b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c
> c/liblttng-ust-libc-wrapper/lttng-ust-malloc.c ---
> b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c 2015-01-06 17:14:34.000000000
> +0100 +++ c/liblttng-ust-libc-wrapper/lttng-ust-malloc.c 2015-01-06
> 17:16:40.811145106 +0100 @@ -260,7 +260,7 @@ } retval =
> cur_alloc.malloc(size); if (URCU_TLS(malloc_nesting) == 1) { -
> tracepoint(ust_libc, malloc, size, retval); + tracepoint(ust_libc, malloc,
> size, retval, __builtin_return_address(0) ); } URCU_TLS(malloc_nesting)--;
> return retval; @@ -279,7 +279,7 @@ } if (URCU_TLS(malloc_nesting) == 1) { -
> tracepoint(ust_libc, free, ptr); + tracepoint(ust_libc, free, ptr,
> __builtin_return_address(0) ); } if (cur_alloc.free == NULL) { @@ -308,7
> +308,7 @@ } retval = cur_alloc.calloc(nmemb, size); if
> (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, calloc, nmemb,
> size, retval); + tracepoint(ust_libc, calloc, nmemb, size, retval,
> __builtin_return_address(0) ); } URCU_TLS(malloc_nesting)--; return retval;
> @@ -360,7 +360,7 @@ retval = cur_alloc.realloc(ptr, size); end: if
> (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, realloc, ptr, size,
> retval); + tracepoint(ust_libc, realloc, ptr, size, retval,
> __builtin_return_address(0) ); } URCU_TLS(malloc_nesting)--; return retval;
> @@ -380,7 +380,7 @@ } retval = cur_alloc.memalign(alignment, size); if
> (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, memalign,
> alignment, size, retval); + tracepoint(ust_libc, memalign, alignment, size,
> retval, __builtin_return_address(0) ); } URCU_TLS(malloc_nesting)--; return
> retval; @@ -401,7 +401,7 @@ retval = cur_alloc.posix_memalign(memptr,
> alignment, size); if (URCU_TLS(malloc_nesting) == 1) { tracepoint(ust_libc,
> posix_memalign, *memptr, alignment, size, - retval); + retval,
> __builtin_return_address(0) ); } URCU_TLS(malloc_nesting)--; return retval;
> diff -Nurd b/liblttng-ust-libc-wrapper/ust_libc.h
> c/liblttng-ust-libc-wrapper/ust_libc.h ---
> b/liblttng-ust-libc-wrapper/ust_libc.h 2015-01-06 17:14:34.000000000 +0100
> +++ c/liblttng-ust-libc-wrapper/ust_libc.h 2015-01-06 17:16:40.811145106
> +0100 @@ -33,54 +33,60 @@ #include <lttng/tracepoint.h>
> TRACEPOINT_EVENT(ust_libc, malloc, - TP_ARGS(size_t, size, void *, ptr), +
> TP_ARGS(size_t, size, void *, ptr, void *, ra), TP_FIELDS(
> ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) +
> ctf_integer_hex(void *, ra, ra) ) ) TRACEPOINT_EVENT(ust_libc, free, -
> TP_ARGS(void *, ptr), + TP_ARGS(void *, ptr, void *, ra), TP_FIELDS(
> ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, ra, ra) ) )
> TRACEPOINT_EVENT(ust_libc, calloc, - TP_ARGS(size_t, nmemb, size_t, size,
> void *, ptr), + TP_ARGS(size_t, nmemb, size_t, size, void *, ptr, void *,
> ra), TP_FIELDS( ctf_integer(size_t, nmemb, nmemb) ctf_integer(size_t, size,
> size) ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, ra, ra) )
> ) TRACEPOINT_EVENT(ust_libc, realloc, - TP_ARGS(void *, in_ptr, size_t,
> size, void *, ptr), + TP_ARGS(void *, in_ptr, size_t, size, void *, ptr,
> void *, ra), TP_FIELDS( ctf_integer_hex(void *, in_ptr, in_ptr)
> ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) +
> ctf_integer_hex(void *, ra, ra) ) ) TRACEPOINT_EVENT(ust_libc, memalign, -
> TP_ARGS(size_t, alignment, size_t, size, void *, ptr), + TP_ARGS(size_t,
> alignment, size_t, size, void *, ptr, void *, ra), TP_FIELDS(
> ctf_integer(size_t, alignment, alignment) ctf_integer(size_t, size, size)
> ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, ra, ra) ) )
> TRACEPOINT_EVENT(ust_libc, posix_memalign, - TP_ARGS(void *, out_ptr,
> size_t, alignment, size_t, size, int, result), + TP_ARGS(void *, out_ptr,
> size_t, alignment, size_t, size, int, result, void *, ra), TP_FIELDS(
> ctf_integer_hex(void *, out_ptr, out_ptr) ctf_integer(size_t, alignment,
> alignment) ctf_integer(size_t, size, size) ctf_integer(int, result, result)
> + ctf_integer_hex(void *, ra, ra) ) ) Best regards,
> 

> Olivier Delbeke Senior Software Engineer Olivier.Delbeke at awtce.be / T. +32 2
> 389 25 53 AWTC Europe S.A. - Avenue de l’Industrie, 19 - 1420
> Braine-l’Alleud - Belgium - www.aweurope.eu - www.aisin-aw.co.jp VAT : BE
> 0474.474.114 - RPM Nivelles 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 postmaster at aweurope.be, and permanently destroy
> the original as well as any copy thereof.
> _______________________________________________ lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
> (See attached file: 1E482660.jpg) (See attached file: ecblank.gif)
> 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
> postmaster at aweurope.be, and permanently destroy the original as well as any
> copy thereof.
-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150119/14ca61d4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1D220451.jpg
Type: image/jpeg
Size: 9458 bytes
Desc: not available
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150119/14ca61d4/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150119/14ca61d4/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150119/14ca61d4/attachment-0003.gif>


More information about the lttng-dev mailing list