[poky] Odd log messages for apps using autotools and __FILE__

Holger Freyther holger at freyther.de
Mon Aug 10 00:04:43 PDT 2015


> On 08 Aug 2015, at 21:19, Khem Raj <raj.khem at gmail.com> wrote:
> 

>>> I know I can use __BASE_FILE__ in gcc to get back to install.c
> 
> __BASE_FILE__ is a gnu extension, just be aware of that if you target portability

Yes, that is mentioned in the GNU GCC documentation.


> __FILE__ is one of standard pre-processing macros that are computed by cpp and its supposed to contain the path and name by which cpp opens the current input file and naturally when B != S then you are referring to source file more commonly with absolute path, one could use relative paths  w.r.t build dir but thats up to components build system and may not be even possible in all cases. I don’t think there is any thing to fix there in compiler unless we want to violate the standard. .debug rewrite might be a different thing someone tried a stab at it see
> https://sourceware.org/ml/gdb-patches/2011-06/msg00385.html but didn’t move very far since there were alternative ways.

yes, but this leads to unreadable and huge log messages in many applications.
E.g. all invocations that do something like:


file.c:
	debug(__FILE__, __LINE__, “My message %d”, 23);

turns into

/home/hfreyther/poky/fido/build/tmp/work/armv5te-poky-musl/my-app/r0/git/src/component/file.c:2 My message 23

From my point of view this creates a usability issue for the developers. When I looked
at my BTS log. I couldn’t see the actual log messages (line wrapping, majority of output
being the path). Now it obvious that Poky is the first mainstream distribution to compile
with B!=S but is there a plan in regard to log messages? Migrate to use __BASE_FILE__?
Use __FILE__ but wrap it with strstr? Or is the situation okay enough?

kins regards
	holger


More information about the poky mailing list