FabricMC / fabric

Essential hooks for modding with Fabric.
Apache License 2.0
2.31k stars 404 forks source link

Print the full stack trace from the dedicated server watchdog #4052

Closed TelepathicGrunt closed 3 weeks ago

TelepathicGrunt commented 1 month ago

Turns out 1.21.2 broke my FullStack Watchdog mod but instead of merging someone's PR to port my mod to that version, I figured maybe it'll be better to have it in Fabric API itself.

This code simply swaps the ThreadInfo being passed to StringBuilder with a full stacktrace string instead. The reason for this is ThreadInfo's toString method will truncate the stacktrace for itself. We need the full dump in order to see problems so doing our own copy of that toString method but without the truncating should do the trick

modmuss50 commented 1 month ago

Great idea 👍 Would it be possible to create a testmod with a way to trigger this for testing?

TelepathicGrunt commented 1 month ago

testmod added. Command is /print_thread_dump_test_command. Will work in single player or on server as it calls the DedicatedServerWatchdog.createCrashReport method directly to get the string to print. image