Michael137 wrote: > Hi @Michael137, we are seeing a failure in one of our internal tests that I > bisected back to this change. Consider the following code: > > ```c++ > struct X > { > static const int constant = 1; > int x; > > X() { x = constant; } > }; > const int X::constant; > > int main() > { > X x; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > return 0; > } > ``` > > Prior to your change, the compiler would generate the following DWARF for the > constant value: > > ``` > 0x0000003a: DW_TAG_member > DW_AT_name ("constant") > DW_AT_type (0x00000057 "const int") > DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") > DW_AT_decl_line (3) > DW_AT_external (true) > DW_AT_declaration (true) > DW_AT_const_value (1) > ``` > > After your change, the DW_AT_const_value is gone from this DW_TAG_member > group, but doesn't appear anywhere else in the DWARF output which seems to > indicate that it was dropped completely which does not seem to be correct. Is > this intended or am I missing something?
> Hi @Michael137, we are seeing a failure in one of our internal tests that I > bisected back to this change. Consider the following code: > > ```c++ > struct X > { > static const int constant = 1; > int x; > > X() { x = constant; } > }; > const int X::constant; > > int main() > { > X x; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > return 0; > } > ``` > > Prior to your change, the compiler would generate the following DWARF for the > constant value: > > ``` > 0x0000003a: DW_TAG_member > DW_AT_name ("constant") > DW_AT_type (0x00000057 "const int") > DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") > DW_AT_decl_line (3) > DW_AT_external (true) > DW_AT_declaration (true) > DW_AT_const_value (1) > ``` > > After your change, the DW_AT_const_value is gone from this DW_TAG_member > group, but doesn't appear anywhere else in the DWARF output which seems to > indicate that it was dropped completely which does not seem to be correct. Is > this intended or am I missing something? Right, we stopped putting the `DW_AT_const_value` on the declaration. Instead we put either the location or the constant on the definition, depending on what's available. In your example you define the variable out-of-class which would generate a `DW_TAG_variable` with a location, so we don't emit the constant for it on the definition. What's the nature of the failure? Would you instead be able to read the value out of the definition? CC @dwblaikie https://github.com/llvm/llvm-project/pull/71780 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits