Commit b8bae186 by Ben Clayton

SpirvShaderDebugger: Add flag for printing opcodes as they're executed

The `PRINT_EACH_EXECUTED_INSTRUCTION` preprocessor flag complements the existing `PRINT_EACH_PROCESSED_INSTRUCTION` flag to print each instruction before they are executed. This is exceptionally helpful when debugging the debugger. Bug: b/148401179 Change-Id: If35728f115d664c1dba63e625eefccac9d3140ce Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/42249 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent b2d7dfff
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
// If enabled, each instruction will be printed before processing. // If enabled, each instruction will be printed before processing.
#define PRINT_EACH_PROCESSED_INSTRUCTION 0 #define PRINT_EACH_PROCESSED_INSTRUCTION 0
// If enabled, each instruction will be printed before executing.
#define PRINT_EACH_EXECUTED_INSTRUCTION 0
#ifdef ENABLE_VK_DEBUGGER #ifdef ENABLE_VK_DEBUGGER
...@@ -1452,16 +1454,31 @@ void SpirvShader::dbgEndEmit(EmitState *state) const ...@@ -1452,16 +1454,31 @@ void SpirvShader::dbgEndEmit(EmitState *state) const
void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) const void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) const
{ {
# if PRINT_EACH_PROCESSED_INSTRUCTION # if PRINT_EACH_PROCESSED_INSTRUCTION
auto instruction = spvtools::spvInstructionBinaryToText( {
SPV_ENV_VULKAN_1_1, auto instruction = spvtools::spvInstructionBinaryToText(
insn.wordPointer(0), SPV_ENV_VULKAN_1_1,
insn.wordCount(), insn.wordPointer(0),
insns.data(), insn.wordCount(),
insns.size(), insns.data(),
SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); insns.size(),
printf("%s\n", instruction.c_str()); SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
printf("%s\n", instruction.c_str());
}
# endif // PRINT_EACH_PROCESSED_INSTRUCTION # endif // PRINT_EACH_PROCESSED_INSTRUCTION
# if PRINT_EACH_EXECUTED_INSTRUCTION
{
auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1,
insn.wordPointer(0),
insn.wordCount(),
insns.data(),
insns.size(),
SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
rr::Print("{0}\n", instruction);
}
# endif // PRINT_EACH_EXECUTED_INSTRUCTION
if(extensionsImported.count(Extension::OpenCLDebugInfo100) == 0) if(extensionsImported.count(Extension::OpenCLDebugInfo100) == 0)
{ {
// We're emitting debugger logic for SPIR-V. // We're emitting debugger logic for SPIR-V.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment