Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C GDB使用SIGTRAP信号意外中断_C_Macos_Debugging_Gdb_Sdl - Fatal编程技术网

C GDB使用SIGTRAP信号意外中断

C GDB使用SIGTRAP信号意外中断,c,macos,debugging,gdb,sdl,C,Macos,Debugging,Gdb,Sdl,当我从调试器收到此错误时,我正在使用C创建8080仿真器: Starting program: /Users/khalid/prog/8080_emulator/emulator [New Thread 0x1003 of process 35249] [New Thread 0x1303 of process 35249] During startup program terminated with signal SIGTRAP, Trace/breakpoint trap. 我在使用断点

当我从调试器收到此错误时,我正在使用C创建8080仿真器:

Starting program: /Users/khalid/prog/8080_emulator/emulator 
[New Thread 0x1003 of process 35249]
[New Thread 0x1303 of process 35249]
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.
我在使用断点和不使用断点时都会得到这个输出。在崩溃之前,程序将启动四个线程,然后开始运行。我不确定是什么原因导致了这一点,但任何帮助都是非常感谢的

我正在运行macOS High Sierra 10.13.1,我的仿真程序GitHub repo位于以下位置:

这是我的gdb配置:

configure --host=x86_64-apple-darwin17.3.0 --target=x86_64-apple-darwin17.3.0
         --with-auto-load-dir=:${prefix}/share/auto-load
         --with-auto-load-safe-path=:${prefix}/share/auto-load
         --with-expat
         --with-gdb-datadir=/usr/local/Cellar/gdb/8.1/share/gdb (relocatable)
         --with-jit-reader-dir=/usr/local/Cellar/gdb/8.1/lib/gdb (relocatable)
         --without-libunwind-ia64
         --without-lzma
         --with-python=/System/Library/Frameworks/Python.framework/Versions/2.7
         --without-guile
         --with-separate-debug-dir=/usr/local/Cellar/gdb/8.1/lib/debug (relocatable)
         --without-babeltrace
此外,以下是调试符号:

khalid$ nm emulator
0000000100001020 T _Emulate8080Op
0000000100007640 T _MachineIN
00000001000076f0 T _MachineOUT
0000000100000f20 T _Parity
00000001000080c4 D _SCREEN_HEIGHT
00000001000080c0 D _SCREEN_WIDTH
                 U _SDL_AllocPalette
                 U _SDL_CreateWindow
                 U _SDL_DestroyWindow
                 U _SDL_FreeSurface
                 U _SDL_GetError
                 U _SDL_GetWindowSurface
                 U _SDL_Init
                 U _SDL_Quit
                 U _SDL_UpdateWindowSurface
                 U _SDL_UpperBlit
0000000100000fa0 T _UnimplementedInstruction
                 U ___stack_chk_fail
                 U ___stack_chk_guard
0000000100000000 T __mh_execute_header
0000000100007600 T _closeMedia
                 U _exit
                 U _fopen
                 U _fread
                 U _fseek
                 U _ftell
00000001000080e0 S _gImage
00000001000080d8 S _gScreenSurface
00000001000080d0 S _gWindow
0000000100007760 T _getMicrotime
                 U _gettimeofday
0000000100007470 T _init
00000001000080cb S _int_enable
00000001000075e0 T _loadMedia
0000000100007790 T _main
                 U _malloc
                 U _memset
                 U _printf
                 U _rewind
00000001000080c8 S _shift0
00000001000080c9 S _shift1
00000001000080ca S _shift_offset
00000001000080e8 S _state
                 U dyld_stub_binder
我在其他地方读到,将
strip--strip debug libpthread.so.0
添加到gcc的C标志中会有所帮助,但我已经尝试过了,但没有成功


或者,有没有更好的方法来调试8080仿真器?再次感谢您的帮助

您的模拟器是否使用了
SIGTRAP
本身?事实上,它是否调用过
sigaction
signal
本身?
SIGTRAP
信号是用于调试的API的一部分,因此我怀疑GDB本身存在缺陷,或者您的程序正在执行GDB无法(可能无法)处理的异常操作。模拟器经常要做一些不寻常的事情……不,我的模拟器根本不使用
SIGTRAP
sigaction
。SDL可能做了一些不寻常的事情,因为这是我第一次使用图形库。我对High Sierra也有同样的问题。无法成功地获得任何C或C++应用程序,得到相同的错误。我为gdb创建了证书,对其进行了代码签名,运行了echo命令来创建git文件,如其他建议所示,等等,要降级到gdb 8.0.1,请参阅。的可能重复项