问题
The problem
I get a segmentation error when using numba to run some simulations (Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)).
I am trying to follow the instructions on the numba docs (https://numba.pydata.org/numba-doc/dev/user/troubleshoot.html#example-debug-usage) but I cannot install GDB on my MacOS.
GDB on MacOS
I have followed the instructions on this site to install GDB on MacOS https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/, however when executing
$ gdb python
on the terminal, I get the following warning which prevents me from being able to debug the code:
warning: `/tmp/lto.o': can't open to read symbols: No such file or directory.
(No debugging symbols found in python)
lldb and Numba
The other option I have tried is to debug Numba using lldb, however it does not seem to work.
Therefore, my question is: how can debug Numba on a MacOS?
回答1:
The way macOS handles debug information is a little different from other systems. On most Unix systems, the compiler emits debug information into a .o file. Then the linker copies the debug information into the final executable. Then the debugger reads the debug info from the executable. Since debug info is generally pretty big that's a lot of copying... So on macOS we leave the debug info in the .o file, and instead the linker writes a "debug map" into the executable. It's the debugger's job to find the .o files & use the debug map to link up the debug info.
It sounds like the build process you are using it using "lto" (Link Time Optimization) which takes all the .o files and builds a single .o file, which is then linked. That is great for optimization purposes because you can now inline functions across compile unit boundaries and other neat tricks like that.
But that temporary lto output file needs to be preserved for debugging to work. And it looks like that is not happening in your build process.
There's another step to debug information on macOS. If you want to store debug info longer term, it would be annoying to have to keep all the .o files around, so there's a tool (dsymutil) that copies the debug info from the .o files into a ".dSYM" bundle. You might see if your build process says anything about dSYM's, that might be how it preserves the debug info from the build?
来源:https://stackoverflow.com/questions/59412358/debugging-numba-in-macos