This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]