1

I'm using Mono 3.2.7 on OSX. I would like my program to be able to trigger a thread dump for the diagnostic exports.

[DllImport("libmono", EntryPoint = "_mono_threads_request_thread_dump")]
public static extern void MonoThreadsRequestThreadDump();

Nothing is written to stdout when this is called.

Removing the leading underscore causes a native exception in Mono as expected.

What am I doing incorrectly or what is a better way to achieve my goal?

Joseph Lennox
  • 3,202
  • 1
  • 27
  • 25
  • You could send your own process the `SIGQUIT` signal (as explained [here](http://stackoverflow.com/a/2068471/21567)). – Christian.K Dec 31 '15 at 20:56
  • @Christian.K "you should not expect it to remain usable/stable" is a deal breaker. – Joseph Lennox Jan 01 '16 at 00:06
  • Yes, it would. But without any offence to the person who answered the other question, I would not blindly take that for granted. Just handling SIGQUIT is not reason to become unstable. I would do my own research first. The function that the SIGQUIT handler calls in the end seems to be the one you mention anyway. – Christian.K Jan 01 '16 at 00:07
  • I'm trying to do the same, ideally from c#, but trying now from gdb. I can get full output of threads, but I have to keep constantly flushing stdout for several seconds. ```(gdb) call fflush(0)``` – Michal Dobrodenka Sep 20 '18 at 10:22

1 Answers1

1

Use [DllImport("__Internal")] instead of libmono. Calling this method works, but still has problem with flushing stdout.

Easier way is to send SIGQUIT signal, it will write Full thread dump to stdout.

Michal Dobrodenka
  • 1,104
  • 8
  • 27