Gdb can't step into function

Discussion in 'Mac Programming' started by kefex, Sep 26, 2012.

  1. kefex, Sep 26, 2012
    Last edited by a moderator: Sep 26, 2012

    kefex macrumors newbie

    Joined:
    Sep 26, 2012
    #1
    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
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. ghellquist macrumors regular

    Joined:
    Aug 21, 2011
    Location:
    Stockholm Sweden
    #3
    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
     
  4. kefex thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #4
    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.

    ----------

    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
     
  5. cqexbesd macrumors regular

    Joined:
    Jun 4, 2009
    #5
    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...
     

Share This Page