From 0c4c63b4a575f45f5dcf03f26b78becd36b0efca Mon Sep 17 00:00:00 2001 From: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:55:11 -0700 Subject: Fix missing debug info for the included slang file (#7281) * Fix missing debug info in the included slang file Issue: https://github.com/shader-slang/slang/issues/7271 Debug info including DebugFunction, DebugLocation, and DebugValue are missing in IR for "#included" Slang shader file. The included shader file was not added to TranslationUnit's source file list, therefore mapSourceFileToDebugSourceInst.add() was not called for the source in generateIRForTranslationUnit(), and later mapSourceFileToDebugSourceInst.tryGetValue() could not get value for the source to add DebugLocationDecoration, which led to missing DebugFunction, DebugLocation and other debug info for the included file in IR. Adding the include file in TranslationUnit's source file list fixes the issue. * Add source file using PreprocessorHandler Call _addSourceFile from FrontEndPreprocessorHandler::handleFileDependency. * Just use FrontEndPreprocessorHandler * Make _addSourceFile public * format code * Distingush the included source file * Add m_includedFileSet to avoid adding dup file HashSet m_includedFileSet; --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/compiler-core/slang-source-loc.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-source-loc.h b/source/compiler-core/slang-source-loc.h index 674ed2076..b52f2e50d 100644 --- a/source/compiler-core/slang-source-loc.h +++ b/source/compiler-core/slang-source-loc.h @@ -331,6 +331,12 @@ public: m_sourceMapKind = sourceMapKind; } + /// Set the source file as an included file + void setIncludedFile() { m_included = true; } + + /// Check if the source file is an included file + bool isIncludedFile() { return m_included; } + /// Ctor SourceFile(SourceManager* sourceManager, const PathInfo& pathInfo, size_t contentSize); /// Dtor @@ -360,6 +366,9 @@ protected: ComPtr> m_sourceMap; // What kind of source map it is (if there is one) SourceMapKind m_sourceMapKind = SourceMapKind::Normal; + + // Indicate if the source file is an included file + bool m_included = false; }; enum class SourceLocType -- cgit v1.2.3