diff options
| author | Nilanjana Basu <nilanjana.basu87@gmail.com> | 2019-07-03 00:51:49 +0000 | 
|---|---|---|
| committer | Nilanjana Basu <nilanjana.basu87@gmail.com> | 2019-07-03 00:51:49 +0000 | 
| commit | c0b557744a7d8d87a7e5dd0364b168648d408ea9 (patch) | |
| tree | fd6daf6e8a6a3a58187ed2b40601fc3b3e7e8054 /llvm/lib/DebugInfo/CodeView | |
| parent | efe21088d76c091a29bc7990ef9cf502e1f1bf62 (diff) | |
| download | bcm5719-llvm-c0b557744a7d8d87a7e5dd0364b168648d408ea9.tar.gz bcm5719-llvm-c0b557744a7d8d87a7e5dd0364b168648d408ea9.zip  | |
Revert Changing CodeView debug info type record representation in assembly files to make it more human-readable & editable
This reverts r364982 (git commit 2082bf28ebea76cc187b508f801122866420d9ff)
llvm-svn: 364987
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
| -rw-r--r-- | llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp | 15 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp | 126 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp | 19 | 
3 files changed, 24 insertions, 136 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp index ec4773d571c..dd6f75f97a4 100644 --- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp +++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp @@ -209,14 +209,6 @@ struct VisitHelper {      }    } -  VisitHelper(TypeVisitorCallbackPipeline &Callbacks, VisitorDataSource Source) -      : Visitor((Source == VDS_BytesPresent) ? Pipeline : Callbacks) { -    if (Source == VDS_BytesPresent) { -      Pipeline = Callbacks; -      Pipeline.addCallbackToPipelineFront(Deserializer); -    } -  } -    TypeDeserializer Deserializer;    TypeVisitorCallbackPipeline Pipeline;    CVTypeVisitor Visitor; @@ -230,13 +222,6 @@ Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index,    return V.Visitor.visitTypeRecord(Record, Index);  } -Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index, -                                      TypeVisitorCallbackPipeline &Callbacks, -                                      VisitorDataSource Source) { -  VisitHelper V(Callbacks, Source); -  return V.Visitor.visitTypeRecord(Record, Index); -} -  Error llvm::codeview::visitTypeRecord(CVType &Record,                                        TypeVisitorCallbacks &Callbacks,                                        VisitorDataSource Source) { diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 2b69a1e0768..92c795ab8fa 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -20,7 +20,6 @@ Error CodeViewRecordIO::beginRecord(Optional<uint32_t> MaxLength) {    Limit.MaxLength = MaxLength;    Limit.BeginOffset = getCurrentOffset();    Limits.push_back(Limit); -  resetStreamedLen();    return Error::success();  } @@ -35,29 +34,10 @@ Error CodeViewRecordIO::endRecord() {    // we don't know how big the record is until we're finished writing it, so    // even though we don't commit the extraneous data, we still can't guarantee    // we're at the end of the allocated data. - -  if (isStreaming()) { -    // For streaming mode, add padding to align with 4 byte boundaries for each -    // record -    uint32_t Align = getStreamedLen() % 4; -    if (Align == 0) -      return Error::success(); - -    int PaddingBytes = 4 - Align; -    while (PaddingBytes > 0) { -      char Pad = static_cast<uint8_t>(LF_PAD0 + PaddingBytes); -      StringRef BytesSR = StringRef(&Pad, sizeof(Pad)); -      Streamer->EmitBytes(BytesSR); -      --PaddingBytes; -    } -  }    return Error::success();  }  uint32_t CodeViewRecordIO::maxFieldLength() const { -  if (isStreaming()) -    return 0; -    assert(!Limits.empty() && "Not in a record!");    // The max length of the next field is the minimum of all lengths that would @@ -98,10 +78,7 @@ Error CodeViewRecordIO::skipPadding() {  }  Error CodeViewRecordIO::mapByteVectorTail(ArrayRef<uint8_t> &Bytes) { -  if (isStreaming()) { -    Streamer->EmitBinaryData(toStringRef(Bytes)); -    incrStreamedLen(Bytes.size()); -  } else if (isWriting()) { +  if (isWriting()) {      if (auto EC = Writer->writeBytes(Bytes))        return EC;    } else { @@ -122,28 +99,21 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) {  }  Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { -  if (isStreaming()) { -    Streamer->EmitIntValue(TypeInd.getIndex(), sizeof(TypeInd.getIndex())); -    incrStreamedLen(sizeof(TypeInd.getIndex())); -  } else if (isWriting()) { +  if (isWriting()) {      if (auto EC = Writer->writeInteger(TypeInd.getIndex()))        return EC; -  } else { -    uint32_t I; -    if (auto EC = Reader->readInteger(I)) -      return EC; -    TypeInd.setIndex(I); +    return Error::success();    } + +  uint32_t I; +  if (auto EC = Reader->readInteger(I)) +    return EC; +  TypeInd.setIndex(I);    return Error::success();  }  Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) { -  if (isStreaming()) { -    if (Value >= 0) -      emitEncodedUnsignedInteger(static_cast<uint64_t>(Value)); -    else -      emitEncodedSignedInteger(Value); -  } else if (isWriting()) { +  if (isWriting()) {      if (Value >= 0) {        if (auto EC = writeEncodedUnsignedInteger(static_cast<uint64_t>(Value)))          return EC; @@ -162,9 +132,7 @@ Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) {  }  Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) { -  if (isStreaming()) -    emitEncodedUnsignedInteger(Value); -  else if (isWriting()) { +  if (isWriting()) {      if (auto EC = writeEncodedUnsignedInteger(Value))        return EC;    } else { @@ -177,26 +145,17 @@ Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) {  }  Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value) { -  if (isStreaming()) { -    if (Value.isSigned()) -      emitEncodedSignedInteger(Value.getSExtValue()); -    else -      emitEncodedUnsignedInteger(Value.getZExtValue()); -  } else if (isWriting()) { +  if (isWriting()) {      if (Value.isSigned())        return writeEncodedSignedInteger(Value.getSExtValue());      return writeEncodedUnsignedInteger(Value.getZExtValue()); -  } else -    return consume(*Reader, Value); -  return Error::success(); +  } + +  return consume(*Reader, Value);  }  Error CodeViewRecordIO::mapStringZ(StringRef &Value) { -  if (isStreaming()) { -    auto NullTerminatedString = StringRef(Value.data(), Value.size() + 1); -    Streamer->EmitBytes(NullTerminatedString); -    incrStreamedLen(NullTerminatedString.size()); -  } else if (isWriting()) { +  if (isWriting()) {      // Truncate if we attempt to write too much.      StringRef S = Value.take_front(maxFieldLength() - 1);      if (auto EC = Writer->writeCString(S)) @@ -210,15 +169,6 @@ Error CodeViewRecordIO::mapStringZ(StringRef &Value) {  Error CodeViewRecordIO::mapGuid(GUID &Guid) {    constexpr uint32_t GuidSize = 16; - -  if (isStreaming()) { -    StringRef GuidSR = -        StringRef((reinterpret_cast<const char *>(&Guid)), GuidSize); -    Streamer->EmitBytes(GuidSR); -    incrStreamedLen(GuidSize); -    return Error::success(); -  } -    if (maxFieldLength() < GuidSize)      return make_error<CodeViewError>(cv_error_code::insufficient_buffer); @@ -235,14 +185,12 @@ Error CodeViewRecordIO::mapGuid(GUID &Guid) {  }  Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { - -  if (!isReading()) { +  if (isWriting()) {      for (auto V : Value) {        if (auto EC = mapStringZ(V))          return EC;      } -    uint8_t FinalZero = 0; -    if (auto EC = mapInteger(FinalZero)) +    if (auto EC = Writer->writeInteger<uint8_t>(0))        return EC;    } else {      StringRef S; @@ -257,46 +205,6 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) {    return Error::success();  } -void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value) { -  assert(Value < 0 && "Encoded integer is not signed!"); -  if (Value >= std::numeric_limits<int8_t>::min()) { -    Streamer->EmitIntValue(LF_CHAR, 2); -    Streamer->EmitIntValue(Value, 1); -    incrStreamedLen(3); -  } else if (Value >= std::numeric_limits<int16_t>::min()) { -    Streamer->EmitIntValue(LF_SHORT, 2); -    Streamer->EmitIntValue(Value, 2); -    incrStreamedLen(4); -  } else if (Value >= std::numeric_limits<int32_t>::min()) { -    Streamer->EmitIntValue(LF_LONG, 2); -    Streamer->EmitIntValue(Value, 4); -    incrStreamedLen(6); -  } else { -    Streamer->EmitIntValue(LF_QUADWORD, 2); -    Streamer->EmitIntValue(Value, 4); -    incrStreamedLen(6); -  } -} - -void CodeViewRecordIO::emitEncodedUnsignedInteger(const uint64_t &Value) { -  if (Value < LF_NUMERIC) { -    Streamer->EmitIntValue(Value, 2); -    incrStreamedLen(2); -  } else if (Value <= std::numeric_limits<uint16_t>::max()) { -    Streamer->EmitIntValue(LF_USHORT, 2); -    Streamer->EmitIntValue(Value, 2); -    incrStreamedLen(4); -  } else if (Value <= std::numeric_limits<uint32_t>::max()) { -    Streamer->EmitIntValue(LF_ULONG, 2); -    Streamer->EmitIntValue(Value, 4); -    incrStreamedLen(6); -  } else { -    Streamer->EmitIntValue(LF_UQUADWORD, 2); -    Streamer->EmitIntValue(Value, 8); -    incrStreamedLen(6); -  } -} -  Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) {    assert(Value < 0 && "Encoded integer is not signed!");    if (Value >= std::numeric_limits<int8_t>::min()) { diff --git a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp index 104e310d41b..12fb50d6ddc 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp @@ -29,7 +29,7 @@ struct MapOneMethodRecord {      error(IO.mapInteger(Method.Type));      if (Method.isIntroducingVirtual()) {        error(IO.mapInteger(Method.VFTableOffset)); -    } else if (IO.isReading()) +    } else if (!IO.isWriting())        Method.VFTableOffset = -1;      if (!IsFromOverloadList) @@ -72,9 +72,6 @@ static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name,        error(IO.mapStringZ(N));      }    } else { -    // Reading & Streaming mode come after writing mode is executed for each -    // record. Truncating large names are done during writing, so its not -    // necessary to do it while reading or streaming.      error(IO.mapStringZ(Name));      if (HasUniqueName)        error(IO.mapStringZ(UniqueName)); @@ -99,10 +96,6 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) {    return Error::success();  } -Error TypeRecordMapping::visitTypeBegin(CVType &CVR, TypeIndex Index) { -  return visitTypeBegin(CVR); -} -  Error TypeRecordMapping::visitTypeEnd(CVType &Record) {    assert(TypeKind.hasValue() && "Not in a type mapping!");    assert(!MemberKind.hasValue() && "Still in a member mapping!"); @@ -133,7 +126,7 @@ Error TypeRecordMapping::visitMemberEnd(CVMemberRecord &Record) {    assert(TypeKind.hasValue() && "Not in a type mapping!");    assert(MemberKind.hasValue() && "Not in a member mapping!"); -  if (IO.isReading()) { +  if (!IO.isWriting()) {      if (auto EC = IO.skipPadding())        return EC;    } @@ -146,6 +139,7 @@ Error TypeRecordMapping::visitMemberEnd(CVMemberRecord &Record) {  Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) {    error(IO.mapInteger(Record.ModifiedType));    error(IO.mapEnum(Record.Modifiers)); +    return Error::success();  } @@ -178,6 +172,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArgListRecord &Record) {    error(IO.mapVectorN<uint32_t>(        Record.ArgIndices,        [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); +    return Error::success();  } @@ -195,7 +190,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) {    error(IO.mapInteger(Record.Attrs));    if (Record.isPointerToMember()) { -    if (IO.isReading()) +    if (!IO.isWriting())        Record.MemberInfo.emplace();      MemberPointerInfo &M = *Record.MemberInfo; @@ -265,7 +260,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, BitFieldRecord &Record) {  Error TypeRecordMapping::visitKnownRecord(CVType &CVR,                                            VFTableShapeRecord &Record) {    uint16_t Size; -  if (!IO.isReading()) { +  if (IO.isWriting()) {      ArrayRef<VFTableSlotKind> Slots = Record.getSlots();      Size = Slots.size();      error(IO.mapInteger(Size)); @@ -296,7 +291,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, VFTableRecord &Record) {    error(IO.mapInteger(Record.OverriddenVFTable));    error(IO.mapInteger(Record.VFPtrOffset));    uint32_t NamesLen = 0; -  if (!IO.isReading()) { +  if (IO.isWriting()) {      for (auto Name : Record.MethodNames)        NamesLen += Name.size() + 1;    }  | 

