How to Debug swiftshader process pipeline

121 views
Skip to first unread message

Jack Scho

unread,
May 24, 2022, 11:34:58 AM5/24/22
to swiftshader
As we known Reactor produce code for JIT, 
but if i wanna debug some rendering process, it seems hard to get the actual value for the variable.
For example, if i wanna to know the value for area in SetupRoutine, gdb shows "rr::LValue<Float>" , not the value of A.
debug_swiftshader.png

it`s just i want to know how swiftshader render triangles into screen.
and how you guys debug and develop swiftshader process, just write the reactor code and run it?

Jack Scho

unread,
May 24, 2022, 11:46:37 AM5/24/22
to swiftshader
https://github.com/google/swiftshader/blob/master/docs/ReactorDebugInfo.md

As this md says using  REACTOR_EMIT_DEBUG_INFO when build swiftshader,
but not achieve the goal of show the actual value for area A

Jack Scho

unread,
May 24, 2022, 12:51:44 PM5/24/22
to swiftshader
i found rr::Print() can print the actual value of area A
is there any other methods?

Jack Scho

unread,
May 24, 2022, 12:55:03 PM5/24/22
to swiftshader
means any other methods for tracing the value of A like gdb step by step show .

Nicolas Capens

unread,
May 30, 2022, 11:59:28 AM5/30/22
to Jack Scho, swiftshader
Hi Jack,

Thanks for your interest in SwiftShader! Indeed when the Reactor statements execute, they just record which operations to JIT-compile into binary code. Debugging the execution of the generated code is mostly limited to inserting rr::Print() calls, using rr::Call() to call a C function to which you can pass values and where you can put a breakpoint, or writing values to a buffer that can be inspected using a C++ debugger.

The REACTOR_EMIT_DEBUG_INFO option requires a very specific setup and has probably bitrotted quite a bit. Hopefully once we have full C++23 support we could base it around std::stacktrace and make it work universally, but that's a way off.

I recommend trying out the rr::Call() approach. Unlike the use of rr::Print() you can easily use breakpoints and limit it to specific conditions.

Cheers,
Nicolas

--
You received this message because you are subscribed to the Google Groups "swiftshader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiftshader...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swiftshader/fd2a2ba8-fe6f-4d0f-a021-f0f966ee7c38n%40googlegroups.com.

Jack Scho

unread,
May 30, 2022, 9:57:53 PM5/30/22
to swiftshader
Thanks for your kind reply, I will try rr::Call.

PP hhhzz

unread,
Mar 11, 2024, 11:16:27 AMMar 11
to swiftshader
Hi,
If I want to print the values of a struct, how should I use the rr::Print() function?

Best regards, 
Haozhou

Nicolas Capens

unread,
Mar 11, 2024, 4:28:42 PMMar 11
to PP hhhzz, swiftshader
Hi Haozhou,

You can either use rr::Print() to print each struct element individually (or just the ones of interest), or use rr::Call() to pass a pointer to the struct instance to a custom C function where you do the printing. Because you can also put breakpoints in the latter, and easily add conditions for when to print/break, I'd recommend the latter approach over using rr::Print().

Cheers,
Nicolas

Reply all
Reply to author
Forward
0 new messages