This question already has an answer here:
Our project just started to use the -Og flag when compiling the software in debug mode vs. the -g3 flag.
man GCC says:
"-Og Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience."
The problem is any variable that is set by a inline call is "optimized out" so you can't do "break if" commands using the variable or print the variable until either is is reset by something (that is not an inline function) or until the variable is passed up or down into a new function (you can then see the value, etc.) I have read the GCC man page, but I don't see anything about this problem or how to fix it beyond going back to the -g3 flag for debugging and don't use the -Og flag. So is there someway to use -Og and still be able to see the variable after it is set by inline?
The compiler is gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) for RH 7.3 OS and we are using ddd as the GUI.
This is an example of non - inline where the pid is optimized out:
C unit getting pid to check.
pid = et->printPid(); <= optimized out, can't set break if using pid
if( pid > 0 ) <= optimized out, can do a break if
{
pid = waitpid( pid, &status, WNOHANG ); <= now you can "see" the pid setting and add break if
if( pid == -1 )
FuEvEventTable.h
pid_t printPid() { return( myPrintPid ); }
If printPid was a inline (which is want normally we do to return or set variables in a class) the same thing happens, so { return( myPrintPid ); } style might be the problem.