Search code examples
matlablldb

How do you create a LLDB script to ignore SIGSEGV and SIGBUS


I frequently run matlab in lldb to debug some shared libraries and would like to make a lldb script so rather than typing out the following two lines.

process handle --pass true --stop false --notify true SIGSEGV process handle --pass true --stop false --notify true SIGBUS

I could create a file at ~/.lldb/ignore_sigs but im not sure what to put in that file.


Solution

  • The way "process handle" works, you have to have a running process to attach the signal behaviors to; it doesn't adhere to the target. So you will need to do this once you have a process. The easiest way to do that is to set a breakpoint on main in your .lldbinit file, and add the commands to that breakpoint:

    break set -n main -C "process handle..." -C "process handle..."
    

    Breakpoints set in the .lldbinit file get inherited by all lldb debugging sessions. If you only want this to apply to your matlab debugging sessions, you could make a Python command that checks the name of your target executable and only does the process handle if it is matlab, and then runs the process handle commands. You could then call that Python command from the breakpoint as shown above.