old-cross-binutils/gdb/testsuite
Jerome Guitton b50d69b5aa Full view of interface-wide types
For displaying the full view of a class-wide object, GDB relies on
the assumption that this view will have the same address as the
address of the object. In the case of simple inheritance, this
assumption is correct; the proper type is deduced by decoding
the tag of the object and converting the result to this full-view
type.

Consider for example an abstract class Shape, a child Circle
which implements an interface Drawable, and the corresponding
following objects:

   My_Circle   : Circle := ((1, 2), 3);
   My_Shape    : Shape'Class := Shape'Class (My_Circle);
   My_Drawable : Drawable'Class := Drawable'Class (My_Circle);

To display My_Shape, the debugger first extracts the tag (an internal
field, usually the first one of the record):

 (gdb) p my_shape'address
 $2 = (system.address) 0x8063e28
 (gdb) x/x my_shape'address
 0x8063e28 <classes__my_shape>: 0x08059ec4

Then the type specific data and the expanded name of the tag is read
from there:

 (gdb) p my_shape'tag
 $3 = (access ada.tags.dispatch_table) 0x8059ec4 (classes.circle)

To get the full view, the debugger converts to the corresponding type:

 (gdb) p {classes.circle}0x8063e28
 $4 = (center => (x => 1, y => 2), radius => 3)

Now, in the case of multiple inheritance, the assumption does not hold
anymore. The address that we have usually points to some
place lower. The offset to the original address is saved in the field
Offset_To_Top of the metadata that are above the tag, at address
obj'tag - 8. In the case of my_shape, this offset is 0:

 (gdb) x/x my_shape'tag - 8
 0x8059ebc <classes__circleT+12>:        0x00000000

...but in the case of an interface-wide object, it is not null:

 (gdb) x/x my_drawable'tag - 8
 0x8063b28 <classes__classes__circle_classes__drawable1T56s+12>: 0x00000004
 (gdb) p {classes.circle}(my_drawable'address - 4)
 $7 = (center => (x => 1, y => 2), radius => 3)

The following change handles this relocation in the most common cases.
Remaining cases that are still to be investigated are signaled by
comments.

gdb/ChangeLog:

	* ada-lang.h (ada_tag_value_at_base_address): New function
	declaration.
	* ada-lang.c (is_ada95_tag, ada_tag_value_at_base_address):
	New functions.
	(ada_to_fixed_type_1, ada_evaluate_subexp): Let ada_tag_base_address
	relocate the class-wide value if need be.
	(ada_value_struct_elt, ada_value_ind, ada_coerce_ref):
	Let ada_tag_value_at_base_address relocate the class-wide access/ref
	before dereferencing it.
	* ada-valprint.c (ada_val_print_1): Relocate to base address
	before displaying the content of an interface-wide ref.

gdb/testsuite/ChangeLog:

        * gdb.ada/ptype_tagged_param.exp: Adjust expected output in
        ptype test.
2012-11-29 16:28:10 +00:00
..
boards * boards/dwarf4-gdb-index.exp: New file. 2012-09-20 15:21:09 +00:00
config
gdb.ada Full view of interface-wide types 2012-11-29 16:28:10 +00:00
gdb.arch * gdb.threads/gcore-thread.exp: Use gdb_gcore_cmd. 2012-11-06 15:21:24 +00:00
gdb.asm
gdb.base 2012-11-26 Alexander Larsson <alexl@redhat.com> 2012-11-26 19:23:56 +00:00
gdb.cell * gdb.threads/gcore-thread.exp: Use gdb_gcore_cmd. 2012-11-06 15:21:24 +00:00
gdb.cp gdb/ 2012-11-27 07:59:12 +00:00
gdb.disasm
gdb.dwarf2 Remove trailing '#' in gdb.dwarf2/dw2-icc-opaque.S 2012-10-15 17:26:14 +00:00
gdb.fortran 2012-09-26 Jan Kratochvil <jan.kratochvil@redhat.com> 2012-09-26 19:38:32 +00:00
gdb.gdb 2012-09-08 Khoo Yit Phang <khooyp@cs.umd.edu> 2012-09-08 05:29:21 +00:00
gdb.go
gdb.hp * gdb.hp/gdb.aCC/exception.exp: Remove. 2012-08-21 19:36:47 +00:00
gdb.java gdb/testsuite/ 2012-10-15 19:11:56 +00:00
gdb.linespec PR breakpoints/14643. 2012-10-11 16:12:05 +00:00
gdb.mi gdb/testsuite/ 2012-11-20 02:55:10 +00:00
gdb.modula2
gdb.multi 2012-11-09 Pedro Alves <palves@redhat.com> 2012-11-09 12:20:24 +00:00
gdb.objc
gdb.opencl
gdb.opt
gdb.pascal
gdb.python http://sourceware.org/ml/gdb-patches/2012-11/msg00308.html 2012-11-14 10:16:46 +00:00
gdb.reverse gdb/testsuite/ 2012-10-16 13:14:36 +00:00
gdb.server * gdb.base/annota1.exp: Accept no frames-invalid notification 2012-08-02 15:59:59 +00:00
gdb.stabs
gdb.threads gdb/testsuite/ 2012-11-14 05:52:32 +00:00
gdb.trace gdb/testsuite: 2012-10-25 14:56:09 +00:00
gdb.xml http://sourceware.org/ml/gdb-patches/2012-09/msg00015.html 2012-09-14 21:23:45 +00:00
lib 2012-11-26 Alexander Larsson <alexl@redhat.com> 2012-11-26 19:23:56 +00:00
aclocal.m4
ChangeLog Full view of interface-wide types 2012-11-29 16:28:10 +00:00
configure
configure.ac
dg-extract-results.sh
Makefile.in
TODO