Thread: Visual C++ Debugging???

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    167

    Visual C++ Debugging???

    So I have my program running with input from a file:

    ie Project Menu -> Properties -> Debugging -> Command Arguments -> I have:

    Code:
    < inputfile.txt

    The program works fine when I run without debugging. It loads the input from the file just fine...

    Now, when I want to debug, and stop at breakpoints etc, it *IGNORES* that file completely.

    Why? Is there any way to debug WITH command line arguments (input from file)?

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I seem to recall that you might not be able to redirect input when running through the debugger for some reason. Regular command line arguments will work fine. Were you able to search for anybody else with the same problem?

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by Daved View Post
    I seem to recall that you might not be able to redirect input when running through the debugger for some reason. Regular command line arguments will work fine. Were you able to search for anybody else with the same problem?
    Hmm, wow... That sucks. Pretty big feature to lose out on... Unfortunately no, even tried Google.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Which version are you using?

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by Daved View Post
    Which version are you using?
    http://img53.imageshack.us/img53/938...versionzn8.png

    Is that feature not available in my version?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I don't know. This was the first hit when I searched for "redirect input Visual C++ debug":

    http://forums.msdn.microsoft.com/en/...-fe716f94b2cc/

    It seems to indicate there might be a bug, but I don't have time to test it or search further at the moment.

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Ahhhh s h * t

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    There has to be some kind of a workaround?

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    26
    One workaround would be to add something like "for(;;);" to the start of your program, execute it from a command prompt, and then once the program it running, attach your debugger to the running proces and move the execution point to the next statement.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by Mole42 View Post
    One workaround would be to add something like "for(;;" to the start of your program, execute it from a command prompt, and then once the program it running, attach your debugger to the running proces and move the execution point to the next statement.
    Oh wow... Trying this...

    [Edit]: How do you move the execution point to the next statement?
    Last edited by Paul22000; 07-13-2008 at 11:32 AM.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Take the yellow arrow and drag it to the line you want to move to.
    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.

  12. #12
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by Elysia View Post
    Take the yellow arrow and drag it to the line you want to move to.
    Yellow arrow? Is this in a menu or a toolbar?

    [Edit]: Added screenshot so it's easier to point it out:

    http://img297.imageshack.us/img297/839/visualgu1.png
    Last edited by Paul22000; 07-13-2008 at 02:51 PM.

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    First, break the program (press the pause button).
    A yellow arrow will point at the line it's currently at (it's to the left, where you can see the breakpoint).
    Grab it and drag it to the line you want to move to.

    If it pops up some dialog after you do, simply dismiss it with OK.
    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.

  14. #14
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by Elysia View Post
    First, break the program (press the pause button).
    A yellow arrow will point at the line it's currently at (it's to the left, where you can see the breakpoint).
    Grab it and drag it to the line you want to move to.

    If it pops up some dialog after you do, simply dismiss it with OK.
    Wow, you guys on these forums are geniuses, haha!

    Works great!!!

    One issue (with Visual in general I guess), is there a way to get it to not step into the C++ stuff for every cin and cout? (Not my code)

    Code:
    template<class _Traits> inline
    	basic_ostream<char, _Traits>& __CLRCALL_OR_CDECL operator<<(
    		basic_ostream<char, _Traits>& _Ostr,
    		const char *_Val)
    	{	// insert NTBS into char stream //<--- steps in on this line every cin and every cout
    	typedef char _Elem;
    	typedef basic_ostream<_Elem, _Traits> _Myos;
    	ios_base::iostate _State = ios_base::goodbit;
    	streamsize _Count = (streamsize)_Traits::length(_Val);	// may overflow
    	streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count
    		? 0 : _Ostr.width() - _Count;
    	const typename _Myos::sentry _Ok(_Ostr);
    
    etc...
    Also, just curious, how does Visual C++ know that the process I am attaching to is the exact same as the one I have open when I click debug?

    Man this is awesome!!!! Thanks guys!!!

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    For the quick first question: use step over (F10 with the VS6 scheme).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM