What is Expression Evaluator?



  • In debugmode in QT Creator - I can right-click a variable(in "Locals and Expressions") and choose "Add expression evaluator for [symbol/variable]". What is an Expression Evaluator and what can it be used for? I can't for the life of me find any documentation on this at all.



  • Did you try to type anything in and see what happens? This could give you a clue.

    You may type any expression using variable names from your program and QT Creator will compute the result value as it is at the current debugging stage and show it to you at the bottom of “Locals and Expressions” pane.

    It works but it was extremely slow for me, especially when it gets complex enough. I use it in an emergency only, and I clear it from the list as soon as I am done, since it will continue to slow QT Creator down when the active custom expressions keep being re-evaluated on each step of debugging.

    In my case it could take up to a few minutes to complete a debugging step, when I had a few expressions to evaluate active. QT Creator is not responsive during this time and could seem to be a dead. It comes back to normal speed if the additional expressions to be evaluated are cleared from the list.



  • Can it also be used to view elements in vectors/array?

    For example, I have a two dimensional vector that I access using nested for loops and I would like to be able to view each element as I step through the loops.

    vector<vector<int> > buffer;
    
    for (i=0 ; i<bufferWidth ; ++i)
        for (j=0 ; j<bufferHeight ; ++j)
            if (buffer[j][i] > 0)
               ...
    

    When I try to evaluate buffer[j][i] all I see is:
    buffer[j][i] int



  • Yes, it would also work for that (as usual, use a reasonably new version of gdb and switch off (!) Tools->Options->Debugger, GDB, "Load Systems Pretty Printers".

    On the other hand, you should not need to evaluate expressions for that, just expand the 'buffer' entry.



  • I'm currently using gdb 7.2-50.el6 on Red Hat Enterprise Linux and don't see "Load Systems Pretty Printers" in Tools->Options->Debugger->GDB.

    Also, the reason that I would like to view the contents of an element in the buffer is that the if statement is actually much more complicated and contains 12 different tests for values using the 9 values surrounding the main element. It would be much easier if I could have the debugger display all of those values to make sure that the test is working correctly.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.