Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get rid of <optimized output>?
QtWS25 Last Chance

How to get rid of <optimized output>?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 8.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JMLA
    wrote on last edited by
    #1

    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?

    jsulmJ JohanSoloJ 2 Replies Last reply
    0
    • J JMLA

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @JMLA Are you debugging a debug build or release build?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      0
      • J JMLA

        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?

        JohanSoloJ Offline
        JohanSoloJ Offline
        JohanSolo
        wrote on last edited by
        #3

        @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.

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply
        1
        • jsulmJ jsulm

          @JMLA Are you debugging a debug build or release build?

          J Offline
          J Offline
          JMLA
          wrote on last edited by
          #4

          @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.0_1516353078757_Capture d’écran 2018-01-19 à 10.07.31.png <output optmization> appears as "value" of almost all variables when the program hits a breakpoint :

          jsulmJ 1 Reply Last reply
          0
          • J JMLA

            @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.0_1516353078757_Capture d’écran 2018-01-19 à 10.07.31.png <output optmization> appears as "value" of almost all variables when the program hits a breakpoint :

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            J 1 Reply Last reply
            3
            • jsulmJ jsulm

              @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.

              J Offline
              J Offline
              JMLA
              wrote on last edited by
              #6

              @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!
              0_1516363279965_Opt_Outp2018-01-19 à 12 2.jpg

              JonBJ 1 Reply Last reply
              0
              • J JMLA

                @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!
                0_1516363279965_Opt_Outp2018-01-19 à 12 2.jpg

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @JMLA
                I know nothing about clang or QT Creator or whatever. But I do know about gcc. 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.
                
                1 Reply Last reply
                0
                • aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved