When providing stack trace for a crash make sure we attach to the crashed process...
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Mon, 17 Oct 2011 23:46:34 +0000 (01:46 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Mon, 24 Oct 2011 20:37:41 +0000 (22:37 +0200)
mono/mini/mini-darwin.c
mono/mini/mini-exceptions.c
mono/mini/mini-posix.c
mono/mini/mini.h

index 54e9735eeb1b009f5f58b61b6dfc6cae083618e4..1fafa1f7aab5edfe4faea0b8a20e38d3e2bd75e2 100644 (file)
@@ -228,7 +228,7 @@ mono_runtime_syscall_fork ()
 }
 
 gboolean
-mono_gdb_render_native_backtraces ()
+mono_gdb_render_native_backtraces (pid_t crashed_pid)
 {
        const char *argv [5];
        char gdb_template [] = "/tmp/mono-gdb-commands.XXXXXX";
@@ -241,7 +241,7 @@ mono_gdb_render_native_backtraces ()
        if (mkstemp (gdb_template) != -1) {
                FILE *gdb_commands = fopen (gdb_template, "w");
 
-               fprintf (gdb_commands, "attach %ld\n", (long) getpid ());
+               fprintf (gdb_commands, "attach %ld\n", (long) crashed_pid);
                fprintf (gdb_commands, "info threads\n");
                fprintf (gdb_commands, "thread apply all bt\n");
 
index 7924b0a75e39f60791c64e83d610766a6eb2393f..8e8486a9c18ec72c8933706f02e942bb6a95f1fb 100644 (file)
@@ -2223,6 +2223,7 @@ mono_handle_native_sigsegv (int signal, void *ctx)
                pid_t pid;
                int status;
                char buffer [1024];
+               pid_t crashed_pid = getpid ();
 
                res = pipe (stdout_pipe);
                g_assert (res != -1);
@@ -2241,7 +2242,7 @@ mono_handle_native_sigsegv (int signal, void *ctx)
                        for (i = getdtablesize () - 1; i >= 3; i--)
                                close (i);
 
-                       if (!mono_gdb_render_native_backtraces ())
+                       if (!mono_gdb_render_native_backtraces (crashed_pid))
                                close (STDOUT_FILENO);
 
                        exit (1);
index 674117f311c63231bacfdd6487b1e32285614ff8..79e521325d1e4568ad57688eced1c47d0a47cb0a 100644 (file)
@@ -652,7 +652,7 @@ mono_runtime_syscall_fork ()
 }
 
 gboolean
-mono_gdb_render_native_backtraces ()
+mono_gdb_render_native_backtraces (pid_t crashed_pid)
 {
        const char *argv [9];
        char buf1 [128];
@@ -663,7 +663,7 @@ mono_gdb_render_native_backtraces ()
        }
 
        argv [1] = "-ex";
-       sprintf (buf1, "attach %ld", (long)getpid ());
+       sprintf (buf1, "attach %ld", (long) crashed_pid);
        argv [2] = buf1;
        argv [3] = "--ex";
        argv [4] = "info threads";
index 6ca9e7df1506e02b3d14044860c37424d1c1cc9b..42f525d2874f0c90928d512af630467c5984c396 100644 (file)
@@ -2442,7 +2442,7 @@ void mono_runtime_setup_stat_profiler (void) MONO_INTERNAL;
 void mono_runtime_shutdown_stat_profiler (void) MONO_INTERNAL;
 void mono_runtime_posix_install_handlers (void) MONO_INTERNAL;
 pid_t mono_runtime_syscall_fork (void) MONO_INTERNAL;
-gboolean mono_gdb_render_native_backtraces (void) MONO_INTERNAL;
+gboolean mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
 
 /*
  * Signal handling