Question about debugging practice

Quite often I am debugging my code by simply inserting some temporary output instead of running the software in the debugger. I am sure that I am not alone with this practice, for many good reasons! But there is one thing I never got working so far in the ParaView/VTK source code:

How can I get the vtkDebugMacro output displayed?

Ok, in vtkSetGet.h I can see that it is expanded only if NDEBUG is not defined - thus in a debug build. Which is already the first problem because very often I want to see such kind of output in a build that is exactly not a debug build! Like the practice I am following otherwise - see above.

So I went and changed the code in vtkSetGet.h in such a way that it would always compile, because I see in the expansion that output would go to vtkOutputWindowDisplayDebugText() anyway, which is again only happening if the logging level is set accordingly; at least this is what I understand from some source code reading (but maybe not yet enough…!??).

But trying to compile such a version of ParaView, I am getting error messages in places like this (from vtkImageReader.cxx):

#ifndef NDEBUG
  int* ext = data->GetExtent();
  vtkDebugMacro("Reading extent: " << ext[0] << ", " << ext[1] << ", " << ext[2] << ", " << ext[3]
                                   << ", " << ext[4] << ", " << ext[5]);

Well yes - makes sense: the #ifndef should not block the definition of ext and then call vtkDebugMacro with the assumption that it is undefined anyway. Which is of course not true any more if I make sure that it is defined!

Which leaves me a bit confused. I could of course go and change now all the occurrences of such code and make it more consistent - but then I am getting the feeling that I might be the one who has not understood certain coding/debugging concepts behind ParaView/VTK.

But maybe it is also just some leftover from “historical development” that is not properly cleaned up!? (If I am reading the hackathon announcement I see that cleanup is a main focus there - which I can easily believe! …)

Anyway, my current issues are with some SQLite related code, and I think I will simply again go for some local temporary patches in the PV/VTK code - but then I always see these vtkDebugMacro() calls and think how nice it was to simply “activate” them somehow!

vtkDebugMacro output can be enabled at object-level by calling SetDebugOn() on a specific object.

It is quite verbose as every vtkSetMacro and vtkGetMacro uses it. (that is why it should be used per object)

Right, I see now that it works indeed if I do what you are saying - PLUS compile a debug version! In that case I can run the debug code without debugger and get the output from the vtkDebugMacro!

I was always struggling to get it in the release code, but that is obviously not the idea here.