Thread: debugging in visual studio

  1. #1
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804

    debugging in visual studio

    Halo all,
    I've problem regarding debugging in visual studio. When I debug any code in VS2005 it works fine but it doesn't show me the tracing of the program in any function other than main. If I use any function, call it in main, then the arrow doesn't go to the function but remains in main(). Is there any setting by which I can trace the whole code line by line even in functions other than main() ?
    Thanks
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It should stop wherever you place a breakpoint - F9 sets a breakpoint on the current line. You can set breakpoint properties by selecting the breakpoint and right clicking. You can also set/remove breakpoints by left clicking at the far left of the line. You can view all your breakpoints in the breakpoints window. Use F10 to trace over the current line and F11 to trace into. This depends on your key setup but I believe it is the default when you install VS. You can also add watches by right clicking a variable in the code window and selecting add watch. Visual Studio 2005 + also displays STL containers correctly so you can add watches on them.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I find conditional break points very handy.

    I also use the 'Set Next Statement' and 'Edit and Continue' functionality (to fix bugs, then jump back and re-run code to test fix) all the time.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    You might want to turn the optimizer off.

    Somewhat it eliminates meaningless functions which sometime we need information from them, for instance dissambling.
    Just GET it OFF out my mind!!

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Sounds like you're hitting F10, which means step to the next line. You should be hitting F11 instead, which steps INTO functions instead of over them.

    So if you come to a line of code that contains a function call and you do NOT want to see that function, hit F10. If you DO want to see the function, hit F11.

    Once inside a function, you may decide that you are no longer interested in that function and you want to "pop up" a level. To do that, hit Shift-F11.

    If you want to stop at the beginning of a particular function, hit Ctrl-B and type the function name into the dialog box. Hit Alt-F9 to bring up the breakpoint window and you can easily see all the breakpoints you have set.

    Note that if there is a breakpoint set for a function X(), then hitting F10 will NOT step over the call to X(). It will always break at X() if a breakpoint is set there.

    Other techniques include breakpoints that break only on the Nth time they execute, or every N times. Or, you can make a breakpoint condition on some expression, so it only breaks if that expression is true (non-zero). Even more advanced, you can attach VB scripts to breakpoints to make other things happen in the debugger. For instance, say you have two breakpoints A and B. Suppose that you're only interested in B after A has already been hit. You can disable B, and then attach a script to A which enables B. (Truthfully, it's easier to do stuff like that in gdb but you can do it in Visual Studio as well)
    Last edited by brewbuck; 07-09-2009 at 05:58 PM.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM