Binutils with MCST patches
Go to file
Andrew Burgess 6f0ffe50c8 gdb: Allow struct fields named double
The 64-bit RISC-V target currently models the floating point registers
as having the following type:

    union riscv_double
    {
        builtin_type_ieee_single float;
        builtin_type_ieee_double double;
    }

Notice the choice of names for the fields of this struct, possibly not
ideal choices, as these are not valid field names in C.  However, this
type is only ever defined within GDB (or in the target description),
and no restriction seems to exist on the field names in that case.

The problem though is that currently:

    (gdb) info registers $ft0
    ft0            {float = 0, double = 0}	(raw 0x0000000000000000)
    (gdb) p $ft0.float
    $1 = 0
    (gdb) p $ft0.double
    A syntax error in expression, near `double'.

We can access the 'float' field, but not the 'double' field.  This is
because the string 'double' is handled differently to the string
'float' in c-exp.y.

In both cases the string '$ft0' is parsed as a VARIABLE expression.

In the 'float' case, the string 'float' becomes a generic NAME token
in 'lex_one_token', which then allows the rule "exp '.' name" to match
and the field name lookup to occur.

The 'double' case is different.  In order to allow parsing of the type
string 'long double', the 'double' string becomes the token
DOUBLE_KEYWORD.  At this point there's no rule to match "exp '.'
DOUBLE_KEYWORD", so we can never lookup the field named 'double'.

We could rename the fields for RISC-V, and maybe that would be the
best solution.  However, its not hard to allow for fields named
'double', which is what this patch does.

A new case is added to the 'field_name' rule to match the
DOUBLE_KEYWORD, and create a suitable 'struct stoken'.  With this done
the "exp '.'  field_name" pattern can now match, and we can lookup the
double field.

With this patch in place I now see this behaviour:

    (gdb) info registers $ft0
    ft0            {float = 0, double = 0}	(raw 0x0000000000000000)
    (gdb) p $ft0.float
    $1 = 0
    (gdb) p $ft0.double
    $2 = 0

I've gone ahead and handled INT_KEYWORD, LONG, SHORT, SIGNED_KEYWORD,
and UNSIGNED as well within field_name.

I've added a new test for this functionality.

This change was tested on x86-64 GNU/Linux with no regressions.

gdb/ChangeLog:

	* c-exp.y (field_name): Allow DOUBLE_KEYWORD, INT_KEYWORD, LONG,
	SHORT, SIGNED_KEYWORD, and UNSIGNED tokens to act as a field
	names.
	(typename_stoken): New function.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-unusual-field-names.c: New file.
	* gdb.dwarf2/dw2-unusual-field-names.exp: New file.
2018-12-24 17:25:25 +00:00
bfd Automatic date update in version.in 2018-12-24 00:00:20 +00:00
binutils elf: Add PT_GNU_PROPERTY segment type 2018-12-14 04:55:34 -08:00
config Fix a typo in iconv.m4. 2018-11-09 16:08:10 +00:00
contrib Update dg-extract-results.* from gcc 2018-08-06 16:05:16 +02:00
cpu or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
elfcpp [MIPS] Add Loongson 2K1000 proccessor support. 2018-08-29 20:55:25 +08:00
etc Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
gas x86: Properly handle PLT expression in directive 2018-12-19 12:22:12 -08:00
gdb gdb: Allow struct fields named double 2018-12-24 17:25:25 +00:00
gold [GOLD] Tweak keep_text_section_prefix test for PowerPC64 ELFv1 2018-12-18 11:57:45 +10:30
gprof Fix typo setting user_specified variable when parsing -Z option. 2018-10-01 17:18:20 +01:00
include elf: Add PT_GNU_PROPERTY segment type 2018-12-14 04:55:34 -08:00
intl Fix a typo in iconv.m4. 2018-11-09 16:08:10 +00:00
ld x86: Properly handle PLT expression in directive 2018-12-19 12:22:12 -08:00
libdecnumber Merge config/ changes from GCC. 2018-10-31 17:16:41 +00:00
libiberty Synchronize libiberty with gcc and add --no-recruse-limit option to tools that support name demangling. 2018-12-07 11:32:55 +00:00
opcodes Include bfd_stdint.h in bfd.h 2018-12-18 23:49:48 +10:30
readline Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
sim sim: Don't overwrite stored errno in sim_syscall_multi 2018-12-18 00:02:01 +00:00
texinfo
zlib Merge config/ changes from GCC. 2018-10-31 17:16:41 +00:00
.cvsignore
.gitattributes
.gitignore
COPYING
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
COPYING3
COPYING3.LIB
ChangeLog Merge autoconf / automake update changes from GCC. 2018-10-31 17:10:56 +00:00
MAINTAINERS
Makefile.def
Makefile.in Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-29 23:49:28 -03:00
Makefile.tpl Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-29 23:49:28 -03:00
README
README-maintainer-mode Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
ar-lib Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
compile
config-ml.in
config.guess Update config.guess and config.sub 2018-07-05 13:35:19 +02:00
config.rpath
config.sub Update config.sub 2018-07-06 08:23:40 +02:00
configure Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-29 23:49:28 -03:00
configure.ac Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-29 23:49:28 -03:00
depcomp
djunpack.bat
install-sh
libtool.m4 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am Merge autoconf / automake update changes from GCC. 2018-10-31 17:10:56 +00:00
setup.com
src-release.sh Add "contrib" to the list of GDB support dirs (on src-release.sh) 2018-09-13 12:33:19 -04:00
symlink-tree
test-driver Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
ylwrap

README

		   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.