mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-12 12:16:04 +08:00
1f5d1570c0
ada_value_struct_elt is used when displaying a component (say, 'N') of a record object (say, 'Obj') of type, say, 't1'. Now if Obj is tagged (Ada parlance: "tagged types" are what other object-oriented languages call "classes"), then 'N' may not be visible in the current view and we need to look for it in its actual type. We do that at the same time as resolving variable-length fields. This would typically be done by the following call to ada_value_struct_elt, with the last parameter check_tag set to 1: t1 = ada_to_fixed_type (ada_get_base_type (t1), NULL, address, NULL, 1); This is the general logic, but recently we introduced a special case to handle homonyms. Different components may have the same name in a tagged type. For instance: type Top_T is tagged record N : Integer := 1; end record; type Middle_T is new Top.Top_T with record N : Character := 'a'; end record; Middle_T extends Top_T and both define a (different) component with the same name ('N'). In such a case, using the actual type of a Middle_T object would create a confusion, since we would have two component 'N' in this actual type. So, to handle homonyms, we convert t1 to the actual type *if and only if* N cannot be found in the current view. For example, if Obj has been created as a Middle_T but is seen as a Top_T'Class at our point of execution, then "print Obj.N" will display the integer field defined in Top_T's declaration. Now, even if we find N in the current view, we still have to get a fixed type: for instance, the record can be unconstrained and we still need a fixed type to get the proper offset to each field. That is to say, in this case: type Dyn_Top_T (Disc : Natural) is tagged record S : Integer_Array (1 .. Disc) := (others => Disc); N : Integer := 1; end record; type Dyn_Middle_T is new Dyn_Top.Dyn_Top_T with record N : Character := 'a'; U : Integer := 42; end record; If we have an object Obj of type Dyn_Middle_T and we want to display U, we don't need to build, from its tag, a real type with all its real fields. In other words, we don't need to add the parent components: Disc, S, and the integer N. We only need to access U and it is directly visible in Dyn_Middle_T. So no tag handling. However, we do need to build a fixed-size type to have the proper offset to U (since this offset to U depends on the size of Obj.S, which itself is dynamic and depends on the value of Obj.Disc). We accidentally lost some of this treatment when we introduced the resolution of homonyms. This patch re-install this part by uncoupling the tag resolution from the "fixing" of variable-length components. This change also slightly simplifies the non-tagged case: in the non-tagged case, no need to set check_tag to 1, since we already know that there is no tag. gdb/ChangeLog: * ada-lang.c (ada_value_struct_elt): Call ada_to_fixed_type with check_tag to 1 if and only if the type is tagged and the component being searched cannot been found in the current view. Otherwise, always call ada_to_fixed_type with check_tag to 0. gdb/testsuite/ChangeLog: * gdb.ada/same_component_name: Add test for case of tagged record with variable-length fields. |
||
---|---|---|
bfd | ||
binutils | ||
config | ||
contrib | ||
cpu | ||
elfcpp | ||
etc | ||
gas | ||
gdb | ||
gold | ||
gprof | ||
include | ||
intl | ||
ld | ||
libdecnumber | ||
libiberty | ||
opcodes | ||
readline | ||
sim | ||
texinfo | ||
zlib | ||
.cvsignore | ||
.gitattributes | ||
.gitignore | ||
ar-lib | ||
ChangeLog | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.LIBGLOSS | ||
COPYING.NEWLIB | ||
depcomp | ||
djunpack.bat | ||
install-sh | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
makefile.vms | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
README | ||
README-maintainer-mode | ||
setup.com | ||
src-release.sh | ||
symlink-tree | ||
test-driver | ||
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.