mscoree: Add a buffer for Mono's debug output.
Signed-off-by: Esme Povirk <esme@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6cb5f66079
commit
20dc5f378c
|
@ -137,8 +137,6 @@ static MonoAssembly* CDECL mono_assembly_preload_hook_fn(MonoAssemblyName *aname
|
|||
|
||||
static void CDECL mono_shutdown_callback_fn(MonoProfiler *prof);
|
||||
|
||||
static void CDECL mono_print_handler_fn(const char *string, INT is_stdout);
|
||||
|
||||
static MonoImage* CDECL image_open_module_handle_dummy(HMODULE module_handle,
|
||||
char* fname, UINT has_entry_point, MonoImageOpenStatus* status)
|
||||
{
|
||||
|
@ -378,17 +376,6 @@ static void CDECL mono_shutdown_callback_fn(MonoProfiler *prof)
|
|||
is_mono_shutdown = TRUE;
|
||||
}
|
||||
|
||||
static void CDECL mono_print_handler_fn(const char *string, INT is_stdout)
|
||||
{
|
||||
const char *p;
|
||||
for (; *string; string = p)
|
||||
{
|
||||
if ((p = strstr(string, "\n"))) p++;
|
||||
else p = string + strlen(string);
|
||||
wine_dbg_printf("%.*s", (int)(p - string), string);
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT WINAPI thread_set_fn(void)
|
||||
{
|
||||
WARN("stub\n");
|
||||
|
|
|
@ -50,6 +50,14 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
|
||||
WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
||||
|
||||
struct print_handler_tls
|
||||
{
|
||||
int length;
|
||||
char buffer[1018];
|
||||
};
|
||||
|
||||
static DWORD print_tls_index = TLS_OUT_OF_INDEXES;
|
||||
|
||||
typedef HRESULT (*fnCreateInstance)(REFIID riid, LPVOID *ppObj);
|
||||
|
||||
char *WtoA(LPCWSTR wstr)
|
||||
|
@ -214,6 +222,46 @@ HRESULT WINAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor
|
|||
return ret;
|
||||
}
|
||||
|
||||
void CDECL mono_print_handler_fn(const char *string, INT is_stdout)
|
||||
{
|
||||
struct print_handler_tls *tls = TlsGetValue(print_tls_index);
|
||||
|
||||
if (!tls)
|
||||
{
|
||||
tls = HeapAlloc(GetProcessHeap(), 0, sizeof(*tls));
|
||||
tls->length = 0;
|
||||
TlsSetValue(print_tls_index, tls);
|
||||
}
|
||||
|
||||
while (*string)
|
||||
{
|
||||
int remaining_buffer = sizeof(tls->buffer) - tls->length;
|
||||
int length = strlen(string);
|
||||
const char *newline = memchr(string, '\n', min(length, remaining_buffer));
|
||||
|
||||
if (newline)
|
||||
{
|
||||
length = newline - string + 1;
|
||||
wine_dbg_printf("%.*s%.*s", tls->length, tls->buffer, length, string);
|
||||
tls->length = 0;
|
||||
string += length;
|
||||
}
|
||||
else if (length > remaining_buffer)
|
||||
{
|
||||
/* this would overflow Wine's debug buffer */
|
||||
wine_dbg_printf("%.*s%.*s\n", tls->length, tls->buffer, remaining_buffer, string);
|
||||
tls->length = 0;
|
||||
string += remaining_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(tls->buffer + tls->length, string, length);
|
||||
tls->length += length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
||||
|
@ -222,12 +270,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
runtimehost_init();
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
|
||||
print_tls_index = TlsAlloc();
|
||||
|
||||
if (print_tls_index == TLS_OUT_OF_INDEXES)
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
if (print_tls_index != TLS_OUT_OF_INDEXES)
|
||||
HeapFree(GetProcessHeap(), 0, TlsGetValue(print_tls_index));
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
expect_no_runtimes();
|
||||
if (lpvReserved) break; /* process is terminating */
|
||||
runtimehost_uninit();
|
||||
if (print_tls_index != TLS_OUT_OF_INDEXES)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, TlsGetValue(print_tls_index));
|
||||
TlsFree(print_tls_index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -219,4 +219,6 @@ extern HRESULT get_file_from_strongname(WCHAR* stringnameW, WCHAR* assemblies_pa
|
|||
extern void runtimehost_init(void) DECLSPEC_HIDDEN;
|
||||
extern void runtimehost_uninit(void) DECLSPEC_HIDDEN;
|
||||
|
||||
extern void CDECL mono_print_handler_fn(const char *string, INT is_stdout) DECLSPEC_HIDDEN;
|
||||
|
||||
#endif /* __MSCOREE_PRIVATE__ */
|
||||
|
|
Loading…
Reference in New Issue