How to get rid of <optimized output>?
-
I cannot find from the forum, any clue, how to get ride of mentions as <optimized output> appearing in the Debugger pane as "value"s for certain variables.
(It's apparently related to the clang optimization level set for compilation).Which (and where) to put some adequate directive in my xxx.pro file?
-
I cannot find from the forum, any clue, how to get ride of mentions as <optimized output> appearing in the Debugger pane as "value"s for certain variables.
(It's apparently related to the clang optimization level set for compilation).Which (and where) to put some adequate directive in my xxx.pro file?
-
I cannot find from the forum, any clue, how to get ride of mentions as <optimized output> appearing in the Debugger pane as "value"s for certain variables.
(It's apparently related to the clang optimization level set for compilation).Which (and where) to put some adequate directive in my xxx.pro file?
@JMLA said in How to get rid of <optimized output>?:
I cannot find from the forum, any clue, how to get ride of mentions as <optimized output> appearing in the Debugger pane as "value"s for certain variables.
(It's apparently related to the clang optimization level set for compilation).I've also seen this for gcc debug builds. Therefore I think it's more related to the fact the variable is not yet (or not any more) available.
-
@jsulm I amusing Qt 5.6.2 clang 64 bits and QtCreator 4.4.1; I am launching the debugger from the left panel as I used to do for years.
<output optmization> appears as "value" of almost all variables when the program hits a breakpoint :
@JMLA "I am launching the debugger from the left panel as I used to do for years" - that is clear, what I wanted to know was whether you built your project in debug mode (from the screen-shot I can see that you did).
OK, you are at line 412. Many of the <optimized out> variables are defined later I guess. For example "first" - it is initialized and exists inside the for loop. Don't know about all the other variables as I cannot see where those are defined. -
@JMLA "I am launching the debugger from the left panel as I used to do for years" - that is clear, what I wanted to know was whether you built your project in debug mode (from the screen-shot I can see that you did).
OK, you are at line 412. Many of the <optimized out> variables are defined later I guess. For example "first" - it is initialized and exists inside the for loop. Don't know about all the other variables as I cannot see where those are defined.@jsulm Many thanks for you interest. I am attaching this time a more explicit screenshot.
Look e.g. at line 416 in a loop governed by i (currently i=0) where a point structure pt is declared (with just 2 fields x and y initialised at (0,0). Pogramm Counter is at line 434 after affectation of pt.x with value -1.
In the debugger pane i is displayed as an <optimzed value>. I supposed the next line i@1 means the i has 0 as actual value. I do not know what i@2 is supposed to be.
Lower pt shows as an <optimized output> but , surprisingly to me, 2 lines lower one have a line pt@2 showing (?) that pt.x has just received -1 as a new value).
Some variables get additional debugger lines (with their names followed by some @n), some others do not (like nb_points).
Thank you so much for any idea to help in solving my issue!
-
@jsulm Many thanks for you interest. I am attaching this time a more explicit screenshot.
Look e.g. at line 416 in a loop governed by i (currently i=0) where a point structure pt is declared (with just 2 fields x and y initialised at (0,0). Pogramm Counter is at line 434 after affectation of pt.x with value -1.
In the debugger pane i is displayed as an <optimzed value>. I supposed the next line i@1 means the i has 0 as actual value. I do not know what i@2 is supposed to be.
Lower pt shows as an <optimized output> but , surprisingly to me, 2 lines lower one have a line pt@2 showing (?) that pt.x has just received -1 as a new value).
Some variables get additional debugger lines (with their names followed by some @n), some others do not (like nb_points).
Thank you so much for any idea to help in solving my issue!
@JMLA
I know nothing aboutclang
or QT Creator or whatever. But I do know aboutgcc
. At least check the-g
&-O...
being passed to the compiler. For example:GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally be surprising: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values are already at hand; some statements may execute in different places because they have been moved out of loops. Nevertheless it is possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs. If you are not using some other optimization option, consider using -Og with -g. With no -O option at all, some compiler passes that collect information useful for debugging do not run at all, so that -Og may result in a better debugging experience.
-
@JMLA said in How to get rid of <optimized output>?:
In the debugger pane i is displayed as an <optimzed value>. I supposed the next line i@1 means the i has 0 as actual value. I do not know what i@2 is supposed to be.
Lower pt shows as an <optimized output> but , surprisingly to me, 2 lines lower one have a line pt@2 showing (?) that pt.x has just received -1 as a new value).
Some variables get additional debugger lines (with their names followed by some @n), some others do not (like nb_points).The pt@1 just means that there are multiple variables named pt in the function, defined in different scopes.
E.g.
int i = 42; // here is your outer i for (int i = 0; i < 10; ++i) { // Within the loop, i is redefined and goes from 0 to 10 // The debugger shows this as i@1 } // Here you have your outer i again
If you have a variable pt@2 that means you have in fact three variables named pt!
Regards