我想转储具有堆栈跟踪的所有线程,内部函数mono_threads_request_thread_dump()
是这样做的,我可以从gdb调用它,也可以从mono / linux上的C#代码调用它吗?
函数在threads.h
文件中
https://github.com/corngood/mono/blob/master/mono/metadata/threads.h
答案 0 :(得分:2)
使用__Internal
的DllImport调用主机中的本机方法。
[DllImport("__Internal")]
public static extern void mono_threads_request_thread_dump();
public static void Main(string[] args)
{
mono_threads_request_thread_dump();
Console.WriteLine("Hello World!");
}
Full thread dump:
"<unnamed thread>" at <unknown> <0xffffffff>
at Console_ThreadDump.MainClass.Main (string[]) [0x00007] in /Volumes/Code/code/Projects/Console_ThreadDump/Console_ThreadDump/Program.cs:14
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <e3877a65d90742cebc8141de4055f006>:0
"Debugger agent"
"Finalizer"Hello World!
Press any key to continue...