Crash when closing the tab while the debugger is running
There is a crash when the user closes the tab while the debugger is running, and the current view in the view frame is NOT the view used to create the debugger controller. The reason is we check whether the debugger is active based on the current binary view in the view frame (https://github.com/Vector35/debugger/blob/7bc455c4f7c0f3e4e1ce9303c6b426afb9da84f7/ui/uinotification.cpp#L127). However, there is a case where the user is viewing a different bv from the file.
Steps to reproduce:
- Open any file
- Launch it in the debugger
- Switch to the Raw view
- Close the tab
- When asked whether to save the file, click no
- Observe there is no dialog box that asks you whether to stop the running target
- Crash
This actually reveals a deeper issue in the design of the debugger, that the debugger controller is associated with a binary view. However, the UINotification actually works at the file level. This issue https://github.com/Vector35/binaryninja/issues/536 is caused by the same reason.
I have considered the option to associate the debugger controller with a file, but it brings several inconveniences. Firstly, it will not be very obvious which binary view to use when adding the matched bv into the debugger. Secondly, in the future, suppose we have an emulator, it would not be very convenient to emulate at a file level -- having a binary view is much easier.