check for sys/ptrace.h and only use ptrace() in e_start_main.c if it's present

ticket #1757 (3/3)


SVN revision: 79139
This commit is contained in:
Mike Blumenkrantz 2012-11-12 09:23:39 +00:00
parent 15b668e01a
commit 4ae43fb422
2 changed files with 19 additions and 10 deletions

View File

@ -76,7 +76,7 @@ AC_CHECK_FUNCS(unsetenv)
efl_version="1.7.0"
AC_CHECK_HEADERS([sys/timerfd.h])
AC_CHECK_HEADERS([sys/timerfd.h sys/ptrace.h])
dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))

View File

@ -8,7 +8,9 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/ptrace.h>
#ifdef HAVE_SYS_PTRACE_H
# include <sys/ptrace.h>
#endif
#include <limits.h>
#include <fcntl.h>
#ifdef HAVE_ALLOCA_H
@ -414,9 +416,10 @@ main(int argc, char **argv)
return -1;
else if (child == 0)
{
#ifdef HAVE_SYS_PTRACE_H
/* in the child */
ptrace(PT_TRACE_ME, 0, NULL, NULL);
#endif
execv(args[0], args);
return 0; /* We failed, 0 mean normal exit from E with no restart or crash so let exit */
}
@ -426,17 +429,17 @@ main(int argc, char **argv)
pid_t result;
int status;
Eina_Bool done = EINA_FALSE;
#ifdef HAVE_SYS_PTRACE_H
ptrace(PT_ATTACH, child, NULL, NULL);
#endif
result = waitpid(child, &status, 0);
#ifdef HAVE_SYS_PTRACE_H
if (!stop_ptrace)
{
if (WIFSTOPPED(status))
ptrace(PT_CONTINUE, child, NULL, NULL);
}
#endif
while (!done)
{
Eina_Bool remember_sigill = EINA_FALSE;
@ -451,10 +454,12 @@ main(int argc, char **argv)
char buffer[4096];
char *backtrace_str = NULL;
siginfo_t sig;
int r;
int r = 0;
int back;
#ifdef HAVE_SYS_PTRACE_H
r = ptrace(PTRACE_GETSIGINFO, child, NULL, &sig);
#endif
back = r == 0 &&
sig.si_signo != SIGTRAP ? sig.si_signo : 0;
@ -478,13 +483,15 @@ main(int argc, char **argv)
sig.si_signo != SIGBUS &&
sig.si_signo != SIGABRT))
{
#ifdef HAVE_SYS_PTRACE_H
ptrace(PT_CONTINUE, child, NULL, back);
#endif
continue ;
}
#ifdef HAVE_SYS_PTRACE_H
/* E17 should be in pause, we can detach */
ptrace(PT_DETACH, child, NULL, back);
#endif
/* And call gdb if available */
if (home)
{
@ -545,7 +552,9 @@ main(int argc, char **argv)
{
kill(child, SIGSTOP);
usleep(200000);
#ifdef HAVE_SYS_PTRACE_H
ptrace(PT_DETACH, child, NULL, NULL);
#endif
}
}
}