소스 검색

AK+Kernel+LibC: Add vdbgprintf()

This is like dbgprintf() except it takes a va_list instead of ...
Andreas Kling 5 년 전
부모
커밋
3055f73d48
3개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 0
      AK/kstdio.h
  2. 9 3
      Kernel/kprintf.cpp
  3. 5 0
      Libraries/LibC/stdio.cpp

+ 2 - 0
AK/kstdio.h

@@ -31,7 +31,9 @@
 #        include <Kernel/kstdio.h>
 #    else
 #        include <AK/Types.h>
+#        include <stdarg.h>
 extern "C" {
+int vdbgprintf(const char* fmt, va_list);
 int dbgprintf(const char* fmt, ...);
 ssize_t dbgputstr(const char*, ssize_t);
 int sprintf(char* buf, const char* fmt, ...);

+ 9 - 3
Kernel/kprintf.cpp

@@ -176,14 +176,20 @@ extern "C" int kernelputstr(const char* characters, int length)
     return 0;
 }
 
-extern "C" int dbgprintf(const char* fmt, ...)
+extern "C" int vdbgprintf(const char* fmt, va_list ap)
 {
     ScopedSpinLock lock(s_log_lock);
     color_on();
+    int ret = printf_internal(debugger_putch, nullptr, fmt, ap);
+    color_off();
+    return ret;
+}
+
+extern "C" int dbgprintf(const char* fmt, ...)
+{
     va_list ap;
     va_start(ap, fmt);
-    int ret = printf_internal(debugger_putch, nullptr, fmt, ap);
+    int ret = vdbgprintf(fmt, ap);
     va_end(ap);
-    color_off();
     return ret;
 }

+ 5 - 0
Libraries/LibC/stdio.cpp

@@ -802,6 +802,11 @@ void rewind(FILE* stream)
     ASSERT(rc == 0);
 }
 
+int vdbgprintf(const char* fmt, va_list ap)
+{
+    return printf_internal([](char*&, char ch) { dbgputch(ch); }, nullptr, fmt, ap);
+}
+
 int dbgprintf(const char* fmt, ...)
 {
     va_list ap;