Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: jtc@redback.com (J.T. Conklin)
To: gdb@cygnus.com
Subject: problem with chained if statements?
Date: Thu, 01 Apr 1999 00:00:00 -0000	[thread overview]
Message-ID: <5mhfrl3v6e.fsf@jtc.redbacknetworks.com> (raw)

I'm trying to write some user-defined commands to traverse and/or
pretty-print some of the internal data structures used in our SW.  In
the absense of a `switch' statement, I am using a chain of if .. else
if ... else if ... else ... end statements.  Unfortunately it doesn't
seem to work.

For example, with the chain:
	if ($status == $TASK_READY)
                printf "READY    "
        else if ($status == $TASK_DELAY)
                printf "DELAY    "
        else if ($status == ($TASK_DELAY | $TASK_SUSPEND))
                printf "DELAY+S  "
        else if ($status == $TASK_PEND)
                printf "PEND     "
        else if ($status == ($TASK_PEND | $TASK_DELAY))
                printf "PEND+T   "
        else if ($status == ($TASK_PEND | $TASK_SUSPEND))
                printf "PEND+S   "
        else if ($status == $TASK_SUSPEND)
                printf "SUSPEND  "
        else if ($status == $TASK_DEAD)
                printf "DEAD     "
        else
                printf "%8x ", $status
	end

Always prints the numeric value of $status, even when it is equal to
one of the pre-defined $TASK_FOO variables.  However, a simple test

	set $status = $TASK_READY
	if $status == $TASK_READY
		printf "OK\n"
	end
works as expected.


Is my syntax for this wrong in some way, or should I be looking for 
an bug inside GDB.

	--jtc

-- 
J.T. Conklin
RedBack Networks


             reply	other threads:[~1999-04-01  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-01  0:00 J.T. Conklin [this message]
1999-04-01  0:00 ` Stan Shebs
1999-04-01  0:00   ` J.T. Conklin
1999-04-01  0:00     ` Stan Shebs
  -- strict thread matches above, loose matches on Subject: below --
1999-04-01  0:00 Thompson, James C
1999-04-01  0:00 Thompson, James C
1999-04-01  0:00 ` Todd Whitesel
1999-04-01  0:00 ` Ovidiu Predescu
1999-04-01  0:00   ` Stan Shebs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5mhfrl3v6e.fsf@jtc.redbacknetworks.com \
    --to=jtc@redback.com \
    --cc=gdb@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox