No description
Find a file
Joel Brobecker 4bb99ac688 ax-gdb: Do not treat enums and bools as integers.
This patch fixes a problem when using gdb + gdbserver, and trying
to break on a function when one of the (enum) parameters is equal
to a certain value, and the size of that enum is 1 byte.

    (gdb) break mixed.adb:15 if light = green
    Breakpoint 2 at 0x402d5a: file mixed.adb, line 15.
    (gdb) cont
    Continuing.
    [Inferior 1 (process 9742) exited normally]

The debugger should have stopped once when our function was call
with light set to green.

Here is what happens: Because we're using a recent GDBserver,
GDB hands off the evaluation of the condition to GDBserver, by
providing it in the Z0 packet. This is what GDB sends:

    $Z0,402d5a,1;X13,26000622100223ff1c16100219162022011327#cf

I decoded the condition as follow:

    260006    reg 6 -> push
    2210      const8 0x10 -> push
    02        add (stack now has 1 element equal to reg6 + 16)
    23ff1c    const16 0xff1c
    1610      ext 16 (sign extend 16 bits)
    02        add (stack now has 1 element equal to reg6 + 16 - 228)
    19        ref32: Pop as addr, push 32bit value at addr.
    1620      ext 32 (sign extend 32 bits)
    2201      const8 0x01
    13        equal
    27        end

The beginning of the agent expression can be explained by the address
of symbol "light":

    (gdb) info addr light
    Symbol "light" is a variable at frame base reg $rbp offset 16+-228.

However, the mistake is the "ext 32" operation (extend 32 bits),
because our variable is *not* 32bits, only 8:

    (gdb) print light'size
    $5 = 8

But the reason why GDB decides to use a 32bit extension is because
it overrides the symbol's type with a plain integer type in
ax-gdb.c:gen_usual_unary...

      /* If the value is an enum or a bool, call it an integer.  */
    case TYPE_CODE_ENUM:
    case TYPE_CODE_BOOL:
      value->type = builtin_type (exp->gdbarch)->builtin_int;
      break;

... before calling require_rvalue. And of course, that causes the
generator to generate a sizeof(int) extension of the result.

One way to fix this would be to use an integer type of the correct
size, but I do not understand why this is necessary. The two routines
that use that information to generate the opcode down the line are
gen_fetch (for a memory value), or gen_extend (for a register value).
And they both have handling of enums and bools.

So the fix we elected to implement was simply to remove that code.

gdb/ChangeLog:

        * ax-gdb.c (gen_usual_unary): Remove special handling of
        enum and bool types.
2012-03-08 20:54:36 +00:00
bfd 2012-03-08 Tristan Gingold <gingold@adacore.com> 2012-03-08 14:25:29 +00:00
binutils * mn10300.h (elf_mn10300_reloc_type): Add R_MN10300_TLS_GD, 2012-03-07 17:52:00 +00:00
config config/: 2011-12-20 17:01:30 +00:00
cpu cpu/ 2012-02-27 06:57:57 +00:00
elfcpp * mips.h: New file 2012-01-28 01:04:22 +00:00
etc PR other/46202: implement install-strip. 2010-11-20 19:37:58 +00:00
gas 2012-03-08 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> 2012-03-08 17:22:18 +00:00
gdb ax-gdb: Do not treat enums and bools as integers. 2012-03-08 20:54:36 +00:00
gold * object.cc (need_decompressed_section): Add #ifdef ENABLE_THREADS. 2012-03-01 07:27:38 +00:00
gprof 2012-03-06 Tristan Gingold <gingold@adacore.com> 2012-03-06 13:54:59 +00:00
include 2012-03-08 Tristan Gingold <gingold@adacore.com> 2012-03-08 14:14:52 +00:00
intl merge from gcc 2010-09-27 21:01:18 +00:00
ld 2012-03-08 Tristan Gingold <gingold@adacore.com> 2012-03-08 13:53:03 +00:00
libdecnumber config/: 2011-12-20 17:01:30 +00:00
libiberty merge from gcc 2012-03-08 00:01:31 +00:00
opcodes 2012-03-08 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> 2012-03-08 17:22:18 +00:00
readline * signals.c (_rl_block_sigwinch, _rl_release_sigwinch): Add 2012-02-24 17:14:43 +00:00
sim sim: bfin: drop old linux/mii.h workarounds 2012-03-04 19:56:57 +00:00
texinfo
.cvsignore
.gitignore start a gitignore 2010-11-17 19:34:59 +00:00
ChangeLog 2012-03-05 Tristan Gingold <gingold@adacore.com> 2012-03-05 11:57:17 +00:00
compile
config-ml.in * config-ml.in: Don't handle arc-*-elf*. 2011-03-22 20:01:13 +00:00
config.guess Sync from upstream: 2011-06-06 10:36:06 +00:00
config.rpath Remove freebsd1 from libtool.m4 macros and config.rpath. 2011-02-13 21:00:14 +00:00
config.sub * config.sub: Update to version 2011-10-29 (added rl78) 2011-11-02 00:56:53 +00:00
configure 2012-03-05 Tristan Gingold <gingold@adacore.com> 2012-03-05 11:57:17 +00:00
configure.ac 2012-03-05 Tristan Gingold <gingold@adacore.com> 2012-03-05 11:57:17 +00:00
COPYING
COPYING.LIB
COPYING.LIBGLOSS 2012-02-21 Joern Rennecke <joern.rennecke@embecosm.com> 2012-02-21 22:40:27 +00:00
COPYING.NEWLIB 2012-02-21 Joern Rennecke <joern.rennecke@embecosm.com> 2012-02-21 22:40:27 +00:00
COPYING3
COPYING3.LIB
depcomp
djunpack.bat
install-sh
libtool.m4 Remove freebsd1 from libtool.m4 macros and config.rpath. 2011-02-13 21:00:14 +00:00
ltgcc.m4
ltmain.sh Backport from Libtool: Fix relink mode to use absolute path if hardcode_minus_L. 2011-01-13 18:52:53 +00:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS Import move-if-change script from gnulib. 2011-02-12 15:47:02 +00:00
Makefile.def 2011-11-09 Roland McGrath <mcgrathr@google.com> 2011-11-09 18:57:30 +00:00
Makefile.in 2011-11-09 Roland McGrath <mcgrathr@google.com> 2011-11-09 18:57:30 +00:00
Makefile.tpl 2011-11-09 Roland McGrath <mcgrathr@google.com> 2011-11-09 18:57:30 +00:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change Import move-if-change script from gnulib. 2011-02-12 15:47:02 +00:00
README
README-maintainer-mode
setup.com
src-release Include the <root>/cpu/ dir in GDB releases 2011-08-19 15:48:36 +00:00
symlink-tree
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.