[lttng-dev] tracepoint generation is fragile wrt macro expansion
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Mon Dec 17 15:54:40 EST 2012
* Sébastien Barthélémy (barthelemy at crans.org) wrote:
> Hello,
>
> please find attached a small patch which demonstrates the problem.
>
> The patch simply renames the test file ust_tests_hello.h into
> ust_tests-linux-hello.h. The build then fails on linux because the "linux"
> in
>
> #define TRACEPOINT_INCLUDE_FILE ./ust_tests-linux-hello.h
>
> gets expanded to "1", and it then tries to include ust_tests-1-hello.h.
Good point ! Here is the fix:
commit 41858e2b6e81ee5e02eccdd7467b9239d4cdf726
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Mon Dec 17 15:36:08 2012 -0500
Fix: don't do macro expansion in tracepoint file name
Change the API in a backward compatible way: previously, probe headers
would do e.g.
#define TRACEPOINT_INCLUDE_FILE ./ust_tests-linux-hello.h
but e.g. "linux" here would be expanded to "1", which is bad.
Fix this by allowing those headers to do:
#define TRACEPOINT_INCLUDE "./ust_tests-linux-hello.h"
instead. We still support the old TRACEPOINT_INCLUDE_FILE for backward
compatibility.
Reported-by: Sébastien Barthélémy <barthelemy at crans.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> I do not know if this can be fixed, hopefully you'll have a better idea.
>
> I came into the problem because I generate the tracepoint definition file
> (à la lttng-gen-tp) but define TRACEPOINT_INCLUDE_FILE to the full path of
> the generated file, which happens to be in the build directory, something
> like .../build-sys-linux-x86_64/..., So I'm more exposed.
>
> Maybe a possible solution would involve __FILE__?
Nope, unfortunately, __FILE__ always expands to the file in which
__FILE__ is located, not, e.g., the header referring to a macro
containing __FILE__.
Please let me know if the patch above works for you,
Thanks,
Mathieu
>
> Cheers
>
> -- Sébastien
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list