ReactOS 0.4.16-dev-197-g92996da
trace.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Command Shell
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Dynamic trace (generates debugging output to console output)
5 * COPYRIGHT: Copyright 2011 Hans Harder <hans@atbas.org>
6 * Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 */
8
9#include "precomp.h"
10
11#ifdef FEATURE_DYNAMIC_TRACE
12
14
16{
17 va_list va;
18 int cch;
19 char szTextA[800];
20#ifdef _UNICODE
21 wchar_t szTextW[800];
22#endif
23 static struct __wine_debug_functions s_Debug;
24
25 va_start(va, fmt);
26
27 /* Console output */
29 {
30 StringCchPrintfA(szTextA, _countof(szTextA), "%s (%d): ", file, line);
31 cch = lstrlenA(szTextA);
32 StringCchVPrintfA(&szTextA[cch], _countof(szTextA) - cch, fmt, va);
33
34#ifdef _UNICODE
35 MultiByteToWideChar(OutputCodePage, 0, szTextA, -1, szTextW, _countof(szTextW));
36 szTextW[_countof(szTextW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
37 ConOutPuts(szTextW);
38#else
39 ConOutPuts(szTextA);
40#endif
41 }
42
43 if (!s_Debug.dbg_vlog)
44 __wine_dbg_set_functions(NULL, &s_Debug, sizeof(s_Debug));
45
46 /* Debug logging */
47 switch (type)
48 {
50 if (__WINE_IS_DEBUG_ON(_FIXME, __wine_dbch___default))
51 s_Debug.dbg_vlog(__WINE_DBCL_FIXME, __wine_dbch___default, file, func, line, fmt, va);
52 break;
53 case __WINE_DBCL_ERR:
54 if (__WINE_IS_DEBUG_ON(_ERR, __wine_dbch___default))
55 s_Debug.dbg_vlog(__WINE_DBCL_ERR, __wine_dbch___default, file, func, line, fmt, va);
56 break;
58 if (__WINE_IS_DEBUG_ON(_WARN, __wine_dbch___default))
59 s_Debug.dbg_vlog(__WINE_DBCL_WARN, __wine_dbch___default, file, func, line, fmt, va);
60 break;
62 if (__WINE_IS_DEBUG_ON(_TRACE, __wine_dbch___default))
63 s_Debug.dbg_vlog(__WINE_DBCL_TRACE, __wine_dbch___default, file, func, line, fmt, va);
64 break;
65 default:
66 break;
67 }
68
69 va_end(va);
70}
71
72#endif /* def FEATURE_DYNAMIC_TRACE */
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
UINT OutputCodePage
Definition: console.c:26
#define ConOutPuts(szStr)
Definition: console.h:29
BOOL g_bDynamicTrace
Definition: trace.c:13
VOID CmdTrace(INT type, LPCSTR file, INT line, LPCSTR func, LPCSTR fmt,...)
Definition: trace.c:15
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MultiByteToWideChar
Definition: compat.h:110
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum func
Definition: glext.h:6028
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define UNICODE_NULL
#define _WARN(msg)
Definition: debug.h:263
#define __WINE_IS_DEBUG_ON(dbcl, dbch)
Definition: debug.h:87
@ __WINE_DBCL_ERR
Definition: debug.h:52
@ __WINE_DBCL_TRACE
Definition: debug.h:54
@ __WINE_DBCL_FIXME
Definition: debug.h:51
@ __WINE_DBCL_WARN
Definition: debug.h:53
void __wine_dbg_set_functions(const struct __wine_debug_functions *new_funcs, struct __wine_debug_functions *old_funcs, size_t size)
Definition: debug.c:551
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
STRSAFEAPI StringCchVPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat, va_list argList)
Definition: strsafe.h:485
int(* dbg_vlog)(enum __wine_debug_class cls, struct __wine_debug_channel *channel, const char *file, const char *function, const int line, const char *format, va_list args)
Definition: debug.h:159
Definition: fci.c:127
Definition: dsound.c:943
Definition: parser.c:49
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183