Question with GDB usage

I want to study the source code and try to make some breakpoints at both Python code and cpp code by following gdb-integration.

The output is not consistent with the gdb-integration. It seems not to hit the breakpoint. Am I missing something or the tutorial is out of date?


$ gdb python
GNU gdb (GDB) 11.2

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...
(gdb) break at::Tensor::neg
Function "at::Tensor::neg" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (at::Tensor::neg) pending.
(gdb) run
Starting program: /xx/xx/.conda/envs/torch_x/bin/python 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/".
Python 3.8.1 (default, ...) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
[Detaching after fork from child process 152651]
>>> a = torch.Tensor([1])
>>> a.neg()

Should I install torch with some special flags?

I installed it with CPU only from source code.

USE_CUDA=0 python develop

Hi @ptrblck, I noticed you have answered a related question. Is it possible for you to take a look? :slight_smile:

Ohh, I found the root cause, I did build the torch with DEBUG mode.
Although I build it with DEBUG=1 python install, I already built it with Release mode, torch used the cache CMakeLists.txt.