Debugging cpp library called from python/pytorch script

Hi, I have this c++ function called by a python script. I used ipdb to debug the python code but I have not been able to debug the c++ code in a similar manner. I would like to check the values of the variables in the c++ function. I read about the gdb but I can’t seem to make the code break execution in the c++ function. Can someone please guide me on how to do this? below is the c++ function and it’s located in a different folder from the python script.

template <typename T, Int Dimension>                                                                                                                                                                      
  double cuda_Convolution_updateOutput(                                                                                                                                                                     
      /*long*/ at::Tensor inputSize, /*long*/ at::Tensor outputSize,                                                                                                                                        
      /*long*/ at::Tensor filterSize,                                                                                                                                                                       
      /*long*/ at::Tensor filterStride, Metadata<Dimension> &m,                                                                                                                                             
      /*cuda float*/ at::Tensor input_features,                                                                                                                                                             
      /*cuda float*/ at::Tensor output_features, /*cuda float*/ at::Tensor weight,                                                                                                                          
      /*cuda float*/ at::Tensor bias) {                                                                                                                                                                     
                                                                                                                                                                                                            
    auto _rules =                                                                                                                                                                                           
      ¦ m.getRuleBook(inputSize, outputSize, filterSize, filterStride, true);                                                                                                                               
    Int nActiveOut = m.getNActive(outputSize);                                                                                                                                                                                                                                                                                                                                                 
    if (nActiveOut) {                                                                                                                                                                                       
      Int ip = weight.size(1);                                                                                                                                                                              
      Int op = weight.size(2);                                                                                                                                                                              
      output_features.resize_({nActiveOut, op});                                                                                                                                                            
      auto iF = input_features.data<T>();                                                                                                                                                                   
      auto oF = output_features.data<T>();                                                                                                                                                                  
      auto w = weight.data<T>();                                                                                                                                                                            
                                                                                                                                                                                                            
      if (bias.numel())                                                                                                                                                                                     
      ¦ Convolution_fp_bias(oF, bias.data<T>(), op, nActiveOut);                                                                                                                                            
      else                                                                                                                                                                                                  
      ¦ output_features.zero_();                                                                                                                                                                            
                                                                                                                                                                                                            
      return dConvolution_forward2<T>(iF, oF, w, _rules, ip, ip, op, op);

I use std::cerr << to print for debugging. You cannot break inside with cpp with ipdb but you can use gdb to debug python, make sure to build with debug symbols then you can break in the .so file.
It is a little too involved, so std::cerr is much easier.