#include <mono/metadata/threads.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/io-layer/io-layer.h>
#include "mono/metadata/profiler.h"
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
#endif
}
-pid_t
-mono_runtime_syscall_fork ()
-{
-#ifdef HAVE_FORK
- return (pid_t) fork ();
-#else
- g_assert_not_reached ();
-#endif
-}
-
-void
-mono_gdb_render_native_backtraces (pid_t crashed_pid)
-{
-#ifdef HAVE_EXECV
- const char *argv [6];
- char template [] = "/tmp/mono-gdb-commands.XXXXXX";
- FILE *commands;
- gboolean using_lldb = FALSE;
-
- using_lldb = TRUE;
-
- argv [0] = g_find_program_in_path ("gdb");
- if (argv [0])
- using_lldb = FALSE;
-
- if (using_lldb)
- argv [0] = g_find_program_in_path ("lldb");
-
- if (argv [0] == NULL)
- return;
-
- if (mkstemp (template) == -1)
- return;
-
- commands = fopen (template, "w");
- if (using_lldb) {
- fprintf (commands, "process attach --pid %ld\n", (long) crashed_pid);
- fprintf (commands, "thread list\n");
- fprintf (commands, "thread backtrace all\n");
- fprintf (commands, "detach\n");
- fprintf (commands, "quit\n");
- argv [1] = "--source";
- argv [2] = template;
- argv [3] = 0;
-
- } else {
- fprintf (commands, "attach %ld\n", (long) crashed_pid);
- fprintf (commands, "info threads\n");
- fprintf (commands, " t a a info thread\n");
- fprintf (commands, "thread apply all bt\n");
- argv [1] = "-batch";
- argv [2] = "-x";
- argv [3] = template;
- argv [4] = "-nx";
- argv [5] = 0;
- }
- fflush (commands);
- fclose (commands);
-
- fclose (stdin);
-
- execv (argv [0], (char**)argv);
- unlink (template);
-#else
- fprintf (stderr, "mono_gdb_render_native_backtraces not supported on this platform\n");
-#endif // HAVE_EXECV
-}
-
gboolean
mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo *info)
{