QtCreator debug vtkObjects

Hello,
i use the QtCreator and Vtk under linux for developing a CMake-project.
I build VTK in Debug and set the VTK_DIR via /etc/environment.
So when i use the QtCreator in debug mode i cant access any VtkOjects:
image
Any ideas or links i didnt found?
Thanks in advance

Hello,

Please, make sure the debugger cursor is in the same scope as the object to be inspected. From the little screen capture you posted, one sees a smart pointer. Smart pointers may not be valid outside its scope. Maybe you could share more of the context.

best,

PC

Thank you for the reply,
its also not possible if the vtkObjects are created in the same scope or the debugger cursor (guess you mean the breakpoint?) is in the same scope…
But i forget that i cant also do a myPolydata->PrintSelf(std::cout, vtkIndent()) which is ok for me…
But if anyone has the same problem and a solution please let me know.
Thanks so far

These are not the same thing. A breakpoint, when triggered, tells the debugger to stop there. The debugger cursor is where the debugger is currently stopped, which can be light-years away from any breakpoint (e.g. stop triggered by a condition or by exception thrown). The current execution point (where the debugger cursor is) must be such that the object to inspect is in still in scope to allow inspection.

Hello Paulo,
I see. I had the debugger cursor in my mind. I didnt know that word. Thank you, learned sth new!
What i am also wondering is, that when doing a myPolydata->PrintSelf(std::cout, vtkIndent()) in the ouput is all the information and also Debug: Off? Dont know this hast something to do with the problem.
Thanks and nice Weekend
Philipp

What’s this? A CMake configuration?

No,
it is, what i understand now, just a property of the vtkObject which is printed in the terminal, but i dont know what further information is printed than. Or does it mean, when set on, that when something is done with that object, it is printed in the terminal even without PrintSelf(std::cout, vtkIndent())?


And also if i call DebugOn()i cant access that object from qtCreator…
But it makes sense, i mean it would be stupid, if you have to set all vtkObject to DebugOn just to access them in qtCreator… I guess you are right, and it is a CMake problem. A flag or sth. what i am missing…
Sorry for this silly questions and information, but i am not a vtk (and also no c++) expert at all…
regards
philipp

Hello,

I see. That “debug” in your figure means the object will send messages to the console to give feedback to the user on processing, warnings, etc. Then there is the other “debug” thing, when you compile VTK libraries in debug mode. Debug mode means that the compiler will instrumentalize the resulting executable code so it can talk to the debugger, profiler, etc. That is the so-called “debug info”. There is no magic in debugging. I mean, when a debugger controls the execution of a program, the program has a lot of “intrumentation code” that is added to the executable and is necessary so a debugger or profiler can work (e.g. the debugger knows wich line of source code was the origin of certain executable instruction, the name of the variables so it can inspect values, etc.). That is why the debug version libraries are slow and are huge.

To see what’s in the bowels of VTK, you also need to compile it in debug mode, in addition to your own project. To compile VTK in debug mode, you need to set it when configuring the VTK build in CMake: cmake -DCMAKE_BUILD_TYPE=Debug <path_to_source> (run this in a different build directory).

I hope this helps,

PC

Hello Paulo,
thank you for the reply.
As I wrote in my very first post, i built the VTK Lib in Debug mode. So that should not be the issue. But nevertheless thank you very much for the detailed explanation!
But by the a way, is there a possibilty to check which build type i am using on runtime? But i will google… i will see…

regards
Philipp

Not natively. You can test for it via a de facto standard:

 #ifdef NDEBUG
  bool debug_mode = false;
 #else
  bool debug_mode = true;
 #endif

This is not an ANSI standard though, but possibly the most portable way to do so.

regards,

PC

ok, i think my question was wrong:
I wanted to know if there is a possibility to check which build type of the VTK library am i using at runtime, not my own project/executable…

Hello,

There is no portable way to do that. Please, take a look at this: https://stackoverflow.com/questions/847721/how-to-identify-if-a-library-is-debug-or-release-build

take care,

PC