yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9666fbcab
master
Debugging Slang
This document gives examples showing how to run debuggers in the Slang codebase. Follow the Building Slang From Source instructions first.
Visual Studio
This repo includes multiple *.natvis files which Visual Studio picks up
automatically; no extra configuration is required.
LLDB
If you use LLDB, we provide a .lldbinit file which enables data formatters
for types in the Slang codebase. You can use this with LLDB in your terminal via
the --local-lldbinit flag; for example:
$ cmake --build --preset debug $ lldb --local-lldbinit build/Debug/bin/slangc -- tests/byte-code/hello.slang -dump-ir (lldb) breakpoint set --name dumpIR (lldb) run
LLDB can be used with either GCC or Clang, but Clang seems to behave better about respecting breakpoint locations and not having missing variables.
VS Code
If instead you prefer to debug within VS Code, you can run LLDB via the
CodeLLDB extension. For example, to recreate the same debugging session as
above, create a .vscode/tasks.json file with these contents:
{
"version" : "2.0.0" ,
"tasks" : [
{
"label" : "Debug build" ,
"type" : "shell" ,
"command" : "cmake" ,
"args" : ["--build" , "--preset" , "debug" ]
}
]
}
Then create a .vscode/launch.json file with these contents:
{
"version" : "0.2.0" ,
"configurations" : [
{
"name" : "LLDB" ,
"preLaunchTask" : "Debug build" ,
"type" : "lldb" ,
"request" : "launch" ,
"initCommands" : ["command source .lldbinit" ],
"program" : "build/Debug/bin/slangc" ,
"args" : ["tests/byte-code/hello.slang" , "-dump-ir" ]
}
]
}
Finally, place any breakpoints you want, and hit F5.
1# Debugging Slang 2 3This document gives examples showing how to run debuggers in the Slang codebase. 4Follow the [Building Slang From Source](/docs/building.md) instructions first. 5 6## Visual Studio 7 8This repo includes multiple `*.natvis` files which Visual Studio picks up 9automatically; no extra configuration is required. 10 11## LLDB 12 13If you use [LLDB][], we provide a `.lldbinit` file which enables data formatters 14for types in the Slang codebase. You can use this with LLDB in your terminal via 15the [`--local-lldbinit`][] flag; for example: 16 17``` 18$ cmake --build --preset debug 19$ lldb --local-lldbinit build/Debug/bin/slangc -- tests/byte-code/hello.slang -dump-ir 20(lldb) breakpoint set --name dumpIR 21(lldb) run 22``` 23 24LLDB can be used with either GCC or Clang, but Clang seems to behave better 25about respecting breakpoint locations and not having missing variables. 26 27### VS Code 28 29If instead you prefer to debug within VS Code, you can run LLDB via the 30[CodeLLDB][] extension. For example, to recreate the same debugging session as 31above, create a `.vscode/tasks.json` file with these contents: 32 33``` json 34{ 35"version" : "2.0.0" , 36"tasks" : [ 37{ 38"label" : "Debug build" , 39"type" : "shell" , 40"command" : "cmake" , 41"args" : [ "--build" , "--preset" , "debug" ] 42} 43] 44} 45``` 46 47Then create a `.vscode/launch.json` file with these contents: 48 49``` json 50{ 51"version" : "0.2.0" , 52"configurations" : [ 53{ 54"name" : "LLDB" , 55"preLaunchTask" : "Debug build" , 56"type" : "lldb" , 57"request" : "launch" , 58"initCommands" : [ "command source .lldbinit" ], 59"program" : "build/Debug/bin/slangc" , 60"args" : [ "tests/byte-code/hello.slang" , "-dump-ir" ] 61} 62] 63} 64``` 65 66Finally, place any breakpoints you want, and hit F5. 67 68[`--local-lldbinit`] : https://lldb.llvm.org/man/lldb.html#cmdoption-lldb-local-lldbinit 69[codelldb] : https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb 70[lldb] : https://lldb.llvm.org/index.html