mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 23:35:45 +00:00
[CMD] Support dynamic trace (#7093)
Based on Hans Harder's patch. Realize tracing cmd on console output. JIRA issue: CORE-6669 - Add FEATURE_DYNAMIC_TRACE feature. - Add CmdTrace function. - Re-define FIXME, ERR, WARN, and TRACE macros. - Check CMDTRACE environment variable. If it was "ON", then enable dynamic trace.
This commit is contained in:
parent
6c74e69d12
commit
3dcae2ce0c
5 changed files with 106 additions and 4 deletions
72
base/shell/cmd/trace.c
Normal file
72
base/shell/cmd/trace.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Command Shell
|
||||
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||
* PURPOSE: Dynamic trace (generates debugging output to console output)
|
||||
* COPYRIGHT: Copyright 2011 Hans Harder
|
||||
* Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#ifdef FEATURE_DYNAMIC_TRACE
|
||||
|
||||
BOOL g_bDynamicTrace = FALSE;
|
||||
|
||||
VOID CmdTrace(INT type, LPCSTR file, INT line, LPCSTR func, LPCSTR fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
int cch;
|
||||
char szTextA[800];
|
||||
#ifdef _UNICODE
|
||||
wchar_t szTextW[800];
|
||||
#endif
|
||||
static struct __wine_debug_functions s_Debug;
|
||||
|
||||
va_start(va, fmt);
|
||||
|
||||
/* Console output */
|
||||
if (g_bDynamicTrace)
|
||||
{
|
||||
StringCchPrintfA(szTextA, _countof(szTextA), "%s (%d): ", file, line);
|
||||
cch = lstrlenA(szTextA);
|
||||
StringCchVPrintfA(&szTextA[cch], _countof(szTextA) - cch, fmt, va);
|
||||
|
||||
#ifdef _UNICODE
|
||||
MultiByteToWideChar(OutputCodePage, 0, szTextA, -1, szTextW, _countof(szTextW));
|
||||
szTextW[_countof(szTextW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
|
||||
ConOutPuts(szTextW);
|
||||
#else
|
||||
ConOutPuts(szTextA);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!s_Debug.dbg_vlog)
|
||||
__wine_dbg_set_functions(NULL, &s_Debug, sizeof(s_Debug));
|
||||
|
||||
/* Debug logging */
|
||||
switch (type)
|
||||
{
|
||||
case __WINE_DBCL_FIXME:
|
||||
if (__WINE_IS_DEBUG_ON(_FIXME, __wine_dbch___default))
|
||||
s_Debug.dbg_vlog(__WINE_DBCL_FIXME, __wine_dbch___default, file, func, line, fmt, va);
|
||||
break;
|
||||
case __WINE_DBCL_ERR:
|
||||
if (__WINE_IS_DEBUG_ON(_ERR, __wine_dbch___default))
|
||||
s_Debug.dbg_vlog(__WINE_DBCL_ERR, __wine_dbch___default, file, func, line, fmt, va);
|
||||
break;
|
||||
case __WINE_DBCL_WARN:
|
||||
if (__WINE_IS_DEBUG_ON(_WARN, __wine_dbch___default))
|
||||
s_Debug.dbg_vlog(__WINE_DBCL_WARN, __wine_dbch___default, file, func, line, fmt, va);
|
||||
break;
|
||||
case __WINE_DBCL_TRACE:
|
||||
if (__WINE_IS_DEBUG_ON(_TRACE, __wine_dbch___default))
|
||||
s_Debug.dbg_vlog(__WINE_DBCL_TRACE, __wine_dbch___default, file, func, line, fmt, va);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
#endif /* def FEATURE_DYNAMIC_TRACE */
|
Loading…
Add table
Add a link
Reference in a new issue