This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Cast to result of whatis expression
>>>>> "Kenneth" == Kenneth Rose <kenrose@kenrose.org> writes:
Kenneth> I'm writing something similar to gdb-stl-views for some custom
Kenneth> container classes that we have.
I think that these days it is better to use the Python pretty-printing
infrastructure instead. It has a number of advantages -- it works no
matter how the object is printed (in a stack trace, embedded in some
other structure), and it works with MI.
Kenneth> I need to explicitly cast foo.m_x to the appropriate type, but
Kenneth> I'm at a loss as to how to get that type from gdb. "whatis
Kenneth> foo" gives me back "Container<int>". Is there anyway of
Kenneth> extracting the "int" part of that result and using that as the
Kenneth> type to cast to?
You can do this in Python :-)
You could probably do it (with some difficulty) using a combination of
logging, "shell", and "source".
Kenneth> I'm using the stock GDB that ships with Mac OS X 10.6 (GNU gdb
Kenneth> 6.3.50-20050815 (Apple version gdb-1461). I know... it's old.
Ah, Apple's fork. Unfortunately it is Python-free.
You could try GDB 7.2. It has some known bugs on Mac OS, but I have
also heard reports of it work.
Tom