Thread: Debugging into functions

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    20

    Debugging into functions

    I've just successfully set up my debug enviroment and everything seems to work fine, except that I can't step into functions or set breakpoints inside functions called in another #included file. For example, in file.h, I have function doSomething() declared and defined. In main.cpp I #include "file.h" and set a breakpoint on doSomething(). When it gets bp'ed I try stepping into the function but it just steps over it!! I need to see what's going on with the variables, etc. that are initialized in the function!

    Is there anything I'm doing wrong???

    thanks in advance

    p.s. I'm using Visual Studio 2005 Express
    Last edited by fl00d; 12-07-2007 at 09:45 PM. Reason: add

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Is the function actually being called?

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    20
    yeah, and when I set a breakpoint on it it stops there, i just want to be able to step in it and see what's going on each step.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Are you sure you're doing step into (F11) instead of step over (F10)?

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    20
    yeah positive. Here's a code snippet of my program:
    begin.cpp
    Code:
    #include "defs.h"
    
    int begin()
    {
    doSomething(); //bp set
    } //this calls all of my functions in defs.h
    defs.h
    Code:
    void doSomething();
    ...
    void doSomething()
    {
    ...
    }//declares and defines doSomething
    Now, I can set a breakpoint in begin.cpp AT my function call, but not in defs.h INSIDE my function definition. Also when I reach my function call I cannot step into it with F11.

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Perhaps off topic, but shouldn't you really define the function inside a .cpp file?

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Maybe the compiler is inlining your function for some reason? Make sure all optimization is turned off, debugging is turned on, and move the function definition to a .cpp file instead of a header file, and see if that works.

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    20
    Hey, I reorganized everything, hoping it was a stupid error. Unfortunately it's not, but I'm gonna upload the code if u guys wanna check it out. but now it's really organized and pretty

    http://rapidshare.de/files/37999206/myProg.rar.html because my program is 7 files.

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I've never seen Visual Studio fail to step into a function that was within it' scope (IE: not in a DLL, lib, etc). What service pack do you have? There were some early bugs related to this. I'm not sure if Express qualifies for service packs but I seem to remember there being one available for it. I could be wrong.

    Sometimes when you mix mash DLL's Visual Studio will jump to the wrong function but it's not a Visual Studio problem it's a DLL problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  2. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  3. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  4. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM
  5. Inline functions and inheritance
    By hpy_gilmore8 in forum C++ Programming
    Replies: 3
    Last Post: 01-14-2004, 06:46 PM