In my experience, starting python under GDB usually causes all kinds of arcane issues. It’s much better to attach GDB to a running python program to avoid that. For example, your issue seems to be that you are setting breakpoints on non-existent address, I’m guessing that you set your breakpoints before tvm related shared libraries are loaded. GDB may or may not fix the symbol address for you.
I would recommend the following extra simple steps:
- Add
input("dummy breakpoint")
after the last import statement(from tvm.contrib import graph_runtime
). So the program will stop after loading all tvm shared libraries.
- In a separate window, find the process id of the python program and attach GDB to the process, set the breakpoints you want and continue the program so GDB won’t pause the python process.
- Go back to python program and type anything just to resume the python program and it will hit your breakpoint!
Just verified the steps with lldb
:
➜ lldb --attach-pid 42981
(lldb) process attach --pid 42981
Process 42981 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007fff5c8eaec2 libsystem_kernel.dylib`__read_nocancel + 10
libsystem_kernel.dylib`__read_nocancel:
(lldb) breakpoint set --name NNGraphCreate
Breakpoint 1: where = libnnvm_compiler.dylib`NNGraphCreate, address = 0x000000011a130c60
(lldb) c
Process 42981 resuming
Process 42981 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000011a130c60 libnnvm_compiler.dylib`NNGraphCreate
libnnvm_compiler.dylib`NNGraphCreate:
-> 0x11a130c60 <+0>: pushq %rbp
0x11a130c61 <+1>: movq %rsp, %rbp
0x11a130c64 <+4>: pushq %r15
0x11a130c66 <+6>: pushq %r14
Target 0: (Python) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000011a130c60 libnnvm_compiler.dylib`NNGraphCreate
frame #1: 0x000000010a50e3ef _ctypes.cpython-37m-darwin.so`ffi_call_unix64 + 79
frame #2: 0x000000010a50eb93 _ctypes.cpython-37m-darwin.so`ffi_call + 703
frame #3: 0x000000010a50a4ab _ctypes.cpython-37m-darwin.so`_ctypes_callproc + 662
frame #4: 0x000000010a504f98 _ctypes.cpython-37m-darwin.so`PyCFuncPtr_call + 520
frame #5: 0x0000000109bbd315 Python`_PyObject_FastCallKeywords + 359
frame #6: 0x0000000109c54173 Python`call_function + 568
frame #7: 0x0000000109c4b305 Python`_PyEval_EvalFrameDefault + 2604
frame #8: 0x0000000109bbd88e Python`function_code_fastcall + 116
frame #9: 0x0000000109c5417a Python`call_function + 575
frame #10: 0x0000000109c4b305 Python`_PyEval_EvalFrameDefault + 2604
frame #11: 0x0000000109c54ad1 Python`_PyEval_EvalCodeWithName + 1837
frame #12: 0x0000000109c4a851 Python`PyEval_EvalCode + 42
frame #13: 0x0000000109c79a5f Python`run_mod + 54
frame #14: 0x0000000109c78a7a Python`PyRun_FileExFlags + 164
frame #15: 0x0000000109c78159 Python`PyRun_SimpleFileExFlags + 283
frame #16: 0x0000000109c8f842 Python`pymain_main + 5114
frame #17: 0x0000000109c8ffd4 Python`_Py_UnixMain + 104
frame #18: 0x00007fff5c79b115 libdyld.dylib`start + 1
frame #19: 0x00007fff5c79b115 libdyld.dylib`start + 1