#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/event-private.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
static void event_signal(gpointer handle);
static gboolean event_own (gpointer handle);
return (FALSE);
}
- DEBUG("%s: owning event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning event handle %p", __func__, handle);
if(event_handle->manual==FALSE) {
g_assert (event_handle->set_count > 0);
struct _WapiHandle_namedevent *namedevent_handle;
gboolean ok;
- DEBUG ("%s: owning named event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named event handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDEVENT,
(gpointer *)&namedevent_handle);
*/
SetLastError (ERROR_SUCCESS);
- DEBUG ("%s: Creating unnamed event", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating unnamed event", __func__);
event_handle.manual = manual;
event_handle.set_count = 0;
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
- DEBUG("%s: created new event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created new event handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Creating named event [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
- DEBUG ("%s: returning event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
- DEBUG ("%s: Pulsing event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Pulsing event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
* have proceeded. Currently we rely on broadcasting
* a condition.
*/
- DEBUG ("%s: Obtained write lock on event handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
__func__, handle);
thr_ret = _wapi_handle_lock_handle (handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
- DEBUG ("%s: Pulsing named event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Pulsing named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
* have proceeded. Currently we rely on waiting for
* twice the shared handle poll interval.
*/
- DEBUG ("%s: Obtained write lock on event handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
__func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
return(FALSE);
}
- DEBUG ("%s: Resetting event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Resetting event handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
- DEBUG ("%s: No need to reset event handle %p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No need to reset event handle %p", __func__,
handle);
} else {
- DEBUG ("%s: Obtained write lock on event handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
__func__, handle);
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
return(FALSE);
}
- DEBUG ("%s: Resetting named event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Resetting named event handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
- DEBUG ("%s: No need to reset named event handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No need to reset named event handle %p",
__func__, handle);
} else {
- DEBUG ("%s: Obtained write lock on named event handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on named event handle %p",
__func__, handle);
_wapi_shared_handle_set_signal_state (handle, FALSE);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
- DEBUG ("%s: Setting event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Setting event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
- DEBUG ("%s: Setting named event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Setting named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Opening named event [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
}
ret = handle;
- DEBUG ("%s: returning named event handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/shared.h>
#include <mono/io-layer/process-private.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
#undef DEBUG_REFS
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
static void (*_wapi_handle_ops_get_close_func (WapiHandleType type))(gpointer, gpointer);
static WapiHandleCapability handle_caps[WAPI_HANDLE_COUNT] = { (WapiHandleCapability)0 };
gpointer handle = GINT_TO_POINTER (i*_WAPI_HANDLE_INITIAL_COUNT+j);
for(k = handle_data->ref; k > 0; k--) {
- DEBUG ("%s: unreffing %s handle %p", __func__, _wapi_handle_typename[type], handle);
-
_wapi_handle_unref_full (handle, TRUE);
}
}
g_assert (_wapi_has_shut_down == FALSE);
- DEBUG ("%s: Creating new handle of type %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
_wapi_handle_typename[type]);
g_assert(!_WAPI_FD_HANDLE(type));
handle = GUINT_TO_POINTER (handle_idx);
- DEBUG ("%s: Allocated new handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Allocated new handle %p", __func__, handle);
if (_WAPI_SHARED_HANDLE(type)) {
/* Add the shared section too */
}
_WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = ref;
- DEBUG ("%s: New shared handle at offset 0x%x", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New shared handle at offset 0x%x", __func__,
ref);
}
g_assert (_wapi_has_shut_down == FALSE);
- DEBUG ("%s: Creating new handle of type %s to offset %d", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s to offset %d", __func__,
_wapi_handle_typename[type], offset);
g_assert(!_WAPI_FD_HANDLE(type));
if (handle != INVALID_HANDLE_VALUE) {
_wapi_handle_ref (handle);
- DEBUG ("%s: Returning old handle %p referencing 0x%x",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning old handle %p referencing 0x%x",
__func__, handle, offset);
return (handle);
}
if (shared->type == WAPI_HANDLE_UNUSED) {
/* Someone deleted this handle while we were working */
- DEBUG ("%s: Handle at 0x%x unused", __func__, offset);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle at 0x%x unused", __func__, offset);
goto done;
}
if (shared->type != type) {
- DEBUG ("%s: Wrong type at %d 0x%x! Found %s wanted %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Wrong type at %d 0x%x! Found %s wanted %s",
__func__, offset, offset,
_wapi_handle_typename[shared->type],
_wapi_handle_typename[type]);
_WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = offset;
InterlockedIncrement ((gint32 *)&shared->handle_refs);
- DEBUG ("%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
done:
_wapi_handle_unlock_shared_handles ();
g_assert (_wapi_has_shut_down == FALSE);
- DEBUG ("%s: Creating new handle of type %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
_wapi_handle_typename[type]);
g_assert(_WAPI_FD_HANDLE(type));
g_assert(!_WAPI_SHARED_HANDLE(type));
if (fd >= _wapi_fd_reserve) {
- DEBUG ("%s: fd %d is too big", __func__, fd);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fd %d is too big", __func__, fd);
return(GUINT_TO_POINTER (_WAPI_HANDLE_INVALID));
}
handle = &_WAPI_PRIVATE_HANDLES(fd);
if (handle->type != WAPI_HANDLE_UNUSED) {
- DEBUG ("%s: fd %d is already in use!", __func__, fd);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fd %d is already in use!", __func__, fd);
/* FIXME: clean up this handle? We can't do anything
* with the fd, cos thats the new one
*/
}
- DEBUG ("%s: Assigning new fd handle %d", __func__, fd);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Assigning new fd handle %d", __func__, fd);
/* Prevent file share entries racing with us, when the file
* handle is only half initialised
if (!found && search_shared && _WAPI_SHARED_HANDLE (type)) {
/* Not found yet, so search the shared memory too */
- DEBUG ("%s: Looking at other shared handles...", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Looking at other shared handles...", __func__);
for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) {
shared = &_wapi_shared_layout->handles[i];
continue;
}
- DEBUG ("%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
/* It's possible that the shared part
* of this handle has now been blown
g_assert(_WAPI_SHARED_HANDLE(type));
- DEBUG ("%s: Lookup for handle named [%s] type %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Lookup for handle named [%s] type %s", __func__,
utf8_name, _wapi_handle_typename[type]);
thr_ret = _wapi_handle_lock_shared_handles ();
continue;
}
- DEBUG ("%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
sharedns=(WapiSharedNamespace *)&shared_handle_data->u;
- DEBUG ("%s: name is [%s]", __func__, sharedns->name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is [%s]", __func__, sharedns->name);
if (strcmp (sharedns->name, utf8_name) == 0) {
if (shared_handle_data->type != type) {
/* Its the wrong type, so fail now */
- DEBUG ("%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
ret = -1;
goto done;
} else {
- DEBUG ("%s: handle 0x%x matches name and type", __func__, i);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name and type", __func__, i);
ret = i;
goto done;
}
thr_ret = mono_os_mutex_lock (&scan_mutex);
- DEBUG ("%s: Destroying handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Destroying handle %p", __func__, handle);
memcpy (&handle_data, &_WAPI_PRIVATE_HANDLES(idx),
sizeof (struct _WapiHandleUnshared));
type = _WAPI_PRIVATE_HANDLES(idx).type;
- DEBUG ("%s: testing 0x%x against 0x%x (%d)", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing 0x%x against 0x%x (%d)", __func__,
handle_caps[type], caps, handle_caps[type] & caps);
return((handle_caps[type] & caps) != 0);
gpointer handle = handles[i];
guint32 idx = GPOINTER_TO_UINT(handle);
- DEBUG ("%s: attempting to lock %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempting to lock %p", __func__, handle);
type = _WAPI_PRIVATE_HANDLES(idx).type;
if (thr_ret != 0) {
/* Bummer */
- DEBUG ("%s: attempt failed for %p: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt failed for %p: %s", __func__,
handle, strerror (thr_ret));
thr_ret = _wapi_handle_unlock_shared_handles ();
iter=1;
}
- DEBUG ("%s: Backing off for %d ms", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Backing off for %d ms", __func__,
iter*10);
_wapi_handle_spin (10 * iter);
}
}
- DEBUG ("%s: Locked all handles", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locked all handles", __func__);
count=0;
*lowest=numhandles;
type = _WAPI_PRIVATE_HANDLES(idx).type;
- DEBUG ("%s: Checking handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Checking handle %p", __func__, handle);
if(((_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_OWN)==TRUE) &&
(_wapi_handle_ops_isowned (handle) == TRUE)) ||
_WAPI_PRIVATE_HANDLES(idx).signalled == TRUE)) {
count++;
- DEBUG ("%s: Handle %p signalled", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %p signalled", __func__,
handle);
if(*lowest>i) {
*lowest=i;
}
}
- DEBUG ("%s: %d event handles signalled", __func__, count);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %d event handles signalled", __func__, count);
if ((waitall == TRUE && count == numhandles) ||
(waitall == FALSE && count > 0)) {
ret=FALSE;
}
- DEBUG ("%s: Returning %d", __func__, ret);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning %d", __func__, ret);
*retcount=count;
for(i=0; i<numhandles; i++) {
gpointer handle = handles[i];
- DEBUG ("%s: unlocking handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
int
_wapi_handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboolean alertable, gboolean poll, gboolean *alerted)
{
- DEBUG ("%s: waiting for %p (type %s)", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: waiting for %p (type %s)", __func__, handle,
_wapi_handle_typename[_wapi_handle_type (handle)]);
if (alertable)
* owned by someone else) so mark this share info as
* dead
*/
- DEBUG ("%s: Didn't find it, destroying entry", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find it, destroying entry", __func__);
_wapi_free_share_info (share_info);
}
struct _WapiHandle_file *file_handle = &handle->u.file;
if (file_handle->share_info == share_info) {
- DEBUG ("%s: handle 0x%x has this file open!",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x has this file open!",
__func__, i);
goto done;
_wapi_handle_check_share_by_pid (share_info);
} else if (found == FALSE) {
/* Blank out this entry, as it is stale */
- DEBUG ("%s: Didn't find it, destroying entry", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find it, destroying entry", __func__);
_wapi_free_share_info (share_info);
}
--- /dev/null
+/*
+ * io-trace.h: tracing macros
+ *
+ * Authors:
+ * Marek Habersack <grendel@twistedcode.net>
+ *
+ * Copyright 2016 Xamarin, Inc (http://xamarin.com/)
+ */
+
+#ifndef __IO_TRACE_H
+
+#ifdef DISABLE_IO_LAYER_TRACE
+#define MONO_TRACE(...)
+#else
+#define MONO_TRACE(...) mono_trace (__VA_ARGS__)
+#endif
+
+#endif
#include <mono/io-layer/timefuncs-private.h>
#include <mono/io-layer/thread-private.h>
#include <mono/io-layer/io-portability.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#define DEBUG_ENABLED 1
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
static void file_close (gpointer handle, gpointer data);
static WapiFileType file_getfiletype(void);
struct _WapiHandle_file *file_handle = (struct _WapiHandle_file *)data;
int fd = file_handle->fd;
- DEBUG("%s: closing file handle %p [%s]", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing file handle %p [%s]", __func__, handle,
file_handle->filename);
if (file_handle->attrs & FILE_FLAG_DELETE_ON_CLOSE)
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
if(ret==-1) {
gint err = errno;
- DEBUG("%s: read of handle %p error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
handle, strerror(err));
SetLastError (_wapi_get_win32_file_error (err));
return(FALSE);
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
*/
current_pos = lseek (fd, (off_t)0, SEEK_CUR);
if (current_pos == -1) {
- DEBUG ("%s: handle %p lseek failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
handle, strerror (errno));
_wapi_set_last_error_from_errno ();
return(FALSE);
} else {
_wapi_set_last_error_from_errno ();
- DEBUG("%s: write of handle %p error: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
__func__, handle, strerror(errno));
return(FALSE);
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
ret=fsync(fd);
if (ret==-1) {
- DEBUG("%s: fsync of handle %p error: %s", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fsync of handle %p error: %s", __func__, handle,
strerror(errno));
_wapi_set_last_error_from_errno ();
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_SET_FILE_POINTER);
whence=SEEK_END;
break;
default:
- DEBUG("%s: invalid seek type %d", __func__, method);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: invalid seek type %d", __func__, method);
SetLastError (ERROR_INVALID_PARAMETER);
return(INVALID_SET_FILE_POINTER);
#ifdef HAVE_LARGE_FILE_SUPPORT
if(highmovedistance==NULL) {
offset=movedistance;
- DEBUG("%s: setting offset to %lld (low %d)", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld (low %d)", __func__,
offset, movedistance);
} else {
offset=((gint64) *highmovedistance << 32) | (guint32)movedistance;
- DEBUG("%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
}
#else
offset=movedistance;
#endif
- DEBUG ("%s: moving handle %p by %lld bytes from %d", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: moving handle %p by %lld bytes from %d", __func__,
handle, (long long)offset, whence);
#ifdef PLATFORM_ANDROID
newpos=lseek(fd, offset, whence);
#endif
if(newpos==-1) {
- DEBUG("%s: lseek on handle %p returned error %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek on handle %p returned error %s",
__func__, handle, strerror(errno));
_wapi_set_last_error_from_errno ();
return(INVALID_SET_FILE_POINTER);
}
- DEBUG ("%s: lseek returns %lld", __func__, newpos);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek returns %lld", __func__, newpos);
#ifdef HAVE_LARGE_FILE_SUPPORT
ret=newpos & 0xFFFFFFFF;
}
#endif
- DEBUG ("%s: move of handle %p returning %d/%d", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: move of handle %p returning %d/%d", __func__,
handle, ret, highmovedistance==NULL?0:*highmovedistance);
return(ret);
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
ret=fstat(fd, &statbuf);
if(ret==-1) {
- DEBUG ("%s: handle %p fstat failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
handle, strerror(errno));
_wapi_set_last_error_from_errno ();
pos=lseek(fd, (off_t)0, SEEK_CUR);
if(pos==-1) {
- DEBUG("%s: handle %p lseek failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
handle, strerror(errno));
_wapi_set_last_error_from_errno ();
!_wapi_thread_cur_apc_pending());
if(ret==-1) {
- DEBUG("%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
_wapi_set_last_error_from_errno ();
return(FALSE);
/* And put the file position back after the write */
ret = lseek (fd, pos, SEEK_SET);
if (ret == -1) {
- DEBUG ("%s: handle %p second lseek failed: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p second lseek failed: %s",
__func__, handle, strerror(errno));
_wapi_set_last_error_from_errno ();
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
- DEBUG("%s: handle %p ftruncate failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ftruncate failed: %s", __func__,
handle, strerror(errno));
_wapi_set_last_error_from_errno ();
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_FILE_SIZE);
ret = fstat(fd, &statbuf);
if (ret == -1) {
- DEBUG ("%s: handle %p fstat failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
handle, strerror(errno));
_wapi_set_last_error_from_errno ();
if (S_ISBLK(statbuf.st_mode)) {
guint64 bigsize;
if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
- DEBUG ("%s: handle %p ioctl BLKGETSIZE64 failed: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ioctl BLKGETSIZE64 failed: %s",
__func__, handle, strerror(errno));
_wapi_set_last_error_from_errno ();
*highsize = bigsize>>32;
}
- DEBUG ("%s: Returning block device size %d/%d",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning block device size %d/%d",
__func__, size, *highsize);
return(size);
size = statbuf.st_size;
#endif
- DEBUG ("%s: Returning size %d/%d", __func__, size, *highsize);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning size %d/%d", __func__, size, *highsize);
return(size);
}
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
ret=fstat(fd, &statbuf);
if(ret==-1) {
- DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
strerror(errno));
_wapi_set_last_error_from_errno ();
return(FALSE);
}
- DEBUG("%s: atime: %ld ctime: %ld mtime: %ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: atime: %ld ctime: %ld mtime: %ld", __func__,
statbuf.st_atime, statbuf.st_ctime,
statbuf.st_mtime);
access_ticks=((guint64)statbuf.st_atime*10000000)+116444736000000000ULL;
write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;
- DEBUG("%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
access_ticks, create_ticks, write_ticks);
if(create_time!=NULL) {
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
if(file_handle->filename == NULL) {
- DEBUG("%s: handle %p unknown filename", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p unknown filename", __func__, handle);
SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
*/
ret=fstat (fd, &statbuf);
if(ret==-1) {
- DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
strerror(errno));
SetLastError (ERROR_INVALID_PARAMETER);
* but this will do for now.
*/
if (access_ticks < 116444736000000000ULL) {
- DEBUG ("%s: attempt to set access time too early",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set access time too early",
__func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
* but this will do for now.
*/
if (write_ticks < 116444736000000000ULL) {
- DEBUG ("%s: attempt to set write time too early",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time too early",
__func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
utbuf.modtime=statbuf.st_mtime;
}
- DEBUG ("%s: setting handle %p access %ld write %ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting handle %p access %ld write %ld", __func__,
handle, utbuf.actime, utbuf.modtime);
ret = _wapi_utime (file_handle->filename, &utbuf);
if (ret == -1) {
- DEBUG ("%s: handle %p [%s] utime failed: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p [%s] utime failed: %s", __func__,
handle, file_handle->filename, strerror(errno));
SetLastError (ERROR_INVALID_PARAMETER);
struct _WapiHandle_file *console_handle = (struct _WapiHandle_file *)data;
int fd = console_handle->fd;
- DEBUG("%s: closing console handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing console handle %p", __func__, handle);
g_free (console_handle->filename);
if(!(console_handle->fileaccess & GENERIC_READ) &&
!(console_handle->fileaccess & GENERIC_ALL)) {
- DEBUG ("%s: handle %p doesn't have GENERIC_READ access: %u",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, console_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
} while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
- DEBUG("%s: read of handle %p error: %s", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__, handle,
strerror(errno));
_wapi_set_last_error_from_errno ();
if(!(console_handle->fileaccess & GENERIC_WRITE) &&
!(console_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
} else {
_wapi_set_last_error_from_errno ();
- DEBUG ("%s: write of handle %p error: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
__func__, handle, strerror(errno));
return(FALSE);
struct _WapiHandle_file *pipe_handle = (struct _WapiHandle_file*)data;
int fd = pipe_handle->fd;
- DEBUG("%s: closing pipe handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing pipe handle %p", __func__, handle);
/* No filename with pipe handles */
if(!(pipe_handle->fileaccess & GENERIC_READ) &&
!(pipe_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, pipe_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
- DEBUG ("%s: reading up to %d bytes from pipe %p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: reading up to %d bytes from pipe %p", __func__,
numbytes, handle);
do {
} else {
_wapi_set_last_error_from_errno ();
- DEBUG("%s: read of handle %p error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
handle, strerror(errno));
return(FALSE);
}
}
- DEBUG ("%s: read %d bytes from pipe", __func__, ret);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe", __func__, ret);
if(bytesread!=NULL) {
*bytesread=ret;
if(!(pipe_handle->fileaccess & GENERIC_WRITE) &&
!(pipe_handle->fileaccess & GENERIC_ALL)) {
- DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
- DEBUG ("%s: writing up to %d bytes to pipe %p", __func__, numbytes,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: writing up to %d bytes to pipe %p", __func__, numbytes,
handle);
do {
} else {
_wapi_set_last_error_from_errno ();
- DEBUG("%s: write of handle %p error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s", __func__,
handle, strerror(errno));
return(FALSE);
flags=O_RDWR;
break;
default:
- DEBUG("%s: Unknown access type 0x%x", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown access type 0x%x", __func__,
fileaccess);
break;
}
flags|=O_TRUNC;
break;
default:
- DEBUG("%s: Unknown create mode 0x%x", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown create mode 0x%x", __func__,
createmode);
break;
}
*/
if (file_existing_share == 0) {
/* Quick and easy, no possibility to share */
- DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
_wapi_handle_share_release (*share_info);
((file_existing_share == FILE_SHARE_WRITE) &&
(fileaccess != GENERIC_WRITE))) {
/* New access mode doesn't match up */
- DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
_wapi_handle_share_release (*share_info);
((file_existing_access & GENERIC_WRITE) &&
!(sharemode & FILE_SHARE_WRITE))) {
/* New share mode doesn't match up */
- DEBUG ("%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
_wapi_handle_share_release (*share_info);
return(FALSE);
}
} else {
- DEBUG ("%s: New file!", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
}
return(TRUE);
*/
if (file_existing_share == 0) {
/* Quick and easy, no possibility to share */
- DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, (*share_info)->access);
_wapi_handle_share_release (*share_info);
if (!(file_existing_share & FILE_SHARE_DELETE)) {
/* New access mode doesn't match up */
- DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, (*share_info)->access, file_existing_share);
_wapi_handle_share_release (*share_info);
return(FALSE);
}
} else {
- DEBUG ("%s: New file!", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
}
return(TRUE);
}
if (name == NULL) {
- DEBUG ("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
filename = mono_unicode_to_external (name);
if (filename == NULL) {
- DEBUG("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
}
- DEBUG ("%s: Opening %s with share 0x%x and access 0x%x", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening %s with share 0x%x and access 0x%x", __func__,
filename, sharemode, fileaccess);
fd = _wapi_open (filename, flags, perms);
}
if (fd == -1) {
- DEBUG("%s: Error opening file %s: %s", __func__, filename,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename,
strerror(errno));
_wapi_set_last_path_error_from_errno (NULL, filename);
g_free (filename);
}
if (fd >= _wapi_fd_reserve) {
- DEBUG ("%s: File descriptor is too big", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
ret = fstat (fd, &statbuf);
if (ret == -1) {
- DEBUG ("%s: fstat error of file %s: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fstat error of file %s: %s", __func__,
filename, strerror (errno));
_wapi_set_last_error_from_errno ();
g_free (filename);
}
if (file_handle.share_info == NULL) {
/* No space, so no more files can be opened */
- DEBUG ("%s: No space in the share table", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No space in the share table", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
close (fd);
return(INVALID_HANDLE_VALUE);
}
- DEBUG("%s: returning handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
return(handle);
}
#endif
if(name==NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
filename=mono_unicode_to_external(name);
if(filename==NULL) {
- DEBUG("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
attrs = GetFileAttributes (name);
if (attrs == INVALID_FILE_ATTRIBUTES) {
- DEBUG ("%s: file attributes error", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file attributes error", __func__);
/* Error set by GetFileAttributes() */
g_free (filename);
return(FALSE);
struct _WapiFileShare *shareinfo;
if(name==NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
}
if(dest_name==NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
g_free (utf8_name);
SetLastError (ERROR_INVALID_NAME);
utf8_dest_name = mono_unicode_to_external (dest_name);
if (utf8_dest_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
g_free (utf8_name);
SetLastError (ERROR_INVALID_NAME);
if (report_errors)
_wapi_set_last_error_from_errno ();
- DEBUG ("%s: write failed.", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write failed.", __func__);
free (buf);
return FALSE;
}
int ret_utime;
if(name==NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_src = mono_unicode_to_external (name);
if (utf8_src == NULL) {
- DEBUG ("%s: unicode conversion of source returned NULL",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of source returned NULL",
__func__);
SetLastError (ERROR_INVALID_PARAMETER);
}
if(dest_name==NULL) {
- DEBUG("%s: dest is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dest is NULL", __func__);
g_free (utf8_src);
SetLastError (ERROR_INVALID_NAME);
utf8_dest = mono_unicode_to_external (dest_name);
if (utf8_dest == NULL) {
- DEBUG ("%s: unicode conversion of dest returned NULL",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of dest returned NULL",
__func__);
SetLastError (ERROR_INVALID_PARAMETER);
dest_time.actime = st.st_atime;
ret_utime = utime (utf8_dest, &dest_time);
if (ret_utime == -1)
- DEBUG ("%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
g_free (utf8_src);
g_free (utf8_dest);
gchar *utf8_ret;
if (arg == NULL) {
- DEBUG ("%s: %s is NULL", __func__, arg_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s is NULL", __func__, arg_name);
SetLastError (ERROR_INVALID_NAME);
return NULL;
}
utf8_ret = mono_unicode_to_external (arg);
if (utf8_ret == NULL) {
- DEBUG ("%s: unicode conversion of %s returned NULL",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of %s returned NULL",
__func__, arg_name);
SetLastError (ERROR_INVALID_PARAMETER);
return NULL;
break;
default:
- DEBUG("%s: unknown standard handle type", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unknown standard handle type", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(INVALID_HANDLE_VALUE);
const guint16 *ip;
if(system_time==NULL) {
- DEBUG("%s: system_time NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: system_time NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
* year and day calculation to work later
*/
if(file_ticks<0) {
- DEBUG("%s: file_time too big", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file_time too big", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
totaldays=(file_ticks / TICKS_PER_DAY);
rem = file_ticks % TICKS_PER_DAY;
- DEBUG("%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
system_time->wHour=rem/TICKS_PER_HOUR;
rem %= TICKS_PER_HOUR;
- DEBUG("%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
system_time->wMinute = rem / TICKS_PER_MINUTE;
rem %= TICKS_PER_MINUTE;
- DEBUG("%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
rem);
system_time->wSecond = rem / TICKS_PER_SECOND;
rem %= TICKS_PER_SECOND;
- DEBUG("%s: Second: %d rem: %lld", __func__, system_time->wSecond,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Second: %d rem: %lld", __func__, system_time->wSecond,
rem);
system_time->wMilliseconds = rem / TICKS_PER_MILLISECOND;
- DEBUG("%s: Milliseconds: %d", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Milliseconds: %d", __func__,
system_time->wMilliseconds);
/* January 1, 1601 was a Monday, according to Emacs calendar */
system_time->wDayOfWeek = ((1 + totaldays) % 7) + 1;
- DEBUG("%s: Day of week: %d", __func__, system_time->wDayOfWeek);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day of week: %d", __func__, system_time->wDayOfWeek);
/* This algorithm to find year and month given days from epoch
* from glibc
while(totaldays < 0 || totaldays >= (isleap(y)?366:365)) {
/* Guess a corrected year, assuming 365 days per year */
gint64 yg = y + totaldays / 365 - (totaldays % 365 < 0);
- DEBUG("%s: totaldays: %lld yg: %lld y: %lld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld yg: %lld y: %lld", __func__,
totaldays, yg,
y);
g_message("%s: LEAPS(yg): %lld LEAPS(y): %lld", __func__,
totaldays -= ((yg - y) * 365
+ LEAPS_THRU_END_OF (yg - 1)
- LEAPS_THRU_END_OF (y - 1));
- DEBUG("%s: totaldays: %lld", __func__, totaldays);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
y = yg;
- DEBUG("%s: y: %lld", __func__, y);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: y: %lld", __func__, y);
}
system_time->wYear = y;
- DEBUG("%s: Year: %d", __func__, system_time->wYear);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Year: %d", __func__, system_time->wYear);
ip = mon_yday[isleap(y)];
continue;
}
totaldays-=ip[y];
- DEBUG("%s: totaldays: %lld", __func__, totaldays);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
system_time->wMonth = y + 1;
- DEBUG("%s: Month: %d", __func__, system_time->wMonth);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Month: %d", __func__, system_time->wMonth);
system_time->wDay = totaldays + 1;
- DEBUG("%s: Day: %d", __func__, system_time->wDay);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day: %d", __func__, system_time->wDay);
return(TRUE);
}
int result;
if (pattern == NULL) {
- DEBUG ("%s: pattern is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pattern is NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
return(INVALID_HANDLE_VALUE);
utf8_pattern = mono_unicode_to_external (pattern);
if (utf8_pattern == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
}
- DEBUG ("%s: looking for [%s]", __func__, utf8_pattern);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for [%s]", __func__, utf8_pattern);
/* Figure out which bit of the pattern is the directory */
dir_part = _wapi_dirname (utf8_pattern);
}
if (result < 0) {
-#ifdef DEBUG_ENABLED
- gint errnum = errno;
-#endif
_wapi_set_last_path_error_from_errno (dir_part, NULL);
- DEBUG ("%s: scandir error: %s", __func__,
- g_strerror (errnum));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: scandir error: %s", __func__, g_strerror (errno));
g_free (utf8_pattern);
g_free (entry_part);
g_free (dir_part);
g_free (utf8_pattern);
g_free (entry_part);
- DEBUG ("%s: Got %d matches", __func__, result);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Got %d matches", __func__, result);
find_handle.dir_part = dir_part;
find_handle.num = result;
}
if (result != 0) {
- DEBUG ("%s: stat failed: %s", __func__, filename);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: stat failed: %s", __func__, filename);
g_free (filename);
goto retry;
#ifndef __native_client__
result = _wapi_lstat (filename, &linkbuf);
if (result != 0) {
- DEBUG ("%s: lstat failed: %s", __func__, filename);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lstat failed: %s", __func__, filename);
g_free (filename);
goto retry;
}
g_free (filename);
- DEBUG ("%s: Found [%s]", __func__, utf8_filename);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found [%s]", __func__, utf8_filename);
/* fill data block */
int result;
if (name == NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
int result;
if (name == NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
guint32 ret;
if (name == NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return (INVALID_FILE_ATTRIBUTES);
int result;
if (level != GetFileExInfoStandard) {
- DEBUG ("%s: info level %d not supported.", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: info level %d not supported.", __func__,
level);
SetLastError (ERROR_INVALID_PARAMETER);
}
if (name == NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
*/
if (name == NULL) {
- DEBUG("%s: name is NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
mono_once (&io_ops_once, io_ops_init);
- DEBUG ("%s: Creating pipe", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating pipe", __func__);
ret=pipe (filedes);
if(ret==-1) {
- DEBUG ("%s: Error creating pipe: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error creating pipe: %s", __func__,
strerror (errno));
_wapi_set_last_error_from_errno ();
if (filedes[0] >= _wapi_fd_reserve ||
filedes[1] >= _wapi_fd_reserve) {
- DEBUG ("%s: File descriptor is too big", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
*readpipe = read_handle;
*writepipe = write_handle;
- DEBUG ("%s: Returning pipe: read handle %p, write handle %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning pipe: read handle %p, write handle %p",
__func__, read_handle, write_handle);
return(TRUE);
else {
utf8_path_name = mono_unicode_to_external (path_name);
if (utf8_path_name == NULL) {
- DEBUG("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
if (ret == -1) {
_wapi_set_last_error_from_errno ();
- DEBUG ("%s: statvfs failed: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: statvfs failed: %s", __func__, strerror (errno));
return(FALSE);
}
else {
utf8_root_path_name = mono_unicode_to_external (root_path_name);
if (utf8_root_path_name == NULL) {
- DEBUG("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
return(DRIVE_NO_ROOT_DIR);
}
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/io-private.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
gboolean
_wapi_lock_file_region (int fd, off_t offset, off_t length)
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
- DEBUG ("%s: fcntl returns %d", __func__, ret);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
- DEBUG ("%s: fcntl returns %d", __func__, ret);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
- DEBUG ("%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
if (offset_high > 0 || length_high > 0) {
SetLastError (ERROR_INVALID_PARAMETER);
offset = offset_low;
length = length_low;
- DEBUG ("%s: Locking handle %p, offset %ld, length %ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %ld, length %ld", __func__,
handle, offset, length);
#endif
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
- DEBUG ("%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
offset = offset_low;
length = length_low;
- DEBUG ("%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
#endif
return(_wapi_unlock_file_region (fd, offset, length));
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/mutex-private.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
static void mutex_signal(gpointer handle);
static gboolean mutex_own (gpointer handle);
_wapi_thread_own_mutex (handle);
- DEBUG("%s: owning mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning mutex handle %p", __func__, handle);
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
mutex_handle->tid = pthread_self ();
mutex_handle->recursion++;
- DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p locked %d times by %d:%ld", __func__,
handle, mutex_handle->recursion, mutex_handle->pid,
mutex_handle->tid);
return(FALSE);
}
- DEBUG("%s: testing ownership mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership mutex handle %p", __func__, handle);
if (mutex_handle->recursion > 0 &&
mutex_handle->pid == _wapi_getpid () &&
pthread_equal (mutex_handle->tid, pthread_self ())) {
- DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p owned by %d:%ld", __func__,
handle, _wapi_getpid (), pthread_self ());
return(TRUE);
} else {
- DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
return(FALSE);
}
struct _WapiHandle_namedmutex *namedmutex_handle;
gboolean ok;
- DEBUG ("%s: owning named mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named mutex handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX,
(gpointer *)&namedmutex_handle);
_wapi_shared_handle_set_signal_state (handle, FALSE);
- DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p locked %d times by %d:%ld", __func__,
handle, namedmutex_handle->recursion,
namedmutex_handle->pid, namedmutex_handle->tid);
return(FALSE);
}
- DEBUG ("%s: testing ownership mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership mutex handle %p", __func__, handle);
if (namedmutex_handle->recursion > 0 &&
namedmutex_handle->pid == _wapi_getpid () &&
pthread_equal (namedmutex_handle->tid, pthread_self ())) {
- DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p owned by %d:%ld", __func__,
handle, _wapi_getpid (), pthread_self ());
return(TRUE);
} else {
- DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
return(FALSE);
}
return;
}
- DEBUG ("%s: Checking ownership of named mutex handle %p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Checking ownership of named mutex handle %p", __func__,
handle);
if (namedmutex_handle->recursion == 0) {
- DEBUG ("%s: Named mutex handle %p not owned", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p not owned", __func__,
handle);
} else if (namedmutex_handle->pid == _wapi_getpid ()) {
- DEBUG ("%s: Named mutex handle %p owned by this process",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p owned by this process",
__func__, handle);
} else {
int thr_ret;
gpointer proc_handle;
- DEBUG ("%s: Named mutex handle %p owned by another process", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p owned by another process", __func__, handle);
proc_handle = OpenProcess (0, 0, namedmutex_handle->pid);
if (proc_handle == NULL) {
/* Didn't find the process that this handle
* was owned by, overriding it
*/
- DEBUG ("%s: overriding old owner of named mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: overriding old owner of named mutex handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
_wapi_shared_handle_set_signal_state (handle, TRUE);
_wapi_handle_unlock_shared_handles ();
} else {
- DEBUG ("%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
}
if (proc_handle != NULL)
CloseProcess (proc_handle);
if (mutex_handle->pid == pid &&
pthread_equal (mutex_handle->tid, tid)) {
- DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Mutex handle %p abandoned!", __func__, handle);
mutex_handle->recursion = 0;
mutex_handle->pid = 0;
if (mutex_handle->pid == pid &&
pthread_equal (mutex_handle->tid, tid)) {
- DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Mutex handle %p abandoned!", __func__, handle);
mutex_handle->recursion = 0;
mutex_handle->pid = 0;
*/
SetLastError (ERROR_SUCCESS);
- DEBUG ("%s: Creating unnamed mutex", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating unnamed mutex", __func__);
handle = _wapi_handle_new (WAPI_HANDLE_MUTEX, &mutex_handle);
if (handle == _WAPI_HANDLE_INVALID) {
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
- DEBUG ("%s: returning mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning mutex handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Creating named mutex [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named mutex [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
- DEBUG ("%s: returning mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning mutex handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
- DEBUG("%s: Releasing mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Releasing mutex handle %p", __func__, handle);
if (!pthread_equal (mutex_handle->tid, tid) ||
mutex_handle->pid != pid) {
- DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
goto cleanup;
}
if(mutex_handle->recursion==0) {
_wapi_thread_disown_mutex (handle);
- DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking mutex handle %p", __func__, handle);
mutex_handle->pid=0;
mutex_handle->tid=0;
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
- DEBUG("%s: Releasing mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Releasing mutex handle %p", __func__, handle);
if (!pthread_equal (mutex_handle->tid, tid) ||
mutex_handle->pid != pid) {
- DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
goto cleanup;
}
if(mutex_handle->recursion==0) {
_wapi_thread_disown_mutex (handle);
- DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking mutex handle %p", __func__, handle);
mutex_handle->pid=0;
mutex_handle->tid=0;
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Opening named mutex [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named mutex [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
utf8_name);
}
ret = handle;
- DEBUG ("%s: returning named mutex handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named mutex handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/io-private.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
static guint32
convert_from_flags(int flags)
} else if ((flags & O_ACCMODE) == O_RDWR) {
fileaccess=GENERIC_READ|GENERIC_WRITE;
} else {
- DEBUG("%s: Can't figure out flags 0x%x", __func__, flags);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't figure out flags 0x%x", __func__, flags);
}
/* Maybe sort out create mode too */
gpointer handle;
int flags;
- DEBUG("%s: creating standard handle type %s, fd %d", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating standard handle type %s, fd %d", __func__,
name, fd);
#if !defined(__native_client__)
/* Invalid fd. Not really much point checking for EBADF
* specifically
*/
- DEBUG("%s: fcntl error on fd %d: %s", __func__, fd,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl error on fd %d: %s", __func__, fd,
strerror(errno));
SetLastError (_wapi_get_win32_file_error (errno));
return(INVALID_HANDLE_VALUE);
}
- DEBUG("%s: returning handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
return(handle);
}
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/process-private.h>
#include <mono/io-layer/threads.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-path.h>
#include <mono/io-layer/timefuncs-private.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
/* The process' environment strings */
#if defined(__APPLE__)
extern char **environ;
#endif
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#define DEBUG_ENABLED 1
-#else
-#define DEBUG(...)
-#endif
-
static guint32 process_wait (gpointer handle, guint32 timeout, gboolean alertable);
static void process_close (gpointer handle, gpointer data);
static gboolean is_pid_valid (pid_t pid);
char *dir = NULL, **env_strings = NULL, **argv = NULL;
guint32 i, env_count = 0;
gboolean ret = FALSE;
- gpointer handle;
+ gpointer handle = NULL;
WapiHandle_process process_handle = {0}, *process_handle_data;
GError *gerr = NULL;
int in_fd, out_fd, err_fd;
- pid_t pid;
+ pid_t pid = 0;
int thr_ret;
int startup_pipe [2] = {-1, -1};
int dummy;
if (appname != NULL) {
cmd = mono_unicode_to_external (appname);
if (cmd == NULL) {
- DEBUG ("%s: unicode conversion returned NULL",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL",
__func__);
SetLastError (ERROR_PATH_NOT_FOUND);
if (cmdline != NULL) {
args = mono_unicode_to_external (cmdline);
if (args == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
if (cwd != NULL) {
dir = mono_unicode_to_external (cwd);
if (dir == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
/* Executable existing ? */
if (!is_readable_or_executable (prog)) {
- DEBUG ("%s: Couldn't find executable %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
SetLastError (ERROR_FILE_NOT_FOUND);
/* And make sure it's readable */
if (!is_readable_or_executable (prog)) {
- DEBUG ("%s: Couldn't find executable %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
SetLastError (ERROR_FILE_NOT_FOUND);
if (token == NULL) {
/* Give up */
- DEBUG ("%s: Couldn't find what to exec", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find what to exec", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
/* Executable existing ? */
if (!is_readable_or_executable (prog)) {
- DEBUG ("%s: Couldn't find executable %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, token);
g_free (token);
SetLastError (ERROR_FILE_NOT_FOUND);
g_free (prog);
prog = g_find_program_in_path (token);
if (prog == NULL) {
- DEBUG ("%s: Couldn't find executable %s", __func__, token);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s", __func__, token);
g_free (token);
SetLastError (ERROR_FILE_NOT_FOUND);
g_free (token);
}
- DEBUG ("%s: Exec prog [%s] args [%s]", __func__, prog,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Exec prog [%s] args [%s]", __func__, prog,
args_after_prog);
/* Check for CLR binaries; if found, we will try to invoke
}
} else {
if (!is_executable (prog)) {
- DEBUG ("%s: Executable permisson not set on %s", __func__, prog);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Executable permisson not set on %s", __func__, prog);
SetLastError (ERROR_ACCESS_DENIED);
goto free_strings;
}
/* Could not create the pipe to synchroniz process startup. We'll just not synchronize.
* This is just for a very hard to hit race condition in the first place */
startup_pipe [0] = startup_pipe [1] = -1;
- DEBUG ("%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
}
thr_ret = _wapi_handle_lock_shared_handles ();
if (startup_pipe [0] != -1) {
/* Wait until the parent has updated it's internal data */
ssize_t _i G_GNUC_UNUSED = read (startup_pipe [0], &dummy, 1);
- DEBUG ("%s: child: parent has completed its setup", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: child: parent has completed its setup", __func__);
close (startup_pipe [0]);
close (startup_pipe [1]);
}
close (i);
#ifdef DEBUG_ENABLED
- DEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: exec()ing [%s] in dir [%s]", __func__, cmd,
dir == NULL?".":dir);
for (i = 0; argv[i] != NULL; i++)
g_message ("arg %d: [%s]", i, argv[i]);
if (argv)
g_strfreev (argv);
- DEBUG ("%s: returning handle %p for pid %d", __func__, handle,
- pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p for pid %d", __func__, handle, pid);
/* Check if something needs to be cleaned up. */
mono_processes_cleanup ();
progname = g_get_prgname ();
utf8_progname = mono_utf8_from_external (progname);
- DEBUG ("%s: using [%s] as prog name", __func__, progname);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: using [%s] as prog name", __func__, progname);
if (utf8_progname) {
slash = strrchr (utf8_progname, '/');
process_handle = lookup_process_handle (handle);
g_assert (process_handle);
- DEBUG ("%s: looking at process %d", __func__, process_handle->id);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking at process %d", __func__, process_handle->id);
checking_pid = process_handle->id;
/* Find the process handle that corresponds to pid */
gpointer handle = NULL;
- DEBUG ("%s: looking for process %d", __func__, pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for process %d", __func__, pid);
handle = _wapi_search_handle (WAPI_HANDLE_PROCESS,
process_open_compare,
*/
return WAPI_PID_TO_HANDLE (pid);
} else {
- DEBUG ("%s: Can't find pid %d", __func__, pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find pid %d", __func__, pid);
SetLastError (ERROR_PROC_NOT_FOUND);
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
return FALSE;
}
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
return FALSE;
}
mod->inode = i;
mod->filename = g_strdup (info->dlpi_name);
- DEBUG ("%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
mod->inode, mod->filename, mod->address_start, mod->address_end);
free(info);
if (procname == NULL || modulename == NULL)
return (FALSE);
- DEBUG ("%s: procname=\"%s\", modulename=\"%s\"", __func__, procname, modulename);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: procname=\"%s\", modulename=\"%s\"", __func__, procname, modulename);
pname = mono_path_resolve_symlinks (procname);
mname = mono_path_resolve_symlinks (modulename);
g_free (pname);
g_free (mname);
- DEBUG ("%s: result is %d", __func__, result);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: result is %d", __func__, result);
return result;
}
} else {
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
return FALSE;
}
if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
if (errno == ENOMEM) {
free(pi);
- DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
}
return(ret);
}
mib [2] = KERN_PROC_PID;
mib [3] = pid;
if (sysctl(mib, 4, NULL, &size, NULL, 0) < 0) {
- DEBUG ("%s: sysctl() failed: %d", __func__, errno);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sysctl() failed: %d", __func__, errno);
return(ret);
}
if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
if (errno == ENOMEM) {
free(pi);
- DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
}
return(ret);
}
retry:
if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0) {
- DEBUG ("%s: sysctl() failed: %d", __func__, errno);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sysctl() failed: %d", __func__, errno);
return(ret);
}
int i;
char *proc_name = NULL;
- DEBUG ("%s: Getting module base name, process handle %p module %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Getting module base name, process handle %p module %p",
__func__, process, module);
size = size * sizeof (gunichar2); /* adjust for unicode characters */
} else {
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__,
process);
return 0;
g_free (proc_name);
if (procname_ext) {
- DEBUG ("%s: Process name is [%s]", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Process name is [%s]", __func__,
procname_ext);
procname = mono_unicode_from_external (procname_ext, &bytes);
bytes += 2;
if (size < bytes) {
- DEBUG ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
memcpy (basename, procname, size);
} else {
- DEBUG ("%s: Size %d larger than needed (%ld)",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d larger than needed (%ld)",
__func__, size, bytes);
memcpy (basename, procname, bytes);
bytes += 2;
if (size < bytes) {
- DEBUG ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
memcpy (basename, proc_path, size);
} else {
- DEBUG ("%s: Size %d larger than needed (%ld)",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d larger than needed (%ld)",
__func__, size, bytes);
memcpy (basename, proc_path, bytes);
gboolean ret = FALSE;
char *proc_name = NULL;
- DEBUG ("%s: Getting module info, process handle %p module %p",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Getting module info, process handle %p module %p",
__func__, process, module);
if (modinfo == NULL || size < sizeof (WapiModuleInfo))
} else {
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__,
process);
return FALSE;
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
return FALSE;
}
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
return FALSE;
}
} else {
process_handle = lookup_process_handle (process);
if (!process_handle) {
- DEBUG ("%s: Can't find process %p", __func__, process);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
SetLastError (ERROR_INVALID_HANDLE);
return FALSE;
}
GSList *l;
gpointer unref_handle;
- DEBUG ("%s", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s", __func__);
/* Ensure we're not in here in multiple threads at once, nor recursive. */
if (InterlockedCompareExchange (&mono_processes_cleaning_up, 1, 0) != 0)
mono_os_mutex_unlock (&mono_processes_mutex);
- DEBUG ("%s done", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s done", __func__);
InterlockedDecrement (&mono_processes_cleaning_up);
}
{
WapiHandle_process *process_handle;
- DEBUG ("%s", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s", __func__);
process_handle = (WapiHandle_process *) data;
g_free (process_handle->proc_name);
int pid;
struct MonoProcess *p;
- DEBUG ("SIG CHILD handler for pid: %i\n", info->si_pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "SIG CHILD handler for pid: %i\n", info->si_pid);
do {
do {
if (pid <= 0)
break;
- DEBUG ("child ended: %i", pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "child ended: %i", pid);
/*
* This can run concurrently with the code in the rest of this module.
}
} while (1);
- DEBUG ("SIG CHILD handler: done looping.");
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "SIG CHILD handler: done looping.");
}
#endif
sigemptyset (&sa.sa_mask);
sa.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
g_assert (sigaction (SIGCHLD, &sa, &previous_chld_sa) != -1);
- DEBUG ("Added SIGCHLD handler");
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "Added SIGCHLD handler");
#endif
}
* but WaitFor*Object won't call us for pseudo handles. */
g_assert ((GPOINTER_TO_UINT (handle) & _WAPI_PROCESS_UNHANDLED) != _WAPI_PROCESS_UNHANDLED);
- DEBUG ("%s (%p, %u)", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u)", __func__, handle, timeout);
process_handle = lookup_process_handle (handle);
if (!process_handle) {
if (process_handle->exited) {
/* We've already done this one */
- DEBUG ("%s (%p, %u): Process already exited", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Process already exited", __func__, handle, timeout);
return WAIT_OBJECT_0;
}
pid = process_handle->id;
- DEBUG ("%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
/* We don't need to lock mono_processes here, the entry
* has a handle_count > 0 which means it will not be freed. */
while (1) {
if (timeout != INFINITE) {
- DEBUG ("%s (%p, %u): waiting on semaphore for %li ms...",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore for %li ms...",
__func__, handle, timeout, (timeout - (now - start)));
ret = mono_os_sem_timedwait (&mp->exit_sem, (timeout - (now - start)), alertable ? MONO_SEM_FLAGS_ALERTABLE : MONO_SEM_FLAGS_NONE);
} else {
- DEBUG ("%s (%p, %u): waiting on semaphore forever...",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore forever...",
__func__, handle, timeout);
ret = mono_os_sem_wait (&mp->exit_sem, alertable ? MONO_SEM_FLAGS_ALERTABLE : MONO_SEM_FLAGS_NONE);
}
if (ret == -1 && errno != EINTR && errno != ETIMEDOUT) {
- DEBUG ("%s (%p, %u): sem_timedwait failure: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): sem_timedwait failure: %s",
__func__, handle, timeout, g_strerror (errno));
/* Should we return a failure here? */
}
}
if (timeout == 0) {
- DEBUG ("%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
return WAIT_TIMEOUT;
}
now = mono_msec_ticks ();
if (now - start >= timeout) {
- DEBUG ("%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
return WAIT_TIMEOUT;
}
if (alertable && _wapi_thread_cur_apc_pending ()) {
- DEBUG ("%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
return WAIT_IO_COMPLETION;
}
}
/* Process must have exited */
- DEBUG ("%s (%p, %u): Waited successfully", __func__, handle, timeout);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Waited successfully", __func__, handle, timeout);
ret = _wapi_handle_lock_shared_handles ();
g_assert (ret == 0);
process_handle->exited = TRUE;
- DEBUG ("%s (%p, %u): Setting pid %d signalled, exit status %d",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Setting pid %d signalled, exit status %d",
__func__, handle, timeout, process_handle->id, process_handle->exitstatus);
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/semaphore-private.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
static void sema_signal(gpointer handle);
static gboolean sema_own (gpointer handle);
return(FALSE);
}
- DEBUG("%s: owning sem handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning sem handle %p", __func__, handle);
sem_handle->val--;
- DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val now %d", __func__, handle, sem_handle->val);
if(sem_handle->val==0) {
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
struct _WapiHandle_namedsem *namedsem_handle;
gboolean ok;
- DEBUG ("%s: owning named sem handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named sem handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDSEM,
(gpointer *)&namedsem_handle);
namedsem_handle->val--;
- DEBUG ("%s: named sem %p val now %d", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val now %d", __func__, handle,
namedsem_handle->val);
if (namedsem_handle->val == 0) {
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
- DEBUG ("%s: Created semaphore handle %p initial %d max %d",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Created semaphore handle %p initial %d max %d",
__func__, handle, initial, max);
thr_ret = _wapi_handle_unlock_handle (handle);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Creating named sem [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named sem [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
- DEBUG ("%s: returning named sem handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
mono_once (&sem_ops_once, sem_ops_init);
if (max <= 0) {
- DEBUG ("%s: max <= 0", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: max <= 0", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(NULL);
}
if (initial > max || initial < 0) {
- DEBUG ("%s: initial>max or < 0", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: initial>max or < 0", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(NULL);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
- DEBUG ("%s: sem %p val %d count %d", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val %d count %d", __func__, handle,
sem_handle->val, count);
/* Do this before checking for count overflow, because overflowing max
/* No idea why max is signed, but thats the spec :-( */
if (sem_handle->val + count > (guint32)sem_handle->max) {
- DEBUG ("%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
goto end;
}
ret = TRUE;
- DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val now %d", __func__, handle, sem_handle->val);
end:
thr_ret = _wapi_handle_unlock_handle (handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
- DEBUG("%s: named sem %p val %d count %d", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val %d count %d", __func__, handle,
sem_handle->val, count);
/* Do this before checking for count overflow, because overflowing max
/* No idea why max is signed, but thats the spec :-( */
if (sem_handle->val + count > (guint32)sem_handle->max) {
- DEBUG ("%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
goto end;
}
ret = TRUE;
- DEBUG("%s: named sem %p val now %d", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val now %d", __func__, handle,
sem_handle->val);
end:
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
- DEBUG ("%s: Opening named sem [%s]", __func__, utf8_name);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named sem [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
utf8_name);
}
ret = handle;
- DEBUG ("%s: returning named sem handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <mono/io-layer/socket-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/socket-wrappers.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-poll.h>
#include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#endif
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
static guint32 in_cleanup = 0;
static void socket_close (gpointer handle, gpointer data);
int ret;
struct _WapiHandle_socket *socket_handle = (struct _WapiHandle_socket *)data;
- DEBUG ("%s: closing socket handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing socket handle %p", __func__, handle);
/* Shutdown the socket for reading, to interrupt any potential
* receives that may be blocking for data. See bug 75705.
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: close error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: close error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
if (!in_cleanup)
WSASetLastError (errnum);
void _wapi_cleanup_networking(void)
{
- DEBUG ("%s: cleaning up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: cleaning up", __func__);
in_cleanup = 1;
_wapi_handle_foreach (WAPI_HANDLE_SOCKET, cleanup_close, NULL);
if (new_fd == -1) {
gint errnum = errno;
- DEBUG ("%s: accept error: %s", __func__, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: accept error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
}
if (new_fd >= _wapi_fd_reserve) {
- DEBUG ("%s: File descriptor is too big", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
WSASetLastError (WSASYSCALLFAILURE);
return(INVALID_SOCKET);
}
- DEBUG ("%s: returning newly accepted socket handle %p with",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning newly accepted socket handle %p with",
__func__, new_handle);
return(new_fd);
ret = bind (fd, my_addr, addrlen);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: bind error: %s", __func__, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: bind error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
errnum = errno;
if (errno != EINTR) {
- DEBUG ("%s: connect error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect error: %s", __func__,
strerror (errnum));
errnum = errno_to_WSA (errnum, __func__);
if (errno != EINTR) {
errnum = errno_to_WSA (errno, __func__);
- DEBUG ("%s: connect poll error: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect poll error: %s",
__func__, strerror (errno));
WSASetLastError (errnum);
&len) == -1) {
errnum = errno_to_WSA (errno, __func__);
- DEBUG ("%s: connect getsockopt error: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt error: %s",
__func__, strerror (errno));
WSASetLastError (errnum);
socket_handle->saved_error = errnum;
}
- DEBUG ("%s: connect getsockopt returned error: %s",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt returned error: %s",
__func__, strerror (so_error));
WSASetLastError (errnum);
ret = getpeername (fd, name, namelen);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: getpeername error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getpeername error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
ret = getsockname (fd, name, namelen);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: getsockname error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockname error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
ret = getsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: getsockopt error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockopt error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
ret = listen (fd, backlog);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: listen error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: listen error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: recv error: %s", __func__, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recv error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: recvmsg error: %s", __func__, strerror(errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recvmsg error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: send error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
#ifdef O_NONBLOCK
/* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: send error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: sendmsg error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sendmsg error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = setsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: setsockopt error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setsockopt error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
ret = shutdown (fd, how);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: shutdown error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: shutdown error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
if (fd == -1) {
gint errnum = errno;
- DEBUG ("%s: socket error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
}
if (fd >= _wapi_fd_reserve) {
- DEBUG ("%s: File descriptor is too big (%d >= %d)",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big (%d >= %d)",
__func__, fd, _wapi_fd_reserve);
WSASetLastError (WSASYSCALLFAILURE);
if (ret == -1) {
int errnum = errno;
- DEBUG ("%s: Error setting SO_REUSEADDR", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error setting SO_REUSEADDR", __func__);
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
return(INVALID_SOCKET);
}
- DEBUG ("%s: returning socket handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning socket handle %p", __func__, handle);
return(fd);
}
if (newsock == -1) {
gint errnum = errno;
- DEBUG ("%s: socket error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: dup2 error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dup2 error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
static gboolean wapi_disconnectex (guint32 fd, WapiOverlapped *overlapped,
guint32 flags, guint32 reserved)
{
- DEBUG ("%s: called on socket %d!", __func__, fd);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: called on socket %d!", __func__, fd);
if (reserved != 0) {
WSASetLastError (WSAEINVAL);
ret = ioctl (fd, command, buffer);
if (ret == -1) {
gint errnum = errno;
- DEBUG("%s: WSAIoctl error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: WSAIoctl error: %s", __func__,
strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: ioctl error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: ioctl error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
- DEBUG ("%s: select error: %s", __func__, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: select error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
#include <mono/io-layer/versioninfo.h>
#include <mono/io-layer/io-portability.h>
#include <mono/io-layer/error.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-mmap.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
#define ALIGN32(ptr) ptr = (gpointer)((char *)ptr + 3); ptr = (gpointer)((char *)ptr - ((gsize)ptr & 3));
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
- DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
- DEBUG ("%s: File is too small: %d", __func__, map_size);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
nt_headers = (WapiImageNTHeaders32 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
- DEBUG ("%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_rva == 0) {
- DEBUG ("%s: No resources in file!", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
- DEBUG ("%s: Can't find resource directory", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
- DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
- DEBUG ("%s: File is too small: %d", __func__, map_size);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
nt_headers = (WapiImageNTHeaders64 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
- DEBUG ("%s: Bad NT signature 0x%x", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__,
nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
}
if (resource_rva == 0) {
- DEBUG ("%s: No resources in file!", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
- DEBUG ("%s: Can't find resource directory", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
filename_ext = mono_unicode_to_external (filename);
if (filename_ext == NULL) {
- DEBUG ("%s: unicode conversion returned NULL", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(NULL);
fd = _wapi_open (filename_ext, O_RDONLY, 0);
if (fd == -1) {
- DEBUG ("%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
}
if (fstat (fd, &statbuf) == -1) {
- DEBUG ("%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
/* Check basic file size */
if (statbuf.st_size < sizeof(WapiImageDosHeader)) {
- DEBUG ("%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
SetLastError (ERROR_BAD_LENGTH);
g_free (filename_ext);
file_map = mono_file_map (statbuf.st_size, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, 0, handle);
if (file_map == NULL) {
- DEBUG ("%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
data_ptr = get_versioninfo_block (data, block);
if (block->value_len != sizeof(WapiFixedFileInfo)) {
- DEBUG ("%s: FIXEDFILEINFO size mismatch", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: FIXEDFILEINFO size mismatch", __func__);
return(NULL);
}
if (!unicode_string_equals (block->key, "VS_VERSION_INFO")) {
- DEBUG ("%s: VS_VERSION_INFO mismatch", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: VS_VERSION_INFO mismatch", __func__);
return(NULL);
}
ffi = ((WapiFixedFileInfo *)data_ptr);
if ((ffi->dwSignature != VS_FFI_SIGNATURE) ||
(ffi->dwStrucVersion != VS_FFI_STRUCVERSION)) {
- DEBUG ("%s: FIXEDFILEINFO bad signature", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: FIXEDFILEINFO bad signature", __func__);
return(NULL);
}
/* We must have hit padding, so give up
* processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
/* We must have hit padding, so give up
* processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
found_lang = g_utf16_to_utf8 (block->key, 8, NULL, NULL, NULL);
if (found_lang == NULL) {
- DEBUG ("%s: Didn't find a valid language key, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid language key, giving up", __func__);
return(NULL);
}
if (data_ptr == NULL) {
/* Child block hit padding */
- DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
/* We must have hit padding, so give up
* processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
- DEBUG ("%s: Didn't find a valid string, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
- DEBUG ("%s: Didn't find a valid data string, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid data string, giving up", __func__);
return(NULL);
}
memcpy ((gpointer)data_ptr, big_value,
/* We must have hit padding, so give up
* processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
big_value = g_convert ((gchar *)block->key, 16, "UTF-16BE",
"UTF-16LE", NULL, NULL, NULL);
if (big_value == NULL) {
- DEBUG ("%s: Didn't find a valid string, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
if (data_ptr == NULL) {
/* Child block hit padding */
- DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
/* We must have hit padding, so give
* up processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
return;
}
&block);
} else {
/* Bogus data */
- DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Not a valid VERSIONINFO child block", __func__);
return;
}
if (data_ptr == NULL) {
/* Child block hit padding */
- DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
return;
}
}
/* We must have hit padding,
* so give up processing now
*/
- DEBUG ("%s: Hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
goto done;
}
}
} else {
/* Bogus data */
- DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Not a valid VERSIONINFO child block", __func__);
goto done;
}
if (data_ptr == NULL) {
/* Child block hit padding */
- DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
goto done;
}
}
#include <mono/io-layer/wapi.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/wapi-private.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
static gboolean own_if_signalled(gpointer handle)
{
if (_wapi_handle_test_capabilities (handle,
WAPI_HANDLE_CAP_WAIT) == FALSE) {
- DEBUG ("%s: handle %p can't be waited for", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p can't be waited for", __func__,
handle);
return(WAIT_FAILED);
_wapi_handle_ops_prewait (handle);
if (_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_SPECIAL_WAIT) == TRUE) {
- DEBUG ("%s: handle %p has special wait", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p has special wait", __func__, handle);
ret = _wapi_handle_ops_special_wait (handle, timeout, alertable);
}
- DEBUG ("%s: locking handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
if (_wapi_handle_test_capabilities (handle,
WAPI_HANDLE_CAP_OWN) == TRUE) {
if (own_if_owned (handle) == TRUE) {
- DEBUG ("%s: handle %p already owned", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already owned", __func__,
handle);
ret = WAIT_OBJECT_0;
goto done;
}
if (own_if_signalled (handle) == TRUE) {
- DEBUG ("%s: handle %p already signalled", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already signalled", __func__,
handle);
ret=WAIT_OBJECT_0;
_wapi_handle_ops_prewait (handle);
if (own_if_signalled (handle)) {
- DEBUG ("%s: handle %p signalled", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
handle);
ret = WAIT_OBJECT_0;
* if someone else got in before us.)
*/
if (own_if_signalled (handle)) {
- DEBUG ("%s: handle %p signalled", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
handle);
ret=WAIT_OBJECT_0;
} while(waited == 0 && !apc_pending);
/* Timeout or other error */
- DEBUG ("%s: wait on handle %p error: %s", __func__, handle,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait on handle %p error: %s", __func__, handle,
strerror (waited));
ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
done:
- DEBUG ("%s: unlocking handle %p", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
guint32 timeout, gboolean alertable)
{
- guint32 ret, waited;
+ guint32 ret = 0, waited;
int thr_ret;
gboolean apc_pending = FALSE;
gpointer current_thread = wapi_get_current_thread_handle ();
return (WAIT_FAILED);
}
- DEBUG ("%s: locking handle %p", __func__, wait);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handle %p", __func__, wait);
thr_ret = _wapi_handle_lock_handle (wait);
g_assert (thr_ret == 0);
if (_wapi_handle_test_capabilities (wait, WAPI_HANDLE_CAP_OWN)==TRUE) {
if (own_if_owned (wait)) {
- DEBUG ("%s: handle %p already owned", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already owned", __func__,
wait);
ret = WAIT_OBJECT_0;
goto done;
}
if (own_if_signalled (wait)) {
- DEBUG ("%s: handle %p already signalled", __func__, wait);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already signalled", __func__, wait);
ret = WAIT_OBJECT_0;
goto done;
_wapi_handle_ops_prewait (wait);
if (own_if_signalled (wait)) {
- DEBUG ("%s: handle %p signalled", __func__, wait);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__, wait);
ret = WAIT_OBJECT_0;
goto done;
* if someone else got in before us.)
*/
if (own_if_signalled (wait)) {
- DEBUG ("%s: handle %p signalled", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
wait);
ret = WAIT_OBJECT_0;
} while(waited == 0 && !apc_pending);
/* Timeout or other error */
- DEBUG ("%s: wait on handle %p error: %s", __func__, wait,
- strerror (ret));
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait on handle %p error: %s", __func__, wait, strerror (ret));
ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
done:
- DEBUG ("%s: unlocking handle %p", __func__, wait);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, wait);
thr_ret = _wapi_handle_unlock_handle (wait);
g_assert (thr_ret == 0);
gboolean done;
int i;
- DEBUG ("%s: locking handles", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handles", __func__);
done = _wapi_handle_count_signalled_handles (numobjects, handles,
waitall, count, lowest);
}
}
- DEBUG ("%s: unlocking handles", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handles", __func__);
_wapi_handle_unlock_handles (numobjects, handles);
}
if (numobjects > MAXIMUM_WAIT_OBJECTS) {
- DEBUG ("%s: Too many handles: %d", __func__, numobjects);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Too many handles: %d", __func__, numobjects);
return(WAIT_FAILED);
}
handles[i] = wapi_get_current_thread_handle ();
if (handles[i] == NULL) {
- DEBUG ("%s: Handle %d bogus", __func__, i);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %d bogus", __func__, i);
bogustype = TRUE;
break;
}
if ((GPOINTER_TO_UINT (handles[i]) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED) {
- DEBUG ("%s: Handle %d pseudo process", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %d pseudo process", __func__,
i);
bogustype = TRUE;
}
if (_wapi_handle_test_capabilities (handles[i], WAPI_HANDLE_CAP_WAIT) == FALSE) {
- DEBUG ("%s: Handle %p can't be waited for",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %p can't be waited for",
__func__, handles[i]);
bogustype = TRUE;
}
if (duplicate == TRUE) {
- DEBUG ("%s: Returning due to duplicates", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning due to duplicates", __func__);
return(WAIT_FAILED);
}
if (bogustype == TRUE) {
- DEBUG ("%s: Returning due to bogus type", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning due to bogus type", __func__);
return(WAIT_FAILED);
}
}
}
- DEBUG ("%s: locking signal mutex", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking signal mutex", __func__);
thr_ret = _wapi_handle_lock_signal_mutex ();
g_assert (thr_ret == 0);
ret = 0;
}
- DEBUG ("%s: unlocking signal mutex", __func__);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking signal mutex", __func__);
thr_ret = _wapi_handle_unlock_signal_mutex (NULL);
g_assert (thr_ret == 0);
/* Didn't get all handles, and there was a
* timeout or other error
*/
- DEBUG ("%s: wait returned error: %s", __func__,
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait returned error: %s", __func__,
strerror (ret));
if(ret==ETIMEDOUT) {
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/thread-private.h>
#include <mono/io-layer/mutex-private.h>
+#include <mono/io-layer/io-trace.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
-#if 0
-#define WAIT_DEBUG(code) do { code } while (0)
-#else
-#define WAIT_DEBUG(code) do { } while (0)
-#endif
-
struct _WapiHandleOps _wapi_thread_ops = {
NULL, /* close */
NULL, /* signal */
return;
}
- DEBUG ("%s: Thread %p terminating", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p terminating", __func__, handle);
thread_handle = lookup_thread (handle);
- DEBUG ("%s: Thread %p abandoning held mutexes", __func__, handle);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p abandoning held mutexes", __func__, handle);
for (i = 0; i < thread_handle->owned_mutexes->len; i++) {
gpointer mutex = g_ptr_array_index (thread_handle->owned_mutexes, i);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- DEBUG("%s: Recording thread handle %p id %ld status as %d",
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Recording thread handle %p id %ld status as %d",
__func__, handle, thread_handle->id, exitstatus);
/* The thread is no longer active, so unref it */
*/
_wapi_handle_ref (handle);
- DEBUG ("%s: started thread id %ld", __func__, thread->id);
+ MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: started thread id %ld", __func__, thread->id);
return handle;
}