Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Type identification within a user defined commands
@ 2004-10-20 22:22 Brendan Doherty
  2004-10-20 23:48 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Brendan Doherty @ 2004-10-20 22:22 UTC (permalink / raw)
  To: gdb

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Type identification within a user defined commands
  2004-10-20 22:22 Type identification within a user defined commands Brendan Doherty
@ 2004-10-20 23:48 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2004-10-20 23:48 UTC (permalink / raw)
  To: Brendan Doherty; +Cc: gdb

On Thu, Oct 21, 2004 at 10:35:56AM +1300, Brendan Doherty wrote:
> 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.

No, it isn't possible.  You'd need a real scripting language for this;
a Perl implementation was posted, and someone has said they're working
on a Guile implementation.

-- 
Daniel Jacobowitz


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-20 22:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 22:22 Type identification within a user defined commands Brendan Doherty
2004-10-20 23:48 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox