This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

problem with chained if statements?


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