[Insight-developers] [Insight-users] GDB debuging couldn't find method GetPixel()

Williams, Norman K norman-k-williams at uiowa.edu
Fri Jul 29 11:03:15 EDT 2011


This works as well

image.m_Pointer->GetPixel(pixelIndex)

You can also define gdb macros to handle ITK smart pointers. Copy the
following lines
to ~/.gdbinit

define psp
print $arg0.m_Pointer
end

document psp
Print the object pointer from a smart pointer.
Example: psp imagePointer
end

define pspm
print $arg0.m_Pointer->$arg1
end

document pspm
print a member of the object pointed to by a smart pointer.
you can also call a member method through the smart pointer,
Example: pspm imagePtr GetSize()
end

define pspc
print *($arg0.m_Pointer)
end

document pspc

print the contents of an object pointed to with a smart pointer
Example pspc imagePtr
endif

There are also some great gdb user command libraries:

This one will pretty-print STL containers
http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt


On 7/29/11 8:54 AM, "Matt McCormick" <matt.mccormick at kitware.com> wrote:

>Hi Johnny,
>
>GDB has recently greatly improved C++ support.  You may have better luck
>with a newer version of GDB.
>
>The problem I have run into previously is with GDB resolving the
>SmartPointer, not the templated methods.  So, you may have to do
>something like:
>
>p (*(image.m_Pointer)).GetPixel(pixelIndex)
>
>If you use vim, I like pyclewn (which works on top of GDB).  If you want
>a GUI, maybe KDevelop4?
>
>Best,
>Matt
>
>On Thu, Jul 28, 2011 at 9:05 PM, Johnny <20673972 at student.uwa.edu.au>
>wrote:
>
>Hi all,
>
>Could be a silly question but did confuse me quite a few days. Your help
>are highly appreciated.
>
>While I was trying to use GDB debugging my code, I wanted to see what
>value the GetPixel(index) method returns.
>
>The easiest way to reproduce this issue is using the source code
>Examples/DataRepresentation/Image/Image3.cxx
>
>Line113:  ImageType:PixelType pixelValue = image->GetPixel(pixelINdex);
>
>I set the break at line 113. Then using expression ³p
>image->GetPixel(pixelIndex)² which is exactly the same in the code.
>However I always got the message ³Couldn¹t find method
>itk::SmartPointer<itk::Image<short unsined int, 3u>>::GetPixel²
>What was confusing me is if I continued the program, it run OK, which
>means it could find the method. I just could not get it from debuging
>command.
>
>I did heard that GDB are somehow tricky to deal with templated methods.
>Is this the  issue?
>
>Btw I am using Intel mac osx, I cound not install ddd. Any suggestions
>for a good visual debugger?
>
>
>Cheers
>
>Johnny
>
>
>
>
>_____________________________________
>Powered by www.kitware.com <http://www.kitware.com>
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Kitware offers ITK Training Courses, for more information visit:
>http://www.kitware.com/products/protraining.html
>
>Please keep messages on-topic and check the ITK FAQ at:
>http://www.itk.org/Wiki/ITK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.itk.org/mailman/listinfo/insight-users
>
>
>
>
>
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Kitware offers ITK Training Courses, for more information visit:
>http://kitware.com/products/protraining.html
>
>Please keep messages on-topic and check the ITK FAQ at:
>http://www.itk.org/Wiki/ITK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.itk.org/mailman/listinfo/insight-developers



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list