This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Type identification within a user defined commands
- From: "Brendan Doherty" <brendand at gentrack dot com>
- To: <gdb at sources dot redhat dot com>
- Date: Thu, 21 Oct 2004 10:35:56 +1300
- Subject: Type identification within a user defined commands
Is it possible to identify the type of a variable passed to a user
defined command.
I'm trying to create a prettier print that displays information about
the various classes that we use.
I want to use the type to access attributes specific to that class.
What I am trying to do is considerable more complex than the example
below, bug it demostrates what I want to do.
EXAMPLE
=======
define myprint
set $classtype = (whatis $arg0)
if $classtype = dog then
printf "Dog:\n"
printf "Name: %s\n", $arg0->name->str
printf "Number of holes dug: %d\n, $arg0->numholes
else
if $classtype = bird
printf "Bird:\n"
printf "Name: %s\n", $arg0->name->str
printf "Number of worms: %d\n, $arg0->numworms
end
end
end