Skip to content

Commit

Permalink
Use the Unity PAL for the IL2CPP debugger
Browse files Browse the repository at this point in the history
Change the IL2CPP manager debugger to use the Unity PAL, so the debugger
can work on all platforms that IL2CPP supports.
  • Loading branch information
Josh Peterson committed Feb 23, 2018
1 parent 991e78a commit 6decd17
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 11 deletions.
10 changes: 9 additions & 1 deletion mono/metadata/w32process-unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS)

#ifdef HOST_WIN32
typedef struct {
gpointer lpBaseOfDll;
guint32 SizeOfImage;
gpointer EntryPoint;
} MODULEINFO;
#endif

void
mono_w32process_init (void)
{
Expand Down Expand Up @@ -108,7 +116,7 @@ ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
}

gboolean
mono_w32process_get_fileversion_info (gunichar2 *filename, guint32 handle, guint32 len, gpointer data)
mono_w32process_get_fileversion_info (gunichar2 *filename, gpointer* data)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return FALSE;
Expand Down
4 changes: 2 additions & 2 deletions mono/metadata/w32socket-unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS)

gboolean
ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError* error)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return FALSE;
}

MonoBoolean
ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion mono/mini/il2cpp-c-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ void* il2cpp_gc_alloc_fixed(size_t size);
void il2cpp_gc_free_fixed(void* address);
const char* il2cpp_domain_get_name(MonoDomain* domain);

#endif
#endif
8 changes: 4 additions & 4 deletions mono/utils/mono-threads-unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS)

#include "Thread-c-api.h"

void
mono_threads_suspend_init (void)
{
Expand Down Expand Up @@ -99,15 +101,13 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_
MonoNativeThreadId
mono_native_thread_id_get (void)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return 0;
return (MonoNativeThreadId)UnityPalGetCurrentThreadId();
}

gboolean
mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return FALSE;
return id1 == id2;
}

gboolean
Expand Down
80 changes: 77 additions & 3 deletions mono/utils/networking-unity.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,86 @@
#include <config.h>
#include <glib.h>


#include <mono/utils/networking.h>

#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS)

#include "Socket-c-api.h"

static void
add_hostent(MonoAddressInfo *info, int flags, const char* name, gint family, char** aliases, void** addresses, int32_t addressSize)
{
MonoAddressEntry *cur, *prev = info->entries;
int idx = 0;
int address_length = 0;

if (!info->aliases)
info->aliases = g_strdupv(aliases);

while (addresses[idx]) {
cur = g_new0(MonoAddressEntry, 1);
if (prev)
prev->next = cur;
else
info->entries = cur;

if (flags & MONO_HINT_CANONICAL_NAME && name)
cur->canonical_name = g_strdup(name);

cur->family = family;
cur->socktype = SOCK_STREAM;
cur->protocol = 0; /* Zero means the default stream protocol */
address_length = addressSize;
cur->address_len = address_length;
memcpy(&cur->address, addresses[idx], address_length);

prev = cur;
++idx;
}
}

static void free_null_terminated_array (void** array)
{
if (array != NULL)
{
int i = 0;
while (array[i] != NULL)
{
g_free(array[i]);
i++;
}
}
g_free(array);
}

int
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **result)
mono_get_address_info(const char *hostname, int port, int flags, MonoAddressInfo **result)
{
g_assert(0 && "This function is not yet implemented for the Unity platform.");
return 0;
MonoAddressInfo *addr_info;
addr_info = g_new0(MonoAddressInfo, 1);

char* name;
gint family;
char** aliases;
void** addresses;
int32_t addressSize;

if (UnityPalGetHostByName(hostname, &name, &family, &aliases, &addresses, &addressSize) == kWaitStatusSuccess)
add_hostent(addr_info, flags, name, family, aliases, addresses, addressSize);

g_free(name);
free_null_terminated_array(aliases);
free_null_terminated_array(addresses);

if (!addr_info->entries) {
*result = NULL;
mono_free_address_info(addr_info);
return 1;
}

*result = addr_info;
return 0;
}

void *
Expand Down

0 comments on commit 6decd17

Please sign in to comment.