[Bug 16191] New: LLDB fails to evaluate expressions that dereference a struct when inferior is built with recent Clang

Hi Greg, indeed I checked the DWARF and it looks like the definition for that struct is missing from the binary built with newer clang. In the non-working case, the DWARF contains only a declaration:

< 1><0x00000026> DW_TAG_structure_type
                      DW_AT_name "Summarize"
                      DW_AT_declaration yes(1)

As opposed to the full definition in the working case (clang 3.3.1):

< 1><0x0000002d> DW_TAG_structure_type
                      DW_AT_name "Summarize"
                      DW_AT_byte_size 0x00000008
                      DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                      DW_AT_decl_line 0x0000000b
< 2><0x00000035> DW_TAG_member
                        DW_AT_name "first"
                        DW_AT_type <0x00000026>
                        DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                        DW_AT_decl_line 0x0000000d
                        DW_AT_data_member_location DW_OP_plus_uconst 0
                        DW_AT_accessibility DW_ACCESS_public
< 2><0x00000044> DW_TAG_member
                        DW_AT_name "second"
                        DW_AT_type <0x00000026>
                        DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                        DW_AT_decl_line 0x0000000e
                        DW_AT_data_member_location DW_OP_plus_uconst 4
                        DW_AT_accessibility DW_ACCESS_public

So it definitely looks like a clang bug.. Do you know if there's a PR open that I can cross-reference?

Thanks,
Dan

Hi Greg, indeed I checked the DWARF and it looks like the definition for that struct is missing from the binary built with newer clang. In the non-working case, the DWARF contains only a declaration:

< 1><0x00000026> DW_TAG_structure_type
                     DW_AT_name "Summarize"
                     DW_AT_declaration yes(1)

As opposed to the full definition in the working case (clang 3.3.1):

< 1><0x0000002d> DW_TAG_structure_type
                     DW_AT_name "Summarize"
                     DW_AT_byte_size 0x00000008
                     DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                     DW_AT_decl_line 0x0000000b
< 2><0x00000035> DW_TAG_member
                       DW_AT_name "first"
                       DW_AT_type <0x00000026>
                       DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                       DW_AT_decl_line 0x0000000d
                       DW_AT_data_member_location DW_OP_plus_uconst 0
                       DW_AT_accessibility DW_ACCESS_public
< 2><0x00000044> DW_TAG_member
                       DW_AT_name "second"
                       DW_AT_type <0x00000026>
                       DW_AT_decl_file 0x00000001 /home/daniel/dev/llvm/tools/lldb/test/functionalities/data-formatter/rdar-9973865/main.cpp
                       DW_AT_decl_line 0x0000000e
                       DW_AT_data_member_location DW_OP_plus_uconst 4
                       DW_AT_accessibility DW_ACCESS_public

So it definitely looks like a clang bug.. Do you know if there's a PR open that I can cross-reference?

No, this is probably a new bug. There is a lot of code in clang to limit the amount of debug info that gets emitted. If only a forward declaration to a structure is required, the debug info will often try to only emit a forward declaration. There are of course bugs in this. You will want to look at your code and seek if the structure was actually used. If the contents are used in functions that got compiled into the .o file, then there should be full debug info for it and you should file a bug. If the structure doesn't get used, you can't expect it to be around.

If you just want to make sure the type is there because this is for a test, you can force clang to include it by adding extra CFLAGS: -fno-limit-debug-info

Greg

Indeed, -fno-limit-debug-info fixes the issue!

I will file a bug against clang, add that flag to the test Makefile, and
close this bug.

Thanks,
Dan