Fixes for old glibc (Debian Etch) (#17564)

This commit is contained in:
Anton Kochkov 2020-09-02 06:05:50 +08:00 committed by GitHub
parent c9b6149d7b
commit 43feee7a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -319,6 +319,8 @@ static RDebugReasonType linux_handle_new_task(RDebug *dbg, int tid) {
if (ret == -1) {
continue;
}
#ifdef PT_GETEVENTMSG
// NOTE: This API was added in Linux 2.5.46
if (siginfo.si_signo == SIGTRAP) {
// si_code = (SIGTRAP | PTRACE_EVENT_* << 8)
int pt_evt = siginfo.si_code >> 8;
@ -333,6 +335,7 @@ static RDebugReasonType linux_handle_new_task(RDebug *dbg, int tid) {
break;
}
}
#endif
}
}
return R_DEBUG_REASON_UNKNOWN;

View File

@ -14,6 +14,16 @@
#define PTRACE_SETSIGINFO 0x4203
#endif
// A special case of the older Glibc but the kernel newer than 2.5.46
// Sadly, there is no reliable and portable way to check the linux kernel
// version from headers, so we assume it's supported.
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 3)
#if !defined(PT_GETEVENTMSG) && !defined(PTRACE_GETEVENTMSG)
#define PTRACE_GETEVENTMSG 0x4201
#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
#endif
#endif
#if !defined(PTRACE_EVENT_FORK) && !defined(PTRACE_EVENT_VFORK) && !defined(PTRACE_EVENT_CLONE) \
&& !defined(PTRACE_EVENT_EXEC) && !defined(PTRACE_EVENT_VFORK_DONE) && !defined(PTRACE_EVENT_EXIT)