GDB和LLDB “燕子” 状态的子进程在OS X

问题描述:

设置考虑下面的代码:GDB和LLDB “燕子” 状态的子进程在OS X

#include <stdio.h> 
#include <signal.h> 
#include <unistd.h> 
#include <sys/wait.h> 

int main(int ac, char** av) { 
    int status; 
    pid_t cpid = fork(); 
    if(0 == cpid) { /* Child */ 
     return *(volatile int*) 0; /* exits with signal 11 */ 
    } else { /* Parent */ 
     do { 
      waitpid(cpid, &status, WUNTRACED); 
      if(WIFSIGNALED(status)) { 
       printf("\nChild exited with signal %d\n\n", WTERMSIG(status)); 
       return 0; 
      } 
     } while (!WIFEXITED(status) && !WIFSIGNALED(status)); 
     printf("\nChild exited normally\n\n"); 
    } 
    return 0; 
} 

我从终端运行的应用程序预期的结果:

$ ./Fork4GdbTests.exe 

Child exited with signal 11 

运行App内LLDB(或GDB),奇怪的是,我得到:

$ lldb ./Fork4GdbTests.exe 
(lldb) target create "./Fork4GdbTests.exe" 
Current executable set to './Fork4GdbTests.exe' (x86_64). 
(lldb) r 
Process 46815 launched: './Fork4GdbTests.exe' (x86_64) 

Child exited normally 

Process 46815 exited with status = 0 (0x00000000) 

我的Makefile文件看起来像这样(用于Cygwin的,也可以):

CC = gcc 
CFLAGS = -Wextra -Wall -Werror -Wno-unused-parameter -g 
.PHONY: all clean 
all: Fork4GdbTests.exe 
%.exe: %.o 
    $(CC) $(CFLAGS) $? $(LIBS) -o [email protected] 
clean: 
    rm -f *.o *.exe *.stackdump; 

在Cygwin中,我得到了从命令提示符和调试器中运行的预期结果。对于各种其他信号(如SIGFPE或通过kill()发送给孩子的任何信号)都会发生类似的行为。

这是怎么回事?

这只是一个错误。由于它影响GDB & LLDB它可能是在CoreOS没有调试器(尽管是同一人既没有调试器的马赫特定层,这样也无法保证......)

无论如何,请文件,http://bugreporter.apple.com一个bug报告。