[PATCH] D103131: support debug info for alias variable

via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 12 12:11:34 PDT 2021


> >   0x0000002a:   DW_TAG_variable
> >                   DW_AT_name      ("oldname")
> >                   DW_AT_type      (0x0000003f "int")
> >                   DW_AT_external  (true)
> >                   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >                   DW_AT_decl_line (1)
> >                   DW_AT_location  (DW_OP_addr 0x0)
> >
> >   0x0000003f:   DW_TAG_base_type
> >                   DW_AT_name      ("int")
> >                   DW_AT_encoding  (DW_ATE_signed)
> >                   DW_AT_byte_size (0x04)
> >
> >   0x00000046:   DW_TAG_variable
> >                   DW_AT_name      ("newname")
> >                   DW_AT_type      (0x0000003f "int")
> >                   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >                   DW_AT_decl_line (2)
> >                   DW_AT_declaration       (true)
> >
> >   0x00000051:   DW_TAG_imported_declaration
> >                   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >                   DW_AT_decl_line (2)
> >                   DW_AT_import    (0x00000046)
> >                   DW_AT_name      ("newname")

I agree with David, this sequence doesn't seem to do what's desired.
There's nothing that ties "newname" to "oldname" here.  What you 
want is something more like this:

0x0000002a: DW_TAG_variable
              DW_AT_name ("oldname")
              ...
0x0000003a: DW_TAG_imported_declaration
              DW_AT_import (0x0000002a)
              DW_AT_name ("newname")

That is, there would not be a separate DW_TAG_variable for "newname";
instead, the imported_declaration would import the DIE for "oldname"
giving it the name "newname".

--paulr



More information about the cfe-commits mailing list