indigodarkwolf / box16

A fork of the official X16 emulator, converted to C++20 and with a bunch of features tweaked and added.
MIT License
42 stars 19 forks source link

segfault when loading breakpoint from symbols file or cmdline #73

Closed irmen closed 1 year ago

irmen commented 1 year ago

box16 segfaults in debugger_add_breakpoint when I run it like so $ box16 -sym test.vice-mon-list

if that symbol file contains a break command like this: break $832

The same thing happens when launching with -debug 0900 command line arguments

indigodarkwolf commented 1 year ago

Ah, I see what happened here. These would have worked once upon a time, but when I refactored memory to support memory flags on breakpoints, I needed to know how much memory was being setup, so when a command line or inifile option tries to set a breakpoint, either directly with a -debug option or indirectly with a break statement from a -sym option, the debugging system hasn't been initialized yet.

Noodling over the best fix now. I suppose I could try to make the debugging system more robust against setting breakpoints before its system init call, but it might be best instead to have the options parsing stow all -sym and -break commands until after the debugger gets its system init call. In fact, that latter seems like the right choice.