Thread: Using the Debug mode ((F10) V.S 2005

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

    Using the Debug mode ((F10) V.S 2005

    Hello...

    Been using debug a lot in the past with VS 6.0 C++ (Console Applications)... In VS 2005 (with Windows Apps) i noticed the window doesn't activate while you step into your program... I use watch window so would like to enter input data while debugging... I also tried adding a break point, which i notice doesn't work if i run the program (cntrl+F5), not unless i debug (F5) but then again can't maximize/restore the window in this mode...

    Any ideas on how to debug whilst interacting with the user interface/window?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Since Window applications rely on the WM_PAINT message to redraw, you can not redraw the application when it is also stopped in the debugger [at least unless it's multithreaded - and I'm not suggesting you should multithread your application - it will just make things even harder on you].

    That's just the way debugging in windows [and other windowed environments that draw from within the app] works.

    Console apps are different because the actual console window is owned by a different process than the one running in the console, so the drawing is done by the console management process, not the application itself [the application just updates WHAT should be drawn on the console].

    I don't know if Vista changes this - it has changes in the way that windows are drawn to the display, but I suspect it doesn't change how the debugging works.

    --
    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.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The window needs to respond to several messages sent by windows, or it will be marked as unresponsive, frozen and become white eventually.
    The ONLY way to solve it is have a message loop running.
    What I typically do is spawn a thread for each event handler (such if you click a button) and thus have the message loop constantly in the thread that created the window.
    You can then add, for example, message boxes randomly in your code if you need to see the window. Remember that VS will break ALL threads, so it will break the message loop thread too.
    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.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    The window needs to respond to several messages sent by windows, or it will be marked as unresponsive, frozen and become white eventually.
    The ONLY way to solve it is have a message loop running.
    What I typically do is spawn a thread for each event handler (such if you click a button) and thus have the message loop constantly in the thread that created the window.
    You can then add, for example, message boxes randomly in your code if you need to see the window. Remember that VS will break ALL threads, so it will break the message loop thread too.
    Shoo! sounds like Chinese to me but will get there one day ... "THREADS"!!!!

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    The window needs to respond to several messages sent by windows, or it will be marked as unresponsive, frozen and become white eventually.
    The ONLY way to solve it is have a message loop running.
    What I typically do is spawn a thread for each event handler (such if you click a button) and thus have the message loop constantly in the thread that created the window.
    You can then add, for example, message boxes randomly in your code if you need to see the window. Remember that VS will break ALL threads, so it will break the message loop thread too.
    I need to do this but not sure how, could you perhaps give a simple code example?

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Hmmm. I don't use Win32 api, but...
    Firstly, do you know how to use threads?
    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.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    The solution is to use a multiple monitor system or use remote debugging. However another simpler solution is to run your program non-maximized. You should still be able to switch to each task via the task bar.

    I'm able to debug programs on my dev box as well as my client box (remote) at work with no problems. I'm not sure exactly what your troubles are. Please explain and I may be able to help more.

    The big problems I have at home are I don't have a multi-monitor system and I don't have a client box that is the equiv of my dev box so most of my Direct3D code won't run on the client. However I can run windowed which, while annoying at times, still does the trick.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    Hmmm. I don't use Win32 api, but...
    Firstly, do you know how to use threads?
    Up to a degree but yes i do...

    Code:
    WM_CREATE:
        _beginthread(MyThreadFunc,0,NULL);
    
    ..................    
    
    VOID MyThreadFunc(PVOID pvoid)
    {
    
         while(TRUE)
          {
           // thread code
          }
     
    }
    what should go in thread code?

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Bubba View Post
    The solution is to use a multiple monitor system or use remote debugging. However another simpler solution is to run your program non-maximized. You should still be able to switch to each task via the task bar.

    I'm able to debug programs on my dev box as well as my client box (remote) at work with no problems. I'm not sure exactly what your troubles are. Please explain and I may be able to help more.

    The big problems I have at home are I don't have a multi-monitor system and I don't have a client box that is the equiv of my dev box so most of my Direct3D code won't run on the client. However I can run windowed which, while annoying at times, still does the trick.
    Are you using Visual Studio 2003/2005/2008? cause apparently non of those allow to debug in this manner!

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by csonx_p View Post
    Are you using Visual Studio 2003/2005/2008? cause apparently non of those allow to debug in this manner!
    That's not true.
    Whatever problem you're having it's not to do with the IDE or compiler, because the only bit of debugging functionality that was removed in the later compilers, that I can see, is the ability to detach from a single process rather than all (moan moan). I have used all those versions - a lot.
    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"

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by iMalc View Post
    That's not true.
    Whatever problem you're having it's not to do with the IDE or compiler, because the only bit of debugging functionality that was removed in the later compilers, that I can see, is the ability to detach from a single process rather than all (moan moan). I have used all those versions - a lot.
    if you read what matsp is saying here, then you guys are confusing me... Oh! sorry, he's not referring to VS, but to windows programming... Perhaps my question to bubba is if he/she was programming windows API or not!

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    But unfortunately, VS breaks all threads and thus also breaks the message loop, so your window appears frozen. This is the source of the problems.
    I don't know if anyone else know/has a workaround for that.
    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.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    CNTRl+F10

    Strange, any new function i add won't be executed (gets skipped) in a debug mode... I pressed F10 continuously to step over and two of my functions are skipped Well, this could be happening even when i run the program...

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    Strange, any new function i add won't be executed (gets skipped) in a debug mode... I pressed F10 continuously to step over and two of my functions are skipped Well, this could be happening even when i run the program...
    Are you sure you don't get a compiler error or some other inconsistency in your building of the application? Try doing a complete rebuild (clean build) of all your code. The usual cause for these things is that the code the compiler generated, and the source code that the debugger is showing, are out of sync.

    --
    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.

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You do realize that F10 steps over, right? It will execute the entire function and break afterwards.
    Just making sure that I'm understanding you right.
    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. Debug --> Exceptions in Visual Studio 2005
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-10-2007, 02:12 AM
  2. Why my code works only in debug mode?
    By pingpangpang in forum C++ Programming
    Replies: 3
    Last Post: 06-04-2007, 12:39 PM
  3. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM
  4. Debug Mode Vs. Release Mode
    By incognito in forum Tech Board
    Replies: 5
    Last Post: 12-18-2003, 04:06 PM
  5. 2min in debug mode, 3sec in release!
    By glUser3f in forum C++ Programming
    Replies: 9
    Last Post: 10-03-2003, 01:00 PM