You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/11/12 16:13:30 UTC
svn commit: r594174 -
/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp
Author: gshimansky
Date: Mon Nov 12 07:13:29 2007
New Revision: 594174
URL: http://svn.apache.org/viewvc?rev=594174&view=rev
Log:
Applied patch from HARMONY-5101
[drlvm][crash_handler] GDB is started with LWP which belongs to main thread instead of one of crashed thread.
Modified:
harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp?rev=594174&r1=594173&r2=594174&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/crash_handler.cpp Mon Nov 12 07:13:29 2007
@@ -20,7 +20,8 @@
*/
#include <sys/types.h>
-#include <unistd.h>
+#include <linux/unistd.h>
+#include <errno.h>
#include <stdio.h>
#include <semaphore.h>
@@ -33,7 +34,6 @@
#endif
static char g_executable[1024]; // Executable file name
-static char g_strpid[128]; // Current pid as a string
static sem_t g_sem_started; // Prevent forking debugger more than once
static bool g_prepared = false; // Flag is set if gdb crash handler is prepared
static bool g_enabled = false; // vm.crash_handler value is stored here
@@ -56,6 +56,8 @@
return get_boolean_property("vm.crash_handler", FALSE, VM_PROPERTIES);
}
+_syscall0(pid_t, gettid)
+pid_t gettid(void);
bool gdb_crash_handler()
{
@@ -63,15 +65,19 @@
0 != sem_trywait(&g_sem_started)) // gdb was already started
return false;
+ static const int tid_len = 10;
+ char tid[tid_len];
+ snprintf(tid, tid_len, "%d", gettid());
+
if (fork() == 0)
{
fprintf(stderr, "----------------------------------------\n"
"gdb %s %s\n"
"----------------------------------------\n"
- , g_executable, g_strpid);
+ , g_executable, tid);
fflush(stderr);
- execlp("gdb", "gdb", g_executable, g_strpid, NULL);
+ execlp("gdb", "gdb", g_executable, tid, NULL);
perror("Can't run gdb");
}
else
@@ -111,7 +117,6 @@
get_executable_name(g_executable, sizeof(g_executable)) != 0)
return -1;
- snprintf(g_strpid, sizeof(g_strpid), "%d", getpid());
g_prepared = true;
assert(VM_Global_State::loader_env);