From 1fe5e83f3dcc8ef0efa2dd083ebdfab5d0f101a9 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 18 Jul 2023 18:45:38 -0400 Subject: nsight Aftermath crash example (#2984) * Small fixes and improvements around reflection tool. * Make PrettyWriter printing a class. * Aftermath crash demo WIP. * Enable aftermath in test project. * Setting failCount. * Dumping out of source maps. * Improve comments. Simplify handling of compile products. * Other small fixes to aftermath example. * Added Emit SourceLocType. Track sourcemap association meaning. Improved documentation. * Small improvements. * Capture debug information for D3D11/D3D12/Vulkan. * Enable debug info. * Small improvements. * Improve aftermath example README.md. --- source/compiler-core/slang-source-loc.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'source/compiler-core/slang-source-loc.h') diff --git a/source/compiler-core/slang-source-loc.h b/source/compiler-core/slang-source-loc.h index fafff7de6..5c78c4293 100644 --- a/source/compiler-core/slang-source-loc.h +++ b/source/compiler-core/slang-source-loc.h @@ -164,6 +164,16 @@ struct SourceRange SourceLoc end; }; +/// Source maps associated with files are could be of different uses. We use the SourceMapKind +/// to indicate the usage. +/// +/// If the source map is obfuscated reasonable/desirable to ignore them on emit (if we didn't we leak information, +/// and we don't emit into the locations in the obfuscated intermediate "file"). +enum class SourceMapKind +{ + Normal, ///< A regular source map + Obfuscated, ///< Obfuscated source map +}; // Pre-declare struct SourceManager; @@ -256,8 +266,11 @@ public: /// Get the source map associated with this file. If it's set when doing /// lookup for source locations, the source map will be used IBoxValue* getSourceMap() const { return m_sourceMap; } + /// Get the source map kind + SourceMapKind getSourceMapKind() const { return m_sourceMapKind; } + /// Set a source map - void setSourceMap(IBoxValue* sourceMap) { m_sourceMap = sourceMap; } + void setSourceMap(IBoxValue* sourceMap, SourceMapKind sourceMapKind) { m_sourceMap = sourceMap; m_sourceMapKind = sourceMapKind; } /// Ctor SourceFile(SourceManager* sourceManager, const PathInfo& pathInfo, size_t contentSize); @@ -281,12 +294,15 @@ public: // If set then the locations in this file are really from locations from elsewhere, // where the SourceMap specifies that mapping ComPtr> m_sourceMap; + // What kind of source map it is (if there is one) + SourceMapKind m_sourceMapKind = SourceMapKind::Normal; }; enum class SourceLocType { Nominal, ///< The normal interpretation which takes into account #line directives and source maps Actual, ///< Ignores #line directives/source maps - and is the location as seen in the actual file + Emit, ///< Behaves the same as `Nominal` but ignores source maps. Used for Emit source locations. }; // A source location in a format a human might like to see @@ -395,6 +411,8 @@ class SourceView /// Get the pathInfo from a string handle. If it's 0, it will return the _getPathInfo PathInfo _getPathInfoFromHandle(StringSlicePool::Handle pathHandle) const; + SlangResult _findSourceMapLoc(SourceLoc loc, SourceLocType type, HandleSourceLoc& outLoc); + String m_viewPath; ///< Path to this view. If empty the path is the path to the SourceView SourceLoc m_initiatingSourceLoc; ///< An optional source loc that defines where this view was initiated from. SourceLoc(0) if not defined. -- cgit v1.2.3