[vtkusers] How to use vtkDebugMacro

Michael Jackson mike.jackson at bluequartz.net
Sun Oct 19 11:46:13 EDT 2008


If you look at what exactly the vtkDebugMacro expands to:

if (this->GetDebug() &&  
vtkObject::GetGlobalWarningDisplay())               \
      
{                                                                         \
     vtkOStreamWrapper::EndlType  
endl;                                         \
      
vtkOStreamWrapper 
::UseEndl(endl);                                         \
     vtkOStrStreamWrapper  
vtkmsg;                                              \
     vtkmsg << "Debug: In " "/Users/mjackson/Workspace/PVDislocation/ 
src/VizFileReaders/vtkH5VizFileReader.cpp" ", line " << 65 <<  
"\n"             \
            << this->GetClassName() << " (" << this << "): "  
<<"Debugging"  << "\n\n";     \
      
vtkOutputWindowDisplayDebugText 
(vtkmsg.str());                            \
     vtkmsg.rdbuf()- 
 >freeze(0);                                                \
     }                                                                         \
   }

So there may be a problem calling the GetDebug() method from a  
constructor. I vaguely remember someone telling me that calling that  
function from a constructor was problematic, but maybe that was a  
prior version of vtk and it may have just been a bug.

vtkDebugMacro is declared in vtkSetGet.h which should be included if  
you are subclassing from any of the vtk classes but you may want to  
check just to make sure. I tried out vtkDebugMacro in the constructor  
of one of my own vtk derived classes and it at least compiled.

Q1: Nothing. Just the proper includes is all you should need.
Q2: I would keep vtk debugging with vtk classes and Qt debugging with  
Qt classes. Just to be safe.
Q3: See Q1
Q4: In the Xcode debugger, if you hit a breakpoint there should be a  
call stack window somewhere in the debugger. If you want to "print" it  
out then simply select the call stack in the window and "copy" it and  
then paste it into a text editor or where ever else you need it.
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio

On Oct 19, 2008, at 11:19 AM, Elvis Dowson wrote:

> Hi,
>           When I declare vtkDebugMacro(<<"Entering constructor");  
> inside the constructor of a vtk class and compile, I get a couple of  
> errors saying that vtkDebug, etc is not defined.
>
> Question 01: What should I do to enable debugging output in vtk?
>
> Question 02: I am using vtk with Qt, so should I use vtk debugging  
> macros for vtk classes and Qt debugging macros for the Qt  
> application part?
>
> Question 03: Any hints or examples for using debugging macros for  
> vtk and Qt?
>
> Question 04: Is there a way to print out the function call stack  
> trace using the Xcode debugger?
>
> Best regards,
>
> Elvis Dowson
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list