[PATCH] D23177: [CodeView] Decouple the type record deserialization from the visitor.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 13:22:10 PDT 2016


zturner created this revision.
zturner added reviewers: rnk, amccarth, ruiu.
zturner added a subscriber: llvm-commits.

Until now, our use case for the visitor has been to take a stream of bytes representing a type stream, deserialize the records in sequence, and do something with them, where "something" is determined by how the user implements a particular set of callbacks on an abstract class.

For actually writing PDBs, however, we want to do the reverse.  We have some kind of description of the list of records in their in-memory format, and we want to process each one.  Perhaps by serializing them to a byte stream, or perhaps by converting them from one description format (Yaml) to another (in-memory representation).

This was difficult in the current model because deserialization and invoking the callbacks were tightly coupled.

With this patch we change this so that `TypeDeserializer` is itself an implementation of the particular set of callbacks.  This decouples deserialization from the iteration over a list of records and invocation of the callbacks.  `TypeDeserializer` is initialized with another implementation of the callback interface, so that upon deserialization it can pass the deserialized record through to the next set of callbacks.  In a sense this is like an implementation of the `Decorator` design pattern, where the Deserializer is a decorator.

This will be useful for writing Pdbs from yaml, where we have a description of the type records in Yaml format.  In this case, the visitor implementation would have each visitation callback method implemented in such a way as to extract the proper set of fields from the Yaml, and it could maintain state that builds up a list of these records.  Finally at the end we can pass this information through to another set of callbacks which serializes them into a byte stream.

https://reviews.llvm.org/D23177

Files:
  include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
  include/llvm/DebugInfo/CodeView/CodeView.h
  include/llvm/DebugInfo/CodeView/CodeViewError.h
  include/llvm/DebugInfo/CodeView/FieldListRecordBuilder.h
  include/llvm/DebugInfo/CodeView/ListRecordBuilder.h
  include/llvm/DebugInfo/CodeView/RecordSerialization.h
  include/llvm/DebugInfo/CodeView/TypeDeserializer.h
  include/llvm/DebugInfo/CodeView/TypeDumper.h
  include/llvm/DebugInfo/CodeView/TypeRecord.h
  include/llvm/DebugInfo/CodeView/TypeRecords.def
  include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
  include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h
  lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  lib/DebugInfo/CodeView/CMakeLists.txt
  lib/DebugInfo/CodeView/CVTypeVisitor.cpp
  lib/DebugInfo/CodeView/CodeViewError.cpp
  lib/DebugInfo/CodeView/FieldListRecordBuilder.cpp
  lib/DebugInfo/CodeView/ListRecordBuilder.cpp
  lib/DebugInfo/CodeView/TypeDeserializer.cpp
  lib/DebugInfo/CodeView/TypeDumper.cpp
  lib/DebugInfo/CodeView/TypeRecord.cpp
  lib/DebugInfo/CodeView/TypeStreamMerger.cpp
  lib/DebugInfo/CodeView/TypeTableBuilder.cpp
  lib/DebugInfo/PDB/Raw/TpiStream.cpp
  tools/llvm-pdbdump/LLVMOutputStyle.cpp
  tools/llvm-pdbdump/LLVMOutputStyle.h
  tools/llvm-readobj/llvm-readobj.cpp
  tools/llvm-readobj/llvm-readobj.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23177.66849.patch
Type: text/x-patch
Size: 82620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160804/f670ab20/attachment-0001.bin>


More information about the llvm-commits mailing list