kamleshbhalui added a comment. In D103131#2815386 <https://reviews.llvm.org/D103131#2815386>, @probinson wrote:
>>> 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 Even this does not work with gdb. Here is what gdb says, (gdb) ptype newname type = <data variable, no debug info> (gdb) p newname 'newname' has unknown type; cast it to its declared type (gdb) p oldname $1 = 1 (gdb) ptype oldname type = int (gdb) -------------- dumped debug info (using llvm-dwarfdump) test.o: file format elf64-x86-64 .debug_info contents: 0x00000000: Compile Unit: length = 0x00000067, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000006b) 0x0000000b: DW_TAG_compile_unit DW_AT_producer ("clang version 13.0.0 (g...@github.com:llvm/llvm-project.git 4cd7169f5517167ef456e82c6dcae669bde6c725)") DW_AT_language (DW_LANG_C99) DW_AT_name ("test.c") DW_AT_stmt_list (0x00000000) DW_AT_comp_dir ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin") DW_AT_low_pc (0x0000000000000000) DW_AT_high_pc (0x0000000000000008) 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_imported_declaration DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c") DW_AT_decl_line (2) DW_AT_import (0x0000002a) DW_AT_name ("newname") 0x00000051: DW_TAG_subprogram DW_AT_low_pc (0x0000000000000000) DW_AT_high_pc (0x0000000000000008) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_name ("main") DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c") DW_AT_decl_line (3) DW_AT_type (0x0000003f "int") DW_AT_external (true) 0x0000006a: NULL Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103131/new/ https://reviews.llvm.org/D103131 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits