我正在尝试使用单声道分析器分析Xamarin.Mac应用程序,但遇到错误。该应用在本地构建,用于使用 Visual Studio for Mac 进行调试,并使用 MSBuild CLI 为 App Store 构建。
我试过这个:
-
通过 Visual Studio for Mac 构建应用,其中包含完整的调试信息
-
mono --profile=log "MyApp.app/Contents/MonoBundle/MyApp.exe"
失败了
标准输出:
aot-runtime.c:2441: Image out of date assembly:/Users/chase/MyApp/MyAppWeb/projects/MyApp.Mac/bin/Debug/MyApp (Dev).app/Contents/MonoBundle/MyApp (Dev).exe.dylib type:<unknown type> member:(null) signature:<none>
标准:
Stacktrace:
Native stacktrace:
0 mono 0x000000010578ebf8 mono_handle_native_crash + 264
1 libsystem_platform.dylib 0x00007fff5fa03f5a _sigtramp + 26
2 mono 0x0000000105abb148 pvars + 328
3 libsystem_c.dylib 0x00007fff5f7a11ae abort + 127
4 mono 0x000000010599cb0f mono_log_write_logfile + 351
5 mono 0x00000001059b551e monoeg_g_log + 206
6 mono 0x00000001059a2cc6 mono_error_assert_ok_pos + 54
7 mono 0x000000010577512f decode_cached_class_info + 447
8 mono 0x0000000105775530 mono_aot_get_cached_class_info + 432
9 mono 0x0000000105856d5c mono_class_init + 364
10 mono 0x0000000105700f38 mono_method_to_ir + 86040
11 mono 0x00000001056d8807 mini_method_compile + 3287
12 mono 0x00000001056dbf16 mono_jit_compile_method_inner + 790
13 mono 0x00000001056df4d2 mono_jit_compile_method_with_opt + 1442
14 mono 0x00000001056e2f25 mono_jit_runtime_invoke + 501
15 mono 0x00000001058dbab4 do_runtime_invoke + 84
16 mono 0x00000001058df079 do_exec_main_checked + 137
17 mono 0x0000000105750b0f mono_jit_exec + 287
18 mono 0x0000000105753a8d mono_main + 11069
19 mono 0x00000001056d2c4d main + 253
20 mono 0x00000001056d2b44 start + 52
Debug info from gdb:
(lldb) command source -s 0 '/tmp/mono-gdb-commands.MwIxeR'
Executing commands in '/tmp/mono-gdb-commands.MwIxeR'.
(lldb) process attach --pid 3702
warning: (x86_64) /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/4.5/mscorlib.dll.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
Process 3702 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007fff5f846232 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
-> 0x7fff5f846232 <+10>: jae 0x7fff5f84623c ; <+20>
0x7fff5f846234 <+12>: movq %rax, %rdi
0x7fff5f846237 <+15>: jmp 0x7fff5f83cb25 ; cerror
0x7fff5f84623c <+20>: retq
Target 0: (mono) stopped.
Executable module set to "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono".
Architecture set to: x86_64h-apple-macosx.
(lldb) thread list
Process 3702 stopped
* thread #1: tid = 0x1e6e4, 0x00007fff5f846232 libsystem_kernel.dylib`__wait4 + 10, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
thread #2: tid = 0x1e6e7, 0x00007fff5f845a1e libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
thread #3: tid = 0x1e6e8, 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
thread #4: tid = 0x1e6e9, 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Profiler sampler'
thread #5: tid = 0x1e6ea, 0x00007fff5f845cfa libsystem_kernel.dylib`__select + 10, name = 'Profiler helper'
thread #6: tid = 0x1e6eb, 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Profiler writer'
thread #7: tid = 0x1e6ec, 0x00007fff5f83c25e libsystem_kernel.dylib`semaphore_timedwait_trap + 10, name = 'Profiler dumper'
(lldb) thread backtrace all
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x00007fff5f846232 libsystem_kernel.dylib`__wait4 + 10
frame #1: 0x000000010578ec9f mono`mono_handle_native_crash(signal=<unavailable>, ctx=<unavailable>, info=<unavailable>) at mini-exceptions.c:2830 [opt]
frame #2: 0x00007fff5fa03f5a libsystem_platform.dylib`_sigtramp + 26
frame #3: 0x00007fff5f845b6f libsystem_kernel.dylib`__pthread_kill + 11
frame #4: 0x00007fff5fa10080 libsystem_pthread.dylib`pthread_kill + 333
frame #5: 0x00007fff5f7a11ae libsystem_c.dylib`abort + 127
frame #6: 0x000000010599cb0f mono`mono_log_write_logfile(log_domain=<unavailable>, level=<unavailable>, hdr=<unavailable>, message="aot-runtime.c:2441: Image out of date assembly:/Users/chase/MyApp/MyAppWeb/projects/MyApp.Mac/bin/Debug/MyApp (Dev).app/Contents/MonoBundle/MyApp (Dev).exe.dylib type:<unknown type> member:(null) signature:<none>n") at mono-log-common.c:135 [opt]
frame #7: 0x00000001059b551e mono`monoeg_g_log [inlined] monoeg_g_logv at goutput.c:115 [opt]
frame #8: 0x00000001059b54d8 mono`monoeg_g_log(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, format=<unavailable>) at goutput.c:125 [opt]
frame #9: 0x00000001059a2cc6 mono`mono_error_assert_ok_pos(error=<unavailable>, filename="aot-runtime.c", lineno=2441) at mono-error.c:171 [opt]
frame #10: 0x000000010577512f mono`decode_cached_class_info(module=<unavailable>, info=<unavailable>, buf=" x10À(x12", endbuf=0x00007ffeea52ed68) at aot-runtime.c:2441 [opt]
frame #11: 0x0000000105775530 mono`mono_aot_get_cached_class_info(klass=<unavailable>, res=<unavailable>) at aot-runtime.c:2515 [opt]
frame #12: 0x0000000105856d5c mono`mono_class_init [inlined] mono_class_get_cached_class_info(klass=0x00007fba84e0c1c8, res=<unavailable>) at class.c:8958 [opt]
frame #13: 0x0000000105856d44 mono`mono_class_init(klass=0x00007fba84e0c1c8) at class.c:4975 [opt]
frame #14: 0x0000000105700f38 mono`mono_method_to_ir(cfg=<unavailable>, method=<unavailable>, start_bblock=0x00007fba8681f430, end_bblock=0x00007fba8681f580, return_var=0x0000000000000000, inline_args=0x00007fba8681fe28, inline_offset=<unavailable>, is_virtual_call=<unavailable>) at method-to-ir.c:8404 [opt]
frame #15: 0x00000001056d8807 mono`mini_method_compile(method=<unavailable>, opts=370239999, domain=0x00007fba84c0a040, flags=JIT_FLAG_RUN_CCTORS, parts=0, aot_method_index=-1) at mini.c:3440 [opt]
frame #16: 0x00000001056dbf16 mono`mono_jit_compile_method_inner(method=0x00007fba84c0b928, target_domain=0x00007fba84c0a040, opt=370239999, error=0x00007ffeea52f688) at mini.c:4181 [opt]
frame #17: 0x00000001056df4d2 mono`mono_jit_compile_method_with_opt(method=0x00007fba84c0b928, opt=<unavailable>, jit_only=<unavailable>, error=0x00007ffeea52f688) at mini-runtime.c:2129 [opt]
frame #18: 0x00000001056e2f25 mono`mono_jit_runtime_invoke [inlined] mono_jit_compile_method(method=<unavailable>, error=0x00007ffeea52f688) at mini-runtime.c:2175 [opt]
frame #19: 0x00000001056e2f01 mono`mono_jit_runtime_invoke(method=0x00007fba84c0b928, obj=<unavailable>, params=0x00007ffeea52f648, exc=0x0000000000000000, error=<unavailable>) at mini-runtime.c:2687 [opt]
frame #20: 0x00000001058dbab4 mono`do_runtime_invoke(method=0x00007fba84c0b928, obj=0x0000000000000000, params=0x00007ffeea52f648, exc=0x0000000000000000, error=0x00007ffeea52f688) at object.c:2887 [opt]
frame #21: 0x00000001058df079 mono`do_exec_main_checked [inlined] mono_runtime_invoke_checked(method=<unavailable>, obj=<unavailable>, error=<unavailable>) at object.c:3040 [opt]
frame #22: 0x00000001058df038 mono`do_exec_main_checked(method=0x00007fba84c0b928, args=<unavailable>, error=0x00007ffeea52f688) at object.c:4784 [opt]
frame #23: 0x0000000105750b0f mono`mono_jit_exec(domain=<unavailable>, assembly=<unavailable>, argc=1, argv=0x00007ffeea52fa18) at driver.g.c:1210 [opt]
frame #24: 0x0000000105753a8d mono`mono_main [inlined] main_thread_handler at driver.g.c:1287 [opt]
frame #25: 0x0000000105753a59 mono`mono_main(argc=<unavailable>, argv=<unavailable>) at driver.g.c:2417 [opt]
frame #26: 0x00000001056d2c4d mono`main [inlined] mono_main_with_options(argc=<unavailable>, argv=<unavailable>) at main.c:47 [opt]
frame #27: 0x00000001056d2c39 mono`main(argc=3, argv=<unavailable>) at main.c:340 [opt]
frame #28: 0x00000001056d2b44 mono`start + 52
thread #2, name = 'SGen worker'
frame #0: 0x00007fff5f845a1e libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff5fa0e589 libsystem_pthread.dylib`_pthread_cond_wait + 732
frame #2: 0x0000000105993ffe mono`thread_func [inlined] mono_os_cond_wait(mutex=<unavailable>) at mono-os-mutex.h:173 [opt]
frame #3: 0x0000000105993feb mono`thread_func at sgen-thread-pool.c:165 [opt]
frame #4: 0x0000000105993fdd mono`thread_func(data=0x0000000000000000) at sgen-thread-pool.c:196 [opt]
frame #5: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #6: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #7: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
thread #3, name = 'Finalizer'
frame #0: 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x0000000105941a9c mono`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:90 [opt]
frame #2: 0x0000000105941a91 mono`finalizer_thread at mono-coop-semaphore.h:43 [opt]
frame #3: 0x0000000105941a85 mono`finalizer_thread(unused=<unavailable>) at gc.c:852 [opt]
frame #4: 0x00000001058fd960 mono`start_wrapper [inlined] start_wrapper_internal at threads.c:1004 [opt]
frame #5: 0x00000001058fd8c3 mono`start_wrapper(data=<unavailable>) at threads.c:1064 [opt]
frame #6: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #7: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #8: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
thread #4, name = 'Profiler sampler'
frame #0: 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x00000001058eaf3b mono`mono_profiler_sampling_thread_wait [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_NONE) at mono-os-semaphore.h:90 [opt]
frame #2: 0x00000001058eaf24 mono`mono_profiler_sampling_thread_wait at profiler.c:536 [opt]
frame #3: 0x00000001058308c7 mono`sampling_thread_func(data=<unavailable>) at mini-posix.c:643 [opt]
frame #4: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #5: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #6: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
thread #5, name = 'Profiler helper'
frame #0: 0x00007fff5f845cfa libsystem_kernel.dylib`__select + 10
frame #1: 0x0000000105c08bde libmono-profiler-log.0.dylib`helper_thread(arg=<unavailable>) at log.c:3773 [opt]
frame #2: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #3: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #4: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
thread #6, name = 'Profiler writer'
frame #0: 0x00007fff5f83c246 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x0000000105c0987b libmono-profiler-log.0.dylib`writer_thread [inlined] mono_os_sem_wait at mono-os-semaphore.h:90 [opt]
frame #2: 0x0000000105c09862 libmono-profiler-log.0.dylib`writer_thread(arg=<unavailable>) at log.c:4009 [opt]
frame #3: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #4: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #5: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
thread #7, name = 'Profiler dumper'
frame #0: 0x00007fff5f83c25e libsystem_kernel.dylib`semaphore_timedwait_trap + 10
frame #1: 0x0000000105c0a3d2 libmono-profiler-log.0.dylib`dumper_thread [inlined] mono_os_sem_timedwait(timeout_ms=1000, flags=MONO_SEM_FLAGS_NONE) at mono-os-semaphore.h:124 [opt]
frame #2: 0x0000000105c0a3be libmono-profiler-log.0.dylib`dumper_thread(arg=<unavailable>) at log.c:4118 [opt]
frame #3: 0x00007fff5fa0d661 libsystem_pthread.dylib`_pthread_body + 340
frame #4: 0x00007fff5fa0d50d libsystem_pthread.dylib`_pthread_start + 377
frame #5: 0x00007fff5fa0cbf9 libsystem_pthread.dylib`thread_start + 13
(lldb) detach
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Process 3702 detached
(lldb) quit
我的单声道版本是
Mono JIT compiler version 5.10.1.57 (2017-12/ea8a24b1bbf Tue Apr 24 14:53:01 EDT 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(3.6.0svn-mono-master/8b1520c8aae)
GC: sgen (concurrent by default)
如何解决此问题?更一般地说,如何使用单声道探查器分析 Xamarin.Mac 应用捆绑包?
相关问题:在 Xamarin.Mac 应用程序捆绑包上运行仪器,它询问如何使用 Mac 版仪器而不是单声道探查器进行分析。
编辑
MONO_ENV_OPTIONS
我尝试了菲利普·纳瓦拉的答案
Xamarin.Mac 具有特定的启动序列,并嵌入了特定版本的 Mono 运行时。通过直接运行"mono",您可以绕过启动序列,这可能会导致问题。正确的方法是使用 MONO_ENV_OPTIONS 环境变量传递选项:MONO_ENV_OPTIONS=--profile=log MyApp.app/Contents/MacOS/MyApp。
但我收到一个错误:
echo $MONO_ENV_OPTIONS
MONO_ENV_OPTIONS=--profile=log /Users/chase/MyApp/MyAppWeb/projects/MyApp.Mac/bin/Debug/MyApp.app/Contents/MacOS/MyApp
cd /Users/chase/MyApp/MyAppWeb/projects/MyApp.Mac/bin/Debug/MyApp.app/Contents/MacOS/
./MyApp
Cannot open assembly '/Users/chase/MyApp/MyAppWeb/projects/MyApp.Mac/bin/Debug/MyApp.app/Contents/MacOS/MyApp': File does not contain a valid CIL image.
如果我清除MONO_ENV_OPTIONS,则不会收到错误,并且应用程序运行正常(但是,当然,探查器不会运行(。
我不确定它是否有助于解决您的特定错误,但这里有一些提示。
Xamarin.Mac 具有特定的启动序列,并嵌入了特定版本的 Mono 运行时。通过直接运行"mono",您可以绕过启动序列,这可能会导致问题。正确的方法是使用MONO_ENV_OPTIONS
环境变量传递选项:MONO_ENV_OPTIONS=--profile=log MyApp.app/Contents/MacOS/MyApp
。
分析应用程序的另一种方法是调整 MonoDevelop 代码。它使用系统sample
工具,然后对输出进行后处理,以将不透明的函数偏移量转换为 .NET 方法名称。