This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc/cp] method stub assertions

On Tue, 6 Jan 2004 12:05:23 -0500, Daniel Jacobowitz <> said:

> The debug information for A::bad6 does not specify that it is a
> method.  Rather only the debug info for class A specifies that it
> has a method named A::bad6.

I'm coming into this discussion late (without closely reading all of
it, no less), so I may be missing something, but I wouldn't phrase
things this way.  I've compiled the following file (g++ -g -S -dA)

class C {
    int foo();

int C::foo() {
    return 1;

and get, among other things, this output:

# Start of debug info for C.

	.uleb128 0x2	# (DIE (0x25) DW_TAG_structure_type)
	.long	0x8f	# DW_AT_sibling
	.ascii "C\0"	# DW_AT_name
	.byte	0x1	# DW_AT_byte_size
	.byte	0x1	# DW_AT_decl_file
	.byte	0x1	# DW_AT_decl_line

# Debug info for declaration for C::foo.

	.uleb128 0x7	# (DIE (0x76) DW_TAG_subprogram)
	.byte	0x1	# DW_AT_external
	.ascii "foo\0"	# DW_AT_name
	.byte	0x1	# DW_AT_decl_file
	.byte	0x3	# DW_AT_decl_line
	.long	.LC6	# DW_AT_MIPS_linkage_name: "_ZN1C3fooEv"
	.long	0xa6	# DW_AT_type
	.byte	0x1	# DW_AT_declaration


# Done with debug info for C.

	.byte	0x0	# end of children of DIE 0x25


# Start of debug info for definition of C::foo.

	.uleb128 0xc	# (DIE (0xad) DW_TAG_subprogram)
	.long	0xcf	# DW_AT_sibling
	.long	0x76	# DW_AT_specification

That DW_AT_specification in the definition of C::foo refers to DIE
0x76, which is the declaration for C::foo.  And the declaration for
C::foo is nested within the die for C.  So if we're reading the
definition for C::foo, it wouldn't be hard at all to find out that the
DW_TAG_subprogram in question is in fact a method of a class instead
of a free function: follow the specification, and look at its parent
DIE.  (It would have been hard a few months ago, but it's not hard
now. :-) )

David Carlton

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]