A comment from this test case tells us why the function debugBelch2 exists:
ghc/testsuite/tests/rts/T7160.hs-- Don't use debugBelch() directly, because we cannot call varargs functions-- using the FFI (doing so produces a segfault on 64-bit Linux, for example).-- See Debug.Trace.traceIO, which also uses debugBelch2.foreign import ccall "&debugBelch2" fun :: FunPtr (Ptr () -> Ptr () -> IO ())The implementation is:
ghc/libraries/base/cbits/PrelIOUtils.cvoid debugBelch2(const char*s, char *t){ debugBelch(s,t);}ghc/rts/RtsMessages.cRtsMsgFunction *debugMsgFn = rtsDebugMsgFn;...voiddebugBelch(const char*s, ...){ va_list ap; va_start(ap,s); (*debugMsgFn)(s,ap); va_end(ap);}