Skip to content

Commit 58faedf

Browse files
author
Josh Peterson
committed
Use the Unity PAL for the IL2CPP debugger
Change the IL2CPP manager debugger to use the Unity PAL, so the debugger can work on all platforms that IL2CPP supports.
1 parent 991e78a commit 58faedf

File tree

5 files changed

+104
-11
lines changed

5 files changed

+104
-11
lines changed

mono/metadata/w32process-unity.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

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

6+
#ifdef HOST_WIN32
7+
typedef struct {
8+
gpointer lpBaseOfDll;
9+
guint32 SizeOfImage;
10+
gpointer EntryPoint;
11+
} MODULEINFO;
12+
#endif
13+
614
void
715
mono_w32process_init (void)
816
{
@@ -108,7 +116,7 @@ ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
108116
}
109117

110118
gboolean
111-
mono_w32process_get_fileversion_info (gunichar2 *filename, guint32 handle, guint32 len, gpointer data)
119+
mono_w32process_get_fileversion_info (gunichar2 *filename, gpointer* data)
112120
{
113121
g_assert(0 && "This function is not yet implemented for the Unity platform.");
114122
return FALSE;

mono/metadata/w32socket-unity.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,26 @@
33

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

6+
#ifdef NO_HAVE_TRANSMIT_FILE_BUFFERS
7+
8+
typedef struct {
9+
gpointer Head;
10+
guint32 HeadLength;
11+
gpointer Tail;
12+
guint32 TailLength;
13+
} TRANSMIT_FILE_BUFFERS;
14+
15+
#endif
16+
617
gboolean
7-
ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
18+
ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError* error)
819
{
920
g_assert(0 && "This function is not yet implemented for the Unity platform.");
1021
return FALSE;
1122
}
1223

1324
MonoBoolean
14-
ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
25+
ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error)
1526
{
1627
g_assert(0 && "This function is not yet implemented for the Unity platform.");
1728
return FALSE;

mono/mini/il2cpp-c-types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ void* il2cpp_gc_alloc_fixed(size_t size);
117117
void il2cpp_gc_free_fixed(void* address);
118118
const char* il2cpp_domain_get_name(MonoDomain* domain);
119119

120-
#endif
120+
#endif

mono/utils/mono-threads-unity.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
#include "Thread-c-api.h"
6+
57
void
68
mono_threads_suspend_init (void)
79
{
@@ -99,15 +101,13 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_
99101
MonoNativeThreadId
100102
mono_native_thread_id_get (void)
101103
{
102-
g_assert(0 && "This function is not yet implemented for the Unity platform.");
103-
return 0;
104+
return (MonoNativeThreadId)UnityPalGetCurrentThreadId();
104105
}
105106

106107
gboolean
107108
mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
108109
{
109-
g_assert(0 && "This function is not yet implemented for the Unity platform.");
110-
return FALSE;
110+
return id1 == id2;
111111
}
112112

113113
gboolean

mono/utils/networking-unity.c

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,86 @@
1+
#include <config.h>
2+
#include <glib.h>
3+
4+
15
#include <mono/utils/networking.h>
26

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

9+
#include "Socket-c-api.h"
10+
11+
static void
12+
add_hostent(MonoAddressInfo *info, int flags, const char* name, gint family, char** aliases, void** addresses, int32_t addressSize)
13+
{
14+
MonoAddressEntry *cur, *prev = info->entries;
15+
int idx = 0;
16+
int address_length = 0;
17+
18+
if (!info->aliases)
19+
info->aliases = g_strdupv(aliases);
20+
21+
while (addresses[idx]) {
22+
cur = g_new0(MonoAddressEntry, 1);
23+
if (prev)
24+
prev->next = cur;
25+
else
26+
info->entries = cur;
27+
28+
if (flags & MONO_HINT_CANONICAL_NAME && name)
29+
cur->canonical_name = g_strdup(name);
30+
31+
cur->family = family;
32+
cur->socktype = SOCK_STREAM;
33+
cur->protocol = 0; /* Zero means the default stream protocol */
34+
address_length = addressSize;
35+
cur->address_len = address_length;
36+
memcpy(&cur->address, addresses[idx], address_length);
37+
38+
prev = cur;
39+
++idx;
40+
}
41+
}
42+
43+
static void free_null_terminated_array (void** array)
44+
{
45+
if (array != NULL)
46+
{
47+
int i = 0;
48+
while (array[i] != NULL)
49+
{
50+
g_free(array[i]);
51+
i++;
52+
}
53+
}
54+
g_free(array);
55+
}
56+
557
int
6-
mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **result)
58+
mono_get_address_info(const char *hostname, int port, int flags, MonoAddressInfo **result)
759
{
8-
g_assert(0 && "This function is not yet implemented for the Unity platform.");
9-
return 0;
60+
MonoAddressInfo *addr_info;
61+
addr_info = g_new0(MonoAddressInfo, 1);
62+
63+
char* name;
64+
gint family;
65+
char** aliases;
66+
void** addresses;
67+
int32_t addressSize;
68+
69+
if (UnityPalGetHostByName(hostname, &name, &family, &aliases, &addresses, &addressSize) == kWaitStatusSuccess)
70+
add_hostent(addr_info, flags, name, family, aliases, addresses, addressSize);
71+
72+
g_free(name);
73+
free_null_terminated_array(aliases);
74+
free_null_terminated_array(addresses);
75+
76+
if (!addr_info->entries) {
77+
*result = NULL;
78+
mono_free_address_info(addr_info);
79+
return 1;
80+
}
81+
82+
*result = addr_info;
83+
return 0;
1084
}
1185

1286
void *

0 commit comments

Comments
 (0)