Commit 8d086fc3 by Ben Clayton

SpirvShaderDebugger: Add PRINT_EACH_DEFINED_DBG_INSTRUCTION

Prints each debug instruction as it is defined. Yet another tool in debugging the debugger. Also rename `PRINT_EACH_PROCESSED_INSTRUCTION` to `PRINT_EACH_EMITTED_INSTRUCTION` as that's really what it meant. Bug: b/148401179 Change-Id: I9ddf90eab1919deefb5f4557756364478f06375a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48430Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 779a2f34
...@@ -14,8 +14,10 @@ ...@@ -14,8 +14,10 @@
#include "SpirvShader.hpp" #include "SpirvShader.hpp"
// If enabled, each instruction will be printed before processing. // If enabled, each instruction will be printed before defining.
#define PRINT_EACH_PROCESSED_INSTRUCTION 0 #define PRINT_EACH_DEFINED_DBG_INSTRUCTION 0
// If enabled, each instruction will be printed before emitting.
#define PRINT_EACH_EMITTED_INSTRUCTION 0
// If enabled, each instruction will be printed before executing. // If enabled, each instruction will be printed before executing.
#define PRINT_EACH_EXECUTED_INSTRUCTION 0 #define PRINT_EACH_EXECUTED_INSTRUCTION 0
// If enabled, debugger variables will contain debug information (addresses, // If enabled, debugger variables will contain debug information (addresses,
...@@ -2048,7 +2050,7 @@ void SpirvShader::dbgEndEmit(EmitState *state) const ...@@ -2048,7 +2050,7 @@ 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_EMITTED_INSTRUCTION
{ {
auto instruction = spvtools::spvInstructionBinaryToText( auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1,
...@@ -2059,7 +2061,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c ...@@ -2059,7 +2061,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c
SPV_BINARY_TO_TEXT_OPTION_NO_HEADER); SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
printf("%s\n", instruction.c_str()); printf("%s\n", instruction.c_str());
} }
# endif // PRINT_EACH_PROCESSED_INSTRUCTION # endif // PRINT_EACH_EMITTED_INSTRUCTION
# if PRINT_EACH_EXECUTED_INSTRUCTION # if PRINT_EACH_EXECUTED_INSTRUCTION
{ {
...@@ -2162,6 +2164,19 @@ SpirvShader::EmitResult SpirvShader::EmitLine(InsnIterator insn, EmitState *stat ...@@ -2162,6 +2164,19 @@ SpirvShader::EmitResult SpirvShader::EmitLine(InsnIterator insn, EmitState *stat
void SpirvShader::DefineOpenCLDebugInfo100(const InsnIterator &insn) void SpirvShader::DefineOpenCLDebugInfo100(const InsnIterator &insn)
{ {
# if PRINT_EACH_DEFINED_DBG_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);
printf("%s\n", instruction.c_str());
}
# endif // PRINT_EACH_DEFINED_DBG_INSTRUCTION
auto dbg = impl.debugger; auto dbg = impl.debugger;
if(!dbg) { return; } if(!dbg) { return; }
......
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