|
2 | 2 | #include "mono/metadata/mono-debug.h"
|
3 | 3 | #include "mono/metadata/profiler.h"
|
4 | 4 |
|
5 |
| -static char * |
6 |
| -pmip_pretty(MonoCompile* monoCompile) |
7 |
| -{ |
8 |
| - char* methodName; |
9 |
| - char* assemblyName; |
10 |
| - char* formattedPMIP; |
11 |
| - MonoDebugSourceLocation* debugSourceLocation; |
12 |
| - MonoDebugMethodInfo* debugMethodInfo; |
13 |
| - MonoDomain* domain; |
14 |
| - MonoMethod* method = monoCompile->method; |
15 |
| - |
16 |
| - domain = mono_domain_get(); |
17 |
| - if (!domain) |
18 |
| - domain = mono_get_root_domain(); |
19 |
| - |
20 |
| - methodName = mono_method_full_name(method, TRUE); |
21 |
| - |
22 |
| - debugSourceLocation = mono_debug_lookup_source_location(method, 0, domain); |
23 |
| - debugMethodInfo = mono_debug_lookup_method(method); |
24 |
| - |
25 |
| - assemblyName = method->klass->image->module_name; |
26 |
| - |
27 |
| - formattedPMIP = g_strdup_printf("[%s] %s", assemblyName, methodName); |
28 |
| - |
29 |
| - mono_debug_free_source_location(debugSourceLocation); |
30 |
| - g_free(methodName); |
31 |
| - |
32 |
| - return formattedPMIP; |
33 |
| -} |
34 |
| - |
35 | 5 | #if !defined(DISABLE_JIT) && defined(HOST_WIN32)
|
36 | 6 |
|
37 | 7 | static gboolean enabled;
|
@@ -99,24 +69,27 @@ mixed_callstack_plugin_on_domain_unload_end()
|
99 | 69 | void
|
100 | 70 | mixed_callstack_plugin_save_method_info (MonoCompile *cfg)
|
101 | 71 | {
|
102 |
| - char* pretty_name; |
103 |
| - char* frame; |
| 72 | + char* method_name; |
104 | 73 | long bytesWritten = 0;
|
| 74 | + char frame[1024]; |
| 75 | + int bytes; |
105 | 76 |
|
106 | 77 | if (!enabled)
|
107 | 78 | return;
|
108 | 79 |
|
109 |
| - pretty_name = pmip_pretty(cfg); |
| 80 | + method_name = mono_method_full_name (cfg->method, TRUE); |
| 81 | + |
| 82 | + bytes = snprintf (frame, sizeof (frame), "%p;%p;[%s] %s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, cfg->method->klass->image->module_name, method_name); |
| 83 | + /* negative value is encoding error */ |
| 84 | + if (bytes < 0 || bytes > sizeof (frame)) |
| 85 | + return; |
110 | 86 |
|
111 | 87 | mixed_callstack_plugin_lock ();
|
112 |
| - frame = g_strdup_printf("%p;%p;%s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, pretty_name); |
113 |
| - WriteFile(fileHandle, frame, strlen(frame), &bytesWritten, NULL); |
| 88 | + WriteFile(fileHandle, frame, bytes, &bytesWritten, NULL); |
114 | 89 | FlushFileBuffers(fileHandle);
|
115 |
| - |
116 | 90 | mixed_callstack_plugin_unlock ();
|
117 | 91 |
|
118 |
| - g_free(pretty_name); |
119 |
| - g_free(frame); |
| 92 | + g_free(method_name); |
120 | 93 | }
|
121 | 94 |
|
122 | 95 | void
|
|
0 commit comments