Commit 559d9b89 authored by Alex Samorukov's avatar Alex Samorukov Committed by Jehan

Fix empty lldb backtrace on OSX

When lldb attaching to the process it triggers few "-1" errors on read with
EINTR error. After 1-2 errors read() call works again.
Also this patch fixing TID detection, syscall SYS_gettid is oficially deprecated
now and does not work. Also adding safecheck to avoid enldless loop.
parent 792b27af
......@@ -1180,8 +1180,13 @@ gimp_stack_trace_print (const gchar *prog_name,
int out_fd[2];
pid_t fork_pid;
pid_t pid = getpid();
gint eintr_count = 0;
#if defined(G_OS_WIN32)
DWORD tid = GetCurrentThreadId ();
#elif defined(PLATFORM_OSX)
uint64 tid64;
pthread_threadid_np (NULL, &tid64);
long tid = (long)tid64;
#elif defined(SYS_gettid)
long tid = syscall (SYS_gettid);
#elif defined(HAVE_THR_SELF)
......@@ -1275,8 +1280,17 @@ gimp_stack_trace_print (const gchar *prog_name,
*/
close (out_fd[1]);
while ((read_n = read (out_fd[0], buffer, 256)) > 0)
while ((read_n = read (out_fd[0], buffer, 256)) != 0)
{
if (read_n < 0)
{
if (errno == EINTR && eintr_count <= 5)
{
eintr_count++;
continue;
}
break;
}
if (! stack_printed)
{
#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment