New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debuginfo: Generate DW_TAG_template_type_parameter DIEs for generic types #9224

Open
michaelwoerister opened this Issue Sep 16, 2013 · 9 comments

Comments

Projects
None yet
5 participants
@michaelwoerister
Contributor

michaelwoerister commented Sep 16, 2013

Section 5.5.8 Class Template Instantiations of the DWARF 4 standard says:

A class template instantiation is represented by a debugging information entry with the tag DW_TAG_class_type, DW_TAG_structure_type or DW_TAG_union_type. With five exceptions, such an entry will contain the same attributes and have the same types of child entries as would an entry for a class type defined explicitly using the instantiation types and values.

and later (two of the five mentioned exceptions):

Each formal parameterized type declaration appearing in the template definition is
represented by a debugging information entry with the tag DW_TAG_template_type_parameter. [...]

The class type entry and each of its child entries references a template type parameter entry in any circumstance where the source template definition references a formal parameterized type. [...]

These things are not done yet: For generic types we describe their monomorphized version, losing the information that they stem from a generic definition. In order to fix this issue, the following two things need to be done:

  1. Create DW_TAG_template_type_parameter metadata entries for each generic parameter like already done for generic functions.
  2. Reference these metadata entries where they are use in the type definition---instead of directly referencing the type they have been substituted by.
@flaper87

This comment has been minimized.

Contributor

flaper87 commented Feb 18, 2014

Triage bump... Nothing has been done here yet.

@steveklabnik

This comment has been minimized.

Member

steveklabnik commented Apr 21, 2015

Triage: still no change

@steveklabnik

This comment has been minimized.

Member

steveklabnik commented Nov 29, 2016

Triage: no change

@Mark-Simulacrum

This comment has been minimized.

Member

Mark-Simulacrum commented Apr 28, 2017

I'm a little confused by this issue, since gdb seems to indicate the same output from both C++ code (g++ compiled). Perhaps someone could explain what specifically we expect to be different? I've provided C++ and Rust code below as well as gdb output (which is effectively identical). This issue is somewhat similar to #8641 in my opinion.

template<class T>
struct generic {
    T a;
};

struct normal {
    int a;
};

int main() {
    auto generic_t = generic<int> { 10 };
    auto normal_t = normal { 10 };
    return 0;
}
(gdb) info types generic
All types matching regular expression "generic":

File ./test.cpp:
generic<int>;
(gdb) info types normal
All types matching regular expression "normal":

File ./test.cpp:
normal;
(gdb)
pub struct Generic<T: Clone>(T);
pub struct Normal(i32);

fn main () {
    let generic = Generic(10);
    let normal = Normal(10);
    generic;
    normal;
}
(gdb) info types Generic
All types matching regular expression "Generic":

File /tmp/tmp.hAwRDXXf4B/test.rs:
struct Generic<i32>;
(gdb) info types Normal
All types matching regular expression "Normal":

File /tmp/tmp.hAwRDXXf4B/test.rs:
struct Normal;
@Mark-Simulacrum

This comment has been minimized.

Member

Mark-Simulacrum commented Jun 22, 2017

We generate DW_TAG_template_type_param today, and I'm not sure if we did before. GDB output remains the same.

 <5><12233>: Abbrev Number: 66 (DW_TAG_template_type_param)
    <12234>   DW_AT_type        : <0x1be6c>
    <12238>   DW_AT_name        : (indirect string, offset: 0x8df78): T
@tromey

This comment has been minimized.

Contributor

tromey commented Aug 5, 2017

We generate DW_TAG_template_type_param today

Not always, for example in the test case given earlier, I don't see template tags. The DWARF for Generic<i32> is just:

 <2><81>: Abbrev Number: 6 (DW_TAG_structure_type)
    <82>   DW_AT_name        : (indirect string, offset: 0x6e): Generic<i32>
    <86>   DW_AT_byte_size   : 4
    <87>   Unknown AT value: 88: 4
 <3><88>: Abbrev Number: 7 (DW_TAG_member)
    <89>   DW_AT_name        : (indirect string, offset: 0x66): __0
    <8d>   DW_AT_type        : <0xa8>
    <91>   Unknown AT value: 88: 4
    <92>   DW_AT_data_member_location: 0
 <3><93>: Abbrev Number: 0

(Ignore that unknown AT value thing, that's an out-of-date objdump.)

@tromey

This comment has been minimized.

Contributor

tromey commented Aug 5, 2017

@michaelwoerister

This comment has been minimized.

Contributor

michaelwoerister commented Aug 7, 2017

Yes, template parameter descriptions are only emitted for functions and methods. There is no reason why data types should not be supported. It just has never been urgent enough for someone to put time into it.

tromey added a commit to tromey/rust that referenced this issue Oct 12, 2018

Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224

@tromey tromey referenced a pull request that will close this issue Oct 12, 2018

Open

Add template parameter debuginfo to generic types #55010

@tromey

This comment has been minimized.

Contributor

tromey commented Oct 12, 2018

That was the wrong gdb bug btw, the correct one is https://sourceware.org/bugzilla/show_bug.cgi?id=21893

tromey added a commit to tromey/rust that referenced this issue Oct 15, 2018

Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224

tromey added a commit to tromey/rust that referenced this issue Oct 22, 2018

Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224

pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 25, 2018

Rollup merge of rust-lang#55010 - tromey:Bug-9224-generic-parameters,…
… r=michaelwoerister

Add template parameter debuginfo to generic types

This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224

bors added a commit that referenced this issue Oct 27, 2018

Auto merge of #55010 - tromey:Bug-9224-generic-parameters, r=michaelw…
…oerister

Add template parameter debuginfo to generic types

This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes #9224

tromey added a commit to tromey/rust that referenced this issue Oct 30, 2018

Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224

bors added a commit that referenced this issue Oct 30, 2018

Auto merge of #55010 - tromey:Bug-9224-generic-parameters, r=michaelw…
…oerister

Add template parameter debuginfo to generic types

This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes #9224

tromey added a commit to tromey/rust that referenced this issue Nov 13, 2018

Add template parameter debuginfo to generic types
This changes debuginfo generation to add template parameters to
generic types.  With this change the DWARF now has
DW_TAG_template_type_param for types, not just for functions, like:

 <2><40d>: Abbrev Number: 6 (DW_TAG_structure_type)
    <40e>   DW_AT_name        : (indirect string, offset: 0x375): Generic<i32>
    <412>   DW_AT_byte_size   : 4
    <413>   DW_AT_alignment   : 4
...
 <3><41f>: Abbrev Number: 8 (DW_TAG_template_type_param)
    <420>   DW_AT_type        : <0x42a>
    <424>   DW_AT_name        : (indirect string, offset: 0xa65e): T

Closes rust-lang#9224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment