Skip to content
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

Closed
michaelwoerister opened this issue Sep 16, 2013 · 9 comments
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@michaelwoerister
Copy link
Member

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
Copy link
Contributor

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

@steveklabnik
Copy link
Member

Triage: still no change

@steveklabnik
Copy link
Member

Triage: no change

@Mark-Simulacrum
Copy link
Member

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
Copy link
Member

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

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 19, 2017
@tromey
Copy link
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
Copy link
Contributor

tromey commented Aug 5, 2017

BTW this does affect gdb, see https://sourceware.org/bugzilla/show_bug.cgi?id=21466

@michaelwoerister
Copy link
Member Author

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
Copy link
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 22, 2018
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
… 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
@tromey tromey self-assigned this Nov 20, 2018
tromey added a commit to tromey/rust that referenced this issue Nov 29, 2018
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
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Dec 1, 2018
… 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 Dec 3, 2018
…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
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 28, 2022
check macro statements in `[non_copy_const]`

close rust-lang#8493
close rust-lang#9224

This PR fixes false positives in `[non_copy_const]`.

changelog: fix false positives in`[non_copy_const]`

---

r? `@Jarcho`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants