From ab716f7c13232511c1e1709099f34ff3cb73f0a9 Mon Sep 17 00:00:00 2001 From: Mindy Batek Date: Fri, 26 Jun 2026 02:31:33 +0200 Subject: [PATCH] Add `__ploc` printf debugging helper --- druntime/src/object.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/druntime/src/object.d b/druntime/src/object.d index ff565edd7f..682401ee1e 100644 --- a/druntime/src/object.d +++ b/druntime/src/object.d @@ -4930,6 +4930,23 @@ template _arrayOp(Args...) public import core.builtins : __ctfeWrite; +// printf debugging helper: print location +void __ploc(string file = __FILE__, size_t line = __LINE__)(string message = null) @safe pure nothrow @nogc +{ + pragma(inline, true); + debug + { + import core.stdc.stdio : printf; + + if (message is null || message.length > int.max) { + printf("%.*s(%zu)\n", int(file.length), file.ptr, line); + return; + } + + printf("%.*s(%zu): %.*s\n", int(file.length), file.ptr, line, cast(int) message.length, message.ptr); + } +} + /** Provides an "inline import", i.e. an `import` that is only available for a