This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: bitwise operations on registers
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Cc: Eli Zaretskii <eliz at is dot elta dot co dot il>, Andrew Morton <akpm at zip dot com dot au>,gdb at sources dot redhat dot com
- Date: Mon, 11 Mar 2002 10:39:42 -0500
- Subject: Re: bitwise operations on registers
- References: <Pine.SUN.3.91.1020311130105.17471A-100000@is> <3C8CCEAF.2030803@cygnus.com>
On Mon, Mar 11, 2002 at 10:35:11AM -0500, Andrew Cagney wrote:
> >On Sun, 10 Mar 2002, Andrew Morton wrote:
> >
> >
> >>(gdb) p $esp & 4
> >>Argument to arithmetic operation not a number or boolean.
> >>(gdb)
> >>
> >>I don't seem to be able to perform the `&' and `|' arithmetic
> >>operators against machine registers.
> >
> >
> >"p $eax & 4" works for me. Doesn't it work for you?
> >
> >As for $esp, I think GDB knows that it's not a number, so try
> >
> > (gdb) p (int)$esp & 4
> >
> >(I don't know whether the built-in knowledge GDB has about $esp should
> >prevent it from working without the cast, though.)
>
> Yes, try:
> (gdb) p (void*)0 & 4
> So, this a bug?
I think so. C won't let you do it either, but historically we've been
more permissive than C about things that have a clearly defined
meaning, and this does.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer