# Question about debugging practice

**URL:** https://discourse.paraview.org/t/question-about-debugging-practice/4245
**Category:** Development
**Created:** [May 4, 2020, 9:21am UTC](https://discourse.paraview.org/t/question-about-debugging-practice/4245 "2020-05-04T09:21:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [May 4, 2020, 9:21am UTC](https://discourse.paraview.org/t/question-about-debugging-practice/4245/1 "2020-05-04T09:21:43Z")

</div>

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();
#endif
  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](https://discourse.paraview.org/t/paraview-hackathon-wednesday-may-6/4172) 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!

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [May 4, 2020, 12:54pm UTC](https://discourse.paraview.org/t/question-about-debugging-practice/4245/2 "2020-05-04T12:54:24Z")

</div>

`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)

---

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [May 4, 2020, 3:01pm UTC](https://discourse.paraview.org/t/question-about-debugging-practice/4245/3 "2020-05-04T15:01:48Z")

</div>

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.
