This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Show implicit_const values when dumping .debug_info section
AbandonedPublic

Authored by vleschuk on Feb 28 2017, 12:54 AM.

Details

Summary

r296253 (http://llvm.org/viewvc/llvm-project?view=revision&revision=296253) introduced incorrect behavior: implicit_const values were skipped when dumping .debug_info section. This patch makes behavior similar to DW_FORM_flag_present: attribute values for such forms are shown in .debug_info output in spite of the fact they are not really present in this section.

Also modified implicit-const-test to check both .debug_abbrev and .debug_info sections.

Diff Detail

Event Timeline

vleschuk created this revision.Feb 28 2017, 12:54 AM
dblaikie added inline comments.Feb 28 2017, 8:45 AM
lib/DebugInfo/DWARF/DWARFDie.cpp
94–95

I wouldn't expect to see a special case here. Is it necessary? I'd expect extractValue to do the work necessary for whatever the attribute kind is (as it already does for form_present, I assume).

I guess the issue is that DWARFFormValue only holds the form enum, not the rest - I think that probably should be changed so that extractValue can still behave uniformly across all forms.

So DWARFFormValue should take the AttributeSpec... oh, but that has the attribute in it.

Maybe what's needed is a thing that represents the form +ByteSizeOrValue. Maybe it could be called "FormSpec" to match "AttributeSpec"? Not sure.

vleschuk marked an inline comment as done.Feb 28 2017, 9:39 AM
vleschuk added inline comments.
lib/DebugInfo/DWARF/DWARFDie.cpp
94–95

I guess the issue is that DWARFFormValue only holds the form enum, not the rest - I think that probably should be changed so that extractValue can still behave uniformly across all forms.

Actually DWARFFormValue holds not only enum but actual value too:

struct ValueType {                                                            
  ValueType() {                                                               
    uval = 0;                                                                 
  }                                                                           
                                                                              
  union {                                                                     
    uint64_t uval;                                                            
    int64_t sval;                                                             
    const char* cstr;                                                         
  };                                                                          
  const uint8_t* data = nullptr;                                              
};                                                                            
                                                                              
dwarf::Form Form; // Form for this value.                                     
ValueType Value; // Contains all data for the form.                             struct ValueType {                                                            
  ValueType() {                                                               
    uval = 0;                                                                 
  }                                                                           
                                                                              
  union {                                                                     
    uint64_t uval;                                                            
    int64_t sval;                                                             
    const char* cstr;                                                         
  };                                                                          
  const uint8_t* data = nullptr;                                              
};                                                                            
                                                                              
dwarf::Form Form; // Form for this value.                                     
ValueType Value; // Contains all data for the form.                           
struct ValueType {                                                            
  ValueType() {                                                               
    uval = 0;                                                                 
  }                                                                           
                                                                              
  union {                                                                     
    uint64_t uval;                                                            
    int64_t sval;                                                             
    const char* cstr;                                                         
  };                                                                          
  const uint8_t* data = nullptr;                                              
};                                                                            
                                                                              
dwarf::Form Form; // Form for this value.                                     
ValueType Value; // Contains all data for the form.

What extractValue() does - it actually fills the ValueType field of DWARFFormValue, for flag_present it just sets Value to "true" and doesn't need additional data. To fill in implicit_const from inside of extractValue() we need to pass the actual value to it and than assign it from within:

formValue.extractValue(/* ... */, int64_t actualValue);
// ... 
bool DWARFFormValue::extractValue(/* ... */, int64_t actualValue) {
  // ....
  case DW_FORM_implicit_const:
  Value.sdata = actualValue;
  break;
  // ...

That looks a little bit weird for me, as lots of useless actions are performed like passing data back and forth. I think having exceptional case for implicit_const in upper stack frame is better way here.

vleschuk abandoned this revision.Jul 29 2018, 11:08 PM
vleschuk marked an inline comment as done.