diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-api.cpp | 8 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.h | 15 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 1 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 74 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 5 |
5 files changed, 88 insertions, 15 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp index 45c583060..a03aa9071 100644 --- a/source/slang/slang-api.cpp +++ b/source/slang/slang-api.cpp @@ -385,6 +385,14 @@ SLANG_API void spSetDebugInfoLevel( request->setDebugInfoLevel(level); } +SLANG_API void spSetDebugInfoFormat( + slang::ICompileRequest* request, + SlangDebugInfoFormat format) +{ + SLANG_ASSERT(request); + request->setDebugInfoFormat(format); +} + SLANG_API void spSetOptimizationLevel( slang::ICompileRequest* request, SlangOptimizationLevel level) diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index f377d4882..e6b173e2a 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -130,6 +130,19 @@ namespace Slang Maximal = SLANG_DEBUG_INFO_LEVEL_MAXIMAL, }; + enum class DebugInfoFormat : SlangDebugInfoFormatIntegral + { + Default = SLANG_DEBUG_INFO_FORMAT_DEFAULT, + C7 = SLANG_DEBUG_INFO_FORMAT_C7, + Pdb = SLANG_DEBUG_INFO_FORMAT_PDB, + + Stabs = SLANG_DEBUG_INFO_FORMAT_STABS, + Coff = SLANG_DEBUG_INFO_FORMAT_COFF, + Dwarf = SLANG_DEBUG_INFO_FORMAT_DWARF, + + CountOf = SLANG_DEBUG_INFO_FORMAT_COUNT_OF, + }; + enum class OptimizationLevel : SlangOptimizationLevelIntegral { None = SLANG_OPTIMIZATION_LEVEL_NONE, @@ -1884,6 +1897,7 @@ namespace Slang MatrixLayoutMode getDefaultMatrixLayoutMode() { return defaultMatrixLayoutMode; } DebugInfoLevel debugInfoLevel = DebugInfoLevel::None; + DebugInfoFormat debugInfoFormat = DebugInfoFormat::Default; OptimizationLevel optimizationLevel = OptimizationLevel::Default; @@ -2595,6 +2609,7 @@ namespace Slang SlangSeverity overrideSeverity) SLANG_OVERRIDE; virtual SLANG_NO_THROW SlangDiagnosticFlags SLANG_MCALL getDiagnosticFlags() SLANG_OVERRIDE; virtual SLANG_NO_THROW void SLANG_MCALL setDiagnosticFlags(SlangDiagnosticFlags flags) SLANG_OVERRIDE; + virtual SLANG_NO_THROW void SLANG_MCALL setDebugInfoFormat(SlangDebugInfoFormat format) SLANG_OVERRIDE; EndToEndCompileRequest( Session* session); diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index aaf09a8be..2401b6e58 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -130,6 +130,7 @@ DIAGNOSTIC( 95, Error, unknownLibraryKind, "unknown library kind '$0'") DIAGNOSTIC( 96, Error, kindNotLinkable, "not a known linkable kind '$0'") DIAGNOSTIC( 97, Error, libraryDoesNotExist, "library '$0' does not exist") DIAGNOSTIC( 98, Error, cannotAccessAsBlob, "cannot access as a blob") +DIAGNOSTIC( 99, Error, unknownDebugOption, "unknown debug option, known options are ($0)") // // 001xx - Downstream Compilers diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 5ac0d7663..60bc087de 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -1497,25 +1497,69 @@ struct OptionsParser compileRequest->setOptimizationLevel(level); } - // Note: unlike with `-O` above, we have to consider that other // options might have names that start with `-g` and so cannot // just detect it as a prefix. - else if( argValue == "-g" || argValue == "-g2" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_STANDARD); - } - else if( argValue == "-g0" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_NONE); - } - else if( argValue == "-g1" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_MINIMAL); - } - else if( argValue == "-g3" ) + else if (argValue.startsWith("-g")) { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_MAXIMAL); + if (argValue == toSlice("-g")) + { + // The default is standard + compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_STANDARD); + } + else if (argValue.getLength() == 3 && argValue[2] >= '0' && argValue[2] <= '3') + { + // Extract the digit into an index + const Index levelIndex = argValue[2] - '0'; + SLANG_ASSERT(levelIndex >= 0 && levelIndex <= 3); + + // Map indices to enum values + const SlangDebugInfoLevel levels[] = + { + SLANG_DEBUG_INFO_LEVEL_NONE, + SLANG_DEBUG_INFO_LEVEL_MINIMAL, + SLANG_DEBUG_INFO_LEVEL_STANDARD, + SLANG_DEBUG_INFO_LEVEL_MAXIMAL + }; + + const auto level = levels[levelIndex]; + compileRequest->setDebugInfoLevel(level); + } + else + { + // Perhaps it's trying to specify a format + auto formatName = argValue.getUnownedSlice().tail(2); + + SlangDebugInfoFormat format; + if (SLANG_FAILED(TypeTextUtil::findDebugInfoFormat(formatName, format))) + { + List<String> debugOptions; + + debugOptions.add(toSlice("-g")); + + for (Int i = 0; i <= 3; ++i) + { + StringBuilder buf; + buf << toSlice("-g") << i; + debugOptions.add(buf); + } + + for (Index i = 0; i < SLANG_DEBUG_INFO_FORMAT_COUNT_OF; ++i) + { + StringBuilder buf; + buf << toSlice("-g") << TypeTextUtil::getDebugInfoFormatName(SlangDebugInfoFormat(i)); + debugOptions.add(buf); + } + + StringBuilder buf; + StringUtil::join(debugOptions, toSlice(", "), buf); + + sink->diagnose(arg.loc, Diagnostics::unknownDebugOption, buf); + return SLANG_FAIL; + } + + compileRequest->setDebugInfoFormat(format); + } } else if( argValue == "-default-image-format-unknown" ) { diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 3a11d3831..da8fcdcd6 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4737,6 +4737,11 @@ void EndToEndCompileRequest::setDebugInfoLevel(SlangDebugInfoLevel level) getLinkage()->debugInfoLevel = DebugInfoLevel(level); } +void EndToEndCompileRequest::setDebugInfoFormat(SlangDebugInfoFormat format) +{ + getLinkage()->debugInfoFormat = DebugInfoFormat(format); +} + void EndToEndCompileRequest::setOptimizationLevel(SlangOptimizationLevel level) { getLinkage()->optimizationLevel = OptimizationLevel(level); |
