debugging - step into issue

This is a discussion on debugging - step into issue within the C++ Programming forums, part of the General Programming Boards category; hi...i'm using msvs 2008. in the past, using msvs6, i've stepped through with F10 and F11. i'm new to msvs ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    84

    debugging - step into issue

    hi...i'm using msvs 2008. in the past, using msvs6, i've stepped through with F10 and F11. i'm new to msvs 2008 and i came across and issue. i can step line by line but it goes way too deep when i step into a function.

    can anyone please test this for me?

    Code:
    void create_list(string filelist)     // when you step into this, it brings up some very low-level code
    void create_list(string &filelist)    // steps as it should


    Code:
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    void create_list(string filelist);
    
    void main ()
    {
    string filelist = "filelist";
    
    	create_list(filelist);
    }
    
    void create_list(string filelist)
    {
    string command = "dir /d c:\\ > ";
    	command = command + filelist;
    	system(command.c_str());
    }
    thanks...bg742

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,823
    Obviously that's because it calls the string copy constructor.
    Just step out of it (Shift+F11).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    84
    it wasn't like that in vs6. any keystroke i can hit so i don't have to go in deep and pull out with shift + F11?

    thanks for your fast reply.

    bg742

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, sometimes you have to "work at it" to step into the function you actually want to step into. If you know where you are going to end up (that is, it's not a function pointer/method call) it is often easier to jump to the beginning of that function and set a breakpoint.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,823
    You can jump over such things with F10. Just don't do it when calling your functions as it will step over them, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by barneygumble742 View Post
    it wasn't like that in vs6. any keystroke i can hit so i don't have to go in deep and pull out with shift + F11?

    thanks for your fast reply.

    bg742
    I do not have such behavior with your code. So it maybe a result of the STL library installed or some settings in your environmet


    As aSide note - you probably should read the FAQ about void main
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,252
    Quote Originally Posted by barneygumble742 View Post
    it wasn't like that in vs6.
    There are a few reasons why that was.

    1. VS6 had a broken debugger.
    2. VS6's STL library sucked like a vacuum.

    Basically, what you're seeing now it what you always should have seen. Imagine trying to step into a call like this:

    Code:
    int x = foo(a.getValue(), b.getValue());
    You might be trying to step in to the foo() function, but if you hit F11 you go into getValue() twice before you get there. Either set a manual breakpoint at foo(), or just hit Shift-F11 to get out of the function you are not interested in, then hit F11 again.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by brewbuck View Post
    You might be trying to step in to the foo() function, but if you hit F11 you go into getValue() twice before you get there. Either set a manual breakpoint at foo(), or just hit Shift-F11 to get out of the function you are not interested in, then hit F11 again.
    And if foo takes a different type to what getValue returns, then you'll step into two constructor calls as well.
    It's not uncommon to step into and out of say 8 things before getting to the one you meant. Just put a breakpoint in the function you're stepping into for cases like that.

    It is another good reason to pass objects by reference (const when appropriate) rather than by value, as you've no doubt already noticed.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging issue
    By JamesKidder in forum C++ Programming
    Replies: 11
    Last Post: 11-03-2008, 10:14 PM
  2. Double-Checked Locking pattern issue
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2008, 03:29 AM
  3. recursion
    By paulmedic555 in forum C Programming
    Replies: 26
    Last Post: 01-27-2005, 11:43 PM
  4. robot step sizes
    By n00by in forum C Programming
    Replies: 2
    Last Post: 04-29-2004, 03:29 PM
  5. this sites Compiler Resources Specs.
    By Powerfull Army in forum C++ Programming
    Replies: 9
    Last Post: 07-08-2002, 06:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21