[vtk-developers] new widget to spy on your vtk objects

pat marion pat.marion at kitware.com
Mon May 16 12:15:01 EDT 2011


Hi,

I'd like to commit this to VTK now.  I've put some commits on gerrit and I'm
hoping some folks will have time this week to take a look.  The commits are:

http://review.source.kitware.com/#change,1654
http://review.source.kitware.com/#change,1655
http://review.source.kitware.com/#change,1656

-The first commit modifies vtkCommon.  It adds required api to
vtkDebugLeaks.
-The second commit modifies GuiSupport/Qt to add the widget and a test for
the widget.
-The third commit may not pass review.  It adds python powered features to
the widget, but also adds a python dependency to the QVTK library.  Project
developers interested in using the widget can always subclass the widget to
add the python features themselves.


In my opinion, the first commit is low risk for bugs and regressions.  If it
passes review, I hope it can be put into the 5.8 release.  The second commit
is also low risk because it simply adds a new stand-alone widget with test,
it does not alter any existing code.  If it passes with a green dashboard
then I think it should also be placed in the 5.8 release.

Just a reminder, usage of this widget is detailed at:
http://vtk.org/Wiki/DebugLeaksView

Pat


On Tue, Feb 15, 2011 at 12:59 PM, pat marion <pat.marion at kitware.com> wrote:

> I'd definitely be in favor of adding this widget to VTK master, but I'll
> leave that decision to the VTK community and ARB.
>
> The code is mostly self contained in a pair of qt model/view classes, but
> also requires modifications to vtkObjectBase.cxx and vtkDebugLeaks{cxx,h}
> here:
>
>
> https://github.com/patmarion/VTK/commit/8b3b7203323859efb493cd76d1d2ca68e22eff62
>
> The main change is that I added hooks to vtkObjectBase.cxx:
>
> diff --git a/Common/vtkObjectBase.cxx b/Common/vtkObjectBase.cxx
> index 9ea53ec..c75687b 100644
> --- a/Common/vtkObjectBase.cxx
> +++ b/Common/vtkObjectBase.cxx
> @@ -75,10 +75,17 @@ vtkObjectBase::vtkObjectBase()
>  {
>    this->ReferenceCount = 1;
>    this->WeakPointers = 0;
> +#ifdef VTK_DEBUG_LEAKS
> +  vtkDebugLeaks::ObjectConstructed(this);
> +#endif
>  }
>
>  vtkObjectBase::~vtkObjectBase()
>  {
> +#ifdef VTK_DEBUG_LEAKS
> +  vtkDebugLeaks::ObjectDestroyed(this);
> +#endif
> +
>    // warn user if reference counting is on and the object is being
> referenced
>    // by another object
>    if ( this->ReferenceCount > 0)
>
>
> The vtkDebugLeaks::ObjectConstructed/ObjectDestroyed function calls are
> essentially no-ops unless the widget is activate.  And of course when
> VTK_DEBUG_LEAKS is OFF then the whole thing is skipped.  So I think it is
> pretty unobtrusive the way I have it, but perhaps someone will suggest an
> alternate implementation.
>
> Note- class counts and reference counts are not updated instantaneously,
> they are updated when the application event loop cycles.  For people
> interested in pinpointing instantaneous changes, gdb or other debugger is
> still the best option.
>
> Pat
>
>
>
> On Tue, Feb 15, 2011 at 11:28 AM, Aashish Chaudhary <
> aashish.chaudhary at kitware.com> wrote:
>
>> This is fantastic. Really helpful visual debug tool.
>>
>> Any plans to move it into VTK master?
>>
>> Thanks Pat.
>>
>> On Sat, Feb 12, 2011 at 11:04 AM, David Cole <david.cole at kitware.com>wrote:
>>
>>> Absolutely brilliant. Nice work, Pat!
>>>
>>>
>>> On Sat, Feb 12, 2011 at 10:57 AM, Utkarsh Ayachit <
>>> utkarsh.ayachit at kitware.com> wrote:
>>>
>>>> That;s fantastic. Can't wait to try it out next time I am trying to
>>>> debug a leak-hell.
>>>>
>>>> Utkarsh
>>>>
>>>> On Fri, Feb 11, 2011 at 5:49 PM, pat marion <pat.marion at kitware.com>
>>>> wrote:
>>>> > Hello vtk and qt heads,
>>>> >
>>>> > I've got a new widget to share with you.  Actually it's not new.  I
>>>> wrote
>>>> > the code several months ago when I was stuck in an airport.  I finally
>>>> got
>>>> > around to rebasing it and pushing to github.  I added a wiki page with
>>>> > screenshots:
>>>> >
>>>> >     http://vtk.org/Wiki/DebugLeaksView
>>>> >
>>>> > Motivation: VTK_DEBUG_LEAKS is a great help, any developer worth his
>>>> or her
>>>> > salt has it enabled... (right?)  But it only reports leaky objects at
>>>> > program shutdown.  I wanted to spy on my vtk objects at runtime.  So I
>>>> > created this debug leaks widget.  Please see the wiki page for a
>>>> > demonstration!
>>>> >
>>>> > Pat
>>>> >
>>>> > _______________________________________________
>>>> > Powered by www.kitware.com
>>>> >
>>>> > Visit other Kitware open-source projects at
>>>> > http://www.kitware.com/opensource/opensource.html
>>>> >
>>>> > Follow this link to subscribe/unsubscribe:
>>>> > http://www.vtk.org/mailman/listinfo/vtk-developers
>>>> >
>>>> >
>>>> >
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>
>>>
>>>
>>
>>
>> --
>> | Aashish Chaudhary
>> | R&D Engineer
>> | Kitware Inc.
>> | www.kitware.com
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110516/49ec43ee/attachment.html>


More information about the vtk-developers mailing list