debugging templates with GDB

if your problem is just about placing breakpoint in your code. Here is a little snippet

ex: main.cpp

#include <iostream>

template <typename T>
void coin(T v)
{
    std::cout << v << std::endl;
}

template<typename T>
class Foo
{
public:

    T bar(T c)
    {
        return c * 2;
    }
};

int main(int argc, char** argv)
{
    Foo<int> f;
    coin(f.bar(21));
}

compile with g++ -O0 -g main.cpp

gdb ./a.out
(gdb) b Foo<int>::bar(int)
Breakpoint 2 at 0x804871d: file main.cpp, line 16.
(gdb) b void coin<int>(int)
Breakpoint 1 at 0x804872a: file main.cpp, line 6.
(gdb) r
... debugging start

otherwise you could just use

(gdb) b main.cpp:16