diff options
author | Rodrigo Kumpera <kumpera@gmail.com> | 2013-06-15 00:49:00 +0400 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2013-06-15 00:49:07 +0400 |
commit | eff2914eaf20737b6043b26d6e30c8eeeb37adad (patch) | |
tree | 37edf36c3576d11a10c484241a61d8adc078bcd6 | |
parent | 8c7397406e3f4bd1be57eb5aadd8f924dd3c0710 (diff) |
Add lldb support to our thread dump capabilities.
-rw-r--r-- | mono/mini/mini-darwin.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/mono/mini/mini-darwin.c b/mono/mini/mini-darwin.c index 5ec06d20a74..cf54ac6ff07 100644 --- a/mono/mini/mini-darwin.c +++ b/mono/mini/mini-darwin.c @@ -246,32 +246,46 @@ void mono_gdb_render_native_backtraces (pid_t crashed_pid) { const char *argv [5]; - char gdb_template [] = "/tmp/mono-gdb-commands.XXXXXX"; + char template [] = "/tmp/mono-gdb-commands.XXXXXX"; + FILE *commands; + gboolean using_lldb = FALSE; argv [0] = g_find_program_in_path ("gdb"); - if (argv [0] == NULL) { - return; + if (!argv [0]) { + argv [0] = g_find_program_in_path ("lldb"); + using_lldb = TRUE; } - if (mkstemp (gdb_template) != -1) { - FILE *gdb_commands = fopen (gdb_template, "w"); - - fprintf (gdb_commands, "attach %ld\n", (long) crashed_pid); - fprintf (gdb_commands, "info threads\n"); - fprintf (gdb_commands, "thread apply all bt\n"); + if (argv [0] == NULL) + return; - fflush (gdb_commands); - fclose (gdb_commands); + if (mkstemp (template) == -1) + return; + commands = fopen (template, "w"); + if (using_lldb) { + fprintf (commands, "process attach --pid %ld\n", (long) crashed_pid); + fprintf (commands, "script lldb.debugger.HandleCommand (\"thread list\")\n"); + fprintf (commands, "script lldb.debugger.HandleCommand (\"thread backtrace all\")\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, "thread apply all bt\n"); argv [1] = "-batch"; argv [2] = "-x"; - argv [3] = gdb_template; + argv [3] = template; argv [4] = 0; - - execv (argv [0], (char**)argv); - - unlink (gdb_template); } + fflush (commands); + fclose (commands); + + execv (argv [0], (char**)argv); + unlink (template); } gboolean |