This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] dwarf debug information: Handle Free Pascal virtual table indexes
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 12 May 2010 15:47:32 +0200
- Subject: [RFC] dwarf debug information: Handle Free Pascal virtual table indexes
Free Pascal compiler uses for
DW_AT_vtable_elem_location attribute a BLOCK consisting of
a DW_OP_constu marker followed by a unsigned_leb128 value
to indicate the offset within the virtual table of a virtual
function.
GDB doesn't handle this currently, and this creates
errors in which attributes coming later, like
DW_AT_low_pc and DW_AT_high_pc not be set correctly
and thus generating lots of complaints.
This patch allows to parse Free Pascal output correctly.
Is this an acceptable patch?
Pierre Muller
Pascal language support maintainer for GDB
2010-05-12 Pierre Muller <muller@ics.u-strasbg.fr>
* dwarf2read.c (dwarf2_add_member_fn): Handle Free Pascal
compiler method to give the offset of a virtual function
in the virtual table.
Index: src/gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.383
diff -u -p -r1.383 dwarf2read.c
--- src/gdb/dwarf2read.c 8 May 2010 04:58:45 -0000 1.383
+++ src/gdb/dwarf2read.c 12 May 2010 12:51:20 -0000
@@ -4892,6 +4892,23 @@ dwarf2_add_member_fn (struct field_info
fnp->voffset += 2;
fnp->fcontext = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
}
+ /* Support for Free Pascal description of virtual methods. */
+ else if (attr_form_is_block (attr) && DW_BLOCK (attr)->size > 0
+ && DW_BLOCK (attr)->data[0] == DW_OP_constu)
+ {
+ struct dwarf_block blk;
+ int num_read;
+
+ blk.size = DW_BLOCK (attr)->size - 1;
+ blk.data = DW_BLOCK (attr)->data + 1;
+ fnp->voffset = read_unsigned_leb128 (NULL, (gdb_byte *) blk.data,
+ &num_read);
+ if (num_read > blk.size)
+ dwarf2_invalid_attrib_class_complaint
("DW_AT_vtable_elem_location",
+ fieldname);
+ fnp->fcontext = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
+ }
+
else
dwarf2_complex_location_expr_complaint ();
}