Search code examples
pythonc++templatesgdbbreakpoints

setting GDB breakpoint for C++ class member function written using template


I'm trying to set a breakpoint at a C++ class member function which is defined using template. I've looked for the solution in stackoverflow but couldn't find the same problem. Below is a sample code showing the function definition(from py-faster-rcnn caffe code, Dtype is defined as float outside).

template <typename Dtype>
void SoftmaxWithLossLayer<Dtype>::Forward_gpu(
    const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
  softmax_layer_->Forward(softmax_bottom_vec_, softmax_top_vec_);
  const Dtype* prob_data = prob_.gpu_data();
  const Dtype* label = bottom[1]->gpu_data();

Yesterday, I successfully set the breakpoint using

br SoftmaxWithLossLayer<float>::Forward_gpu( const vector<Blob<float>*>& , const vector<Blob<float>*>& )

But this morning, it doesn't work! What can be the problem? If I use br filename:linenuber, it works.
(BTW, I'm using DDD attached to a process running python including C++ library wrapped by boost but I hope this is irrelevant.)


Solution

  • I have never tried this but have you considered using nm to determine how it is defined within the shared library? You might be able to use that information to help ddd/gdb consistently find the template method.