nitesh.jain created this revision. Herald added subscribers: arichardson, sdardis.
The implementation of Address::GetAddressClass() is based on file address. Those it will give incorrect result if there are more than one section for a particular file address. For example (see attach log), there are two sections (.text and .debug_ranges) for the file address 0xbcf0. Hence the Address::GetAddressClass() will return "eAddressClassDebug" instead of "eAddressClassCode". This will cause breakpoint failure and incorrect disassembly view. In these patch, the Address::GetAddressClass() will return AddressClass based on the loaded Section and fall back to file address if its failed. F3765058: log <https://reviews.llvm.org/F3765058> https://reviews.llvm.org/D35784 Files: include/lldb/Symbol/ObjectFile.h include/lldb/lldb-enumerations.h source/Core/Address.cpp source/Symbol/ObjectFile.cpp
Index: source/Symbol/ObjectFile.cpp =================================================================== --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -315,6 +315,65 @@ return false; } +AddressClass ObjectFile::SectionTypeToAddressClass(const SectionType st) { + switch (st) { + case eSectionTypeInvalid: + return eAddressClassUnknown; + case eSectionTypeCode: + return eAddressClassCode; + case eSectionTypeContainer: + return eAddressClassUnknown; + case eSectionTypeData: + case eSectionTypeDataCString: + case eSectionTypeDataCStringPointers: + case eSectionTypeDataSymbolAddress: + case eSectionTypeData4: + case eSectionTypeData8: + case eSectionTypeData16: + case eSectionTypeDataPointers: + case eSectionTypeZeroFill: + case eSectionTypeDataObjCMessageRefs: + case eSectionTypeDataObjCCFStrings: + case eSectionTypeGoSymtab: + return eAddressClassData; + case eSectionTypeDebug: + case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAddr: + case eSectionTypeDWARFDebugAranges: + case eSectionTypeDWARFDebugFrame: + case eSectionTypeDWARFDebugInfo: + case eSectionTypeDWARFDebugLine: + case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugMacInfo: + case eSectionTypeDWARFDebugMacro: + case eSectionTypeDWARFDebugPubNames: + case eSectionTypeDWARFDebugPubTypes: + case eSectionTypeDWARFDebugRanges: + case eSectionTypeDWARFDebugStr: + case eSectionTypeDWARFDebugStrOffsets: + case eSectionTypeDWARFAppleNames: + case eSectionTypeDWARFAppleTypes: + case eSectionTypeDWARFAppleNamespaces: + case eSectionTypeDWARFAppleObjC: + return eAddressClassDebug; + case eSectionTypeEHFrame: + case eSectionTypeARMexidx: + case eSectionTypeARMextab: + case eSectionTypeCompactUnwind: + return eAddressClassRuntime; + case eSectionTypeELFSymbolTable: + case eSectionTypeELFDynamicSymbols: + case eSectionTypeELFRelocationEntries: + case eSectionTypeELFDynamicLinkInfo: + case eSectionTypeOther: + return eAddressClassUnknown; + case eSectionTypeAbsoluteAddress: + return eAddressClassTypeAbsoluteAddress; + default: + return eAddressClassUnknown; + } +} + AddressClass ObjectFile::GetAddressClass(addr_t file_addr) { Symtab *symtab = GetSymtab(); if (symtab) { @@ -324,68 +383,15 @@ const SectionSP section_sp(symbol->GetAddressRef().GetSection()); if (section_sp) { const SectionType section_type = section_sp->GetType(); - switch (section_type) { - case eSectionTypeInvalid: - return eAddressClassUnknown; - case eSectionTypeCode: - return eAddressClassCode; - case eSectionTypeContainer: - return eAddressClassUnknown; - case eSectionTypeData: - case eSectionTypeDataCString: - case eSectionTypeDataCStringPointers: - case eSectionTypeDataSymbolAddress: - case eSectionTypeData4: - case eSectionTypeData8: - case eSectionTypeData16: - case eSectionTypeDataPointers: - case eSectionTypeZeroFill: - case eSectionTypeDataObjCMessageRefs: - case eSectionTypeDataObjCCFStrings: - case eSectionTypeGoSymtab: - return eAddressClassData; - case eSectionTypeDebug: - case eSectionTypeDWARFDebugAbbrev: - case eSectionTypeDWARFDebugAddr: - case eSectionTypeDWARFDebugAranges: - case eSectionTypeDWARFDebugFrame: - case eSectionTypeDWARFDebugInfo: - case eSectionTypeDWARFDebugLine: - case eSectionTypeDWARFDebugLoc: - case eSectionTypeDWARFDebugMacInfo: - case eSectionTypeDWARFDebugMacro: - case eSectionTypeDWARFDebugPubNames: - case eSectionTypeDWARFDebugPubTypes: - case eSectionTypeDWARFDebugRanges: - case eSectionTypeDWARFDebugStr: - case eSectionTypeDWARFDebugStrOffsets: - case eSectionTypeDWARFAppleNames: - case eSectionTypeDWARFAppleTypes: - case eSectionTypeDWARFAppleNamespaces: - case eSectionTypeDWARFAppleObjC: - return eAddressClassDebug; - case eSectionTypeEHFrame: - case eSectionTypeARMexidx: - case eSectionTypeARMextab: - case eSectionTypeCompactUnwind: - return eAddressClassRuntime; - case eSectionTypeELFSymbolTable: - case eSectionTypeELFDynamicSymbols: - case eSectionTypeELFRelocationEntries: - case eSectionTypeELFDynamicLinkInfo: - case eSectionTypeOther: - return eAddressClassUnknown; - case eSectionTypeAbsoluteAddress: - // In case of absolute sections decide the address class based on - // the symbol - // type because the section type isn't specify if it is a code or a - // data - // section. - break; - } + AddressClass addr_class; + addr_class = ObjectFile::SectionTypeToAddressClass(section_type); + // In case of absolute sections decide the address class based on + // the symbol type because the section type isn't specify + // if it is a code or a data section + if (addr_class != eAddressClassTypeAbsoluteAddress) + return addr_class; } } - const SymbolType symbol_type = symbol->GetType(); switch (symbol_type) { case eSymbolTypeAny: Index: source/Core/Address.cpp =================================================================== --- source/Core/Address.cpp +++ source/Core/Address.cpp @@ -990,6 +990,17 @@ } AddressClass Address::GetAddressClass() const { + // Get address class based on loaded Section type + SectionSP section_sp(GetSection()); + if (section_sp) { + const SectionType section_type = section_sp->GetType(); + AddressClass addr_class; + addr_class = ObjectFile::SectionTypeToAddressClass(section_type); + if (addr_class != eAddressClassTypeAbsoluteAddress) + return addr_class; + } + + // Get Address class based on file address ModuleSP module_sp(GetModule()); if (module_sp) { ObjectFile *obj_file = module_sp->GetObjectFile(); Index: include/lldb/lldb-enumerations.h =================================================================== --- include/lldb/lldb-enumerations.h +++ include/lldb/lldb-enumerations.h @@ -825,7 +825,8 @@ eAddressClassCodeAlternateISA, eAddressClassData, eAddressClassDebug, - eAddressClassRuntime + eAddressClassRuntime, + eAddressClassTypeAbsoluteAddress }; //---------------------------------------------------------------------- Index: include/lldb/Symbol/ObjectFile.h =================================================================== --- include/lldb/Symbol/ObjectFile.h +++ include/lldb/Symbol/ObjectFile.h @@ -241,6 +241,9 @@ //------------------------------------------------------------------ virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr); + static lldb::AddressClass + SectionTypeToAddressClass(const lldb::SectionType st); + //------------------------------------------------------------------ /// Extract the dependent modules from an object file. ///
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits