I am creating an 8080 emulator using C when I received this error from my debugger:
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.
I get this output when I do use a breakpoint and when I don't. Before it crashed, the program would start four threads and then begin running. I'm not sure what could have caused this, but any help is appreciated!
I am running macOS High Sierra 10.13.1 and my GitHub repo for the emulator is here: https://github.com/khalludi/8080emulator.
This is my gdb configuration:
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
Also, these are the debug symbols:
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
I read somewhere else that adding strip --strip-debug libpthread.so.0
to the C-flags of gcc would help but I have tried this and it doesn't work.
Or, is there a better way to debug the 8080 emulator? Again, any help is appreciated!