Skip to content

Commit

Permalink
Cleanups.
Browse files Browse the repository at this point in the history
- Add clarifying comment.
- Slightly adjust handling of augmentation 'P' so it also handles
  skipping LEB128-encoded values correctly.
- Remove unused code.
  • Loading branch information
anevilyak committed Dec 24, 2012
1 parent d802af6 commit b83bece
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions src/apps/debugger/dwarf/DwarfFile.cpp
Expand Up @@ -234,8 +234,11 @@ struct DwarfFile::CIEAugmentation {
:
fString(NULL),
fFlags(0),
fAddressEncoding(0)
fAddressEncoding(CFI_ADDRESS_FORMAT_ABSOLUTE)
{
// we default to absolute address format since that corresponds
// to the DWARF standard for .debug_frame. In gcc's case, however,
// .eh_frame will generally override that via augmentation 'R'
}

void Init(DataReader& dataReader)
Expand Down Expand Up @@ -270,11 +273,12 @@ struct DwarfFile::CIEAugmentation {
break;
case 'P':
{
char personalityEncoding = dataReader.Read<char>(0);
uint8 addressSize = EncodedAddressSize(
personalityEncoding, NULL);
dataReader.Skip(addressSize);
remaining -= addressSize + 1;
char tempEncoding = fAddressEncoding;
fAddressEncoding = dataReader.Read<char>(0);
off_t offset = dataReader.Offset();
ReadEncodedAddress(dataReader, NULL, NULL, true);
fAddressEncoding = tempEncoding;
remaining -= dataReader.Offset() - offset + 1;
break;
}
case 'R':
Expand Down Expand Up @@ -370,24 +374,6 @@ struct DwarfFile::CIEAugmentation {
return 0;
}

int8 EncodedAddressSize(char encoding, CompilationUnit* unit) const
{
switch (encoding & 0x07) {
case CFI_ADDRESS_FORMAT_ABSOLUTE:
return unit->AddressSize();
case CFI_ADDRESS_FORMAT_UNSIGNED_16:
return 2;
case CFI_ADDRESS_FORMAT_UNSIGNED_32:
return 4;
case CFI_ADDRESS_FORMAT_UNSIGNED_64:
return 8;
}

// TODO: gcc doesn't (currently) actually generate LEB128-formatted
// addresses. If that changes, we'll need to handle them accordingly
return 0;
}

uint8 FDEAddressType() const
{
return fAddressEncoding & 0x70;
Expand Down

0 comments on commit b83bece

Please sign in to comment.