mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
792b27afe1
commit
559d9b89e3
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue