From eb331446e3bee812d1df19cf59eb2d23d287ac74 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 7 Jan 2019 09:31:31 -0500 Subject: Feature/serialization debug info (#767) * Remove AppContext. Use StdChannels to hold writers, and TestToolUtil to hold test tool specific functionality. * StdChannels -> StdWriters * getStdOut -> getOut, getStdError -> getError * Renamed main.cpp files of tools to try and stop visual studio getting confused between files - such that clicking on an error takes editor to the right location. * Work in progress on being able to serialize debug information. * * Added MemoryStream * First pass converting to IRSerialData * Able to read and write IRSerialData with debug data * Start at reconstruting IR serialized data. * First pass of generation debug SourceLocs from debug data. Works for test set for line nos. * Bug fixes. Moved testing of serialization into IRSerialUtil * Work around problem with irModule = generateIRForTranslationUnit(translationUnit); two times in a row produces different output(!). Fix by just creating once. * Remove problem with use of ternary op in slang.cpp on gcc/clang. * Added -verify-debug-serial-ir option that makes IR modules go through full serialization with debug information and verification. * Add a test that does serial debug verification that is run by default on linux. --- source/core/stream.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'source/core/stream.h') diff --git a/source/core/stream.h b/source/core/stream.h index 4eea6a909..67a3549e9 100644 --- a/source/core/stream.h +++ b/source/core/stream.h @@ -53,7 +53,7 @@ namespace Slang enum class FileAccess { - Read = 1, Write = 2, ReadWrite = 3 + None = 0, Read = 1, Write = 2, ReadWrite = 3 }; enum class FileShare @@ -61,6 +61,32 @@ namespace Slang None, ReadOnly, WriteOnly, ReadWrite }; + class MemoryStream : public Stream + { + public: + virtual Int64 GetPosition() SLANG_OVERRIDE { return m_position; } + virtual void Seek(SeekOrigin origin, Int64 offset) SLANG_OVERRIDE; + virtual Int64 Read(void * buffer, Int64 length) SLANG_OVERRIDE; + virtual Int64 Write(const void * buffer, Int64 length) SLANG_OVERRIDE; + virtual bool IsEnd() SLANG_OVERRIDE { return m_atEnd; } + virtual bool CanRead() SLANG_OVERRIDE { return (int(m_access) & int(FileAccess::Read)) != 0; } + virtual bool CanWrite() SLANG_OVERRIDE { return (int(m_access) & int(FileAccess::Write)) != 0; } + virtual void Close() SLANG_OVERRIDE { m_access = FileAccess::None; } + + MemoryStream(FileAccess access) : + m_access(access), + m_position(0), + m_atEnd(false) + {} + + UInt m_position; + + bool m_atEnd; ///< Happens when a read is done and nothing can be returned because already at end + + FileAccess m_access; + List m_contents; + }; + class FileStream : public Stream { private: -- cgit v1.2.3