|
From: <sv...@va...> - 2007-11-19 02:01:03
|
Author: sewardj
Date: 2007-11-19 02:01:01 +0000 (Mon, 19 Nov 2007)
New Revision: 7184
Log:
Minor tidyings to the debugger-attach code, as part of a failed
attempt to fix debugger attach on ppc32-linux and ppc64-linux (see
#151908). The fork/ptrace-based mechanism works fine for x86-linux
and amd64-linux but not on ppc. I have no idea what is going on.
It seems like the forked child process (to which we will attach GDB)
does not stop when it does PTRACE_TRACE_ME and so things go downhill
very rapidly after that.
Modified:
trunk/coregrind/m_debugger.c
trunk/coregrind/m_errormgr.c
Modified: trunk/coregrind/m_debugger.c
===================================================================
--- trunk/coregrind/m_debugger.c 2007-11-19 00:58:18 UTC (rev 7183)
+++ trunk/coregrind/m_debugger.c 2007-11-19 02:01:01 UTC (rev 7184)
@@ -170,13 +170,20 @@
void VG_(start_debugger) ( ThreadId tid )
{
# define N_BUF 4096
- Int pid;
+ Int pid, rc;
- if ((pid = VG_(fork)()) == 0) {
- VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL);
- VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
+ pid = VG_(fork)();
+ if (pid == 0) {
+ vki_sigset_t set;
+ /* child */
+ rc = VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL);
+ vg_assert(rc == 0);
+ rc = VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
+ vg_assert(rc == 0);
+
} else if (pid > 0) {
+ /* parent */
Int status;
Int res;
Modified: trunk/coregrind/m_errormgr.c
===================================================================
--- trunk/coregrind/m_errormgr.c 2007-11-19 00:58:18 UTC (rev 7183)
+++ trunk/coregrind/m_errormgr.c 2007-11-19 02:01:01 UTC (rev 7184)
@@ -455,7 +455,7 @@
if (allow_db_attach &&
VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) ))
{
- VG_(printf)("starting debugger\n");
+ if (0) VG_(printf)("starting debugger\n");
VG_(start_debugger)( err->tid );
}
/* Or maybe we want to generate the error's suppression? */
|