Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kefex

macrumors newbie
Original poster
Sep 26, 2012
2
0
I've wasted a day and a half on this, finally caving and asking for help. Bafflingly, no one else seems to have the problem, since google searches don't show much.

Here's the deal: I'm able to step into non-template functions, but I can't step into member functions of a template class. gdb steps over the functions rather than into them. The template class is pretty unexciting -- I've just templated on the floating point type. No crazy meta-template programming or nested types to confuse the compiler, very boring stuff.

So this function I can step into no problem:
Code:
void foo()
{
    std::cout << "foo()" << std::endl;
}

But the baz method of an instance of this class doesn't work:

template <typename Float>
struct Bar
{
    Bar(Float val) : val(val) {}

    void baz()
    {
        std::cout << "baz()" << std::endl;
    }

    Float val;
};
I'm using gcc 4.2.1, gdb 7.2

Any thoughts?

Cheers,

Kevin
 
Last edited by a moderator:
If you set a breakpoint inside the function does it get hit? I'm not at all familiar with templates, so I don't know what sort of trickery is involved (it may be fancy for the compiler, but may lead to fairly mundane object code. I reasly don't know). Can you throw a call to a "plain" method inside the call to your template method, set a breakpoint on that method, and see if that is hit?

-Lee
 
If you set a breakpoint inside the function does it get hit? I'm not at all familiar with templates, so I don't know what sort of trickery is involved (it may be fancy for the compiler, but may lead to fairly mundane object code. I reasly don't know). Can you throw a call to a "plain" method inside the call to your template method, set a breakpoint on that method, and see if that is hit?

-Lee

Hi Lee,

No, if I set a breakpoint in the function, it doesn't get hit. It seems that it simply isn't adding any debug information about the function into the binary.

----------

Might an old bug in gcc gdb that has resurfaced. Found quite a few references googling on "gdb step into template mac" from 2002 up to 2005.
// Gunnar

Thanks for that, Gunnar, I'll try googling that phrase. I've been trying to find the exact magical incantation that will cajole google into returning some useful information on the subject, with any luck that's it :)

Kevin
 
You could try building with clang. If it is gcc not adding debug symbols to the function maybe clang will? Just a stab in the dark...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.