   Debugging C++
  Hi, I have made a rather big project, it is a fps game. It has worked well while I have been developing it but now a lot of strange bugs have started to show up. I have no idea of why, it doesn't have anything to do with the thing I added last. I think have have done something rather serious like writing to a pointer that doesn't point to the right place and that this problem maybe worked fine previosly but it becomes a problem now because.So my question is if there is any "easy" way of finding out what the reason to the problem is. I do not want to look through every line of code because there is quite much code. There is no point in commenting out parts because the problem might dissapear even though the reason for it still exists.I am using microsoft visual studio 2003   
  A bug is usually some part of the code which behaves in an unexpected way. Since you notice those bugs, then you know that what happens is different from what should happen—and you can thus trace this back to the code which is responsible for making those things happen.   ;  Hi, the bug isn't some particular thing that doesn't work, everything becomes different, it is impossile to walk, all ennemies dissapear things become black and then the program crash or freeze. And eventhough some particular thing wouldn't work isn't it possible that the error is somewhere else in te code?I am wondering if there are any good debugging programs or anything like that?   ;  Have you tried using the debugger that comes with Visual Studio. Here  is an article to help you out.   ;  By finding the exception error causing the crash, you will have a better idea at what you are looking for.The Win32 API provides methods of catching system exception errors when your program crashes. (Look up SetUnhandledExceptionFilter() )You can also just get the exception error code from the "Program must close" dialog box when your game crashes. (If it is full screen, just alt+tab to it)Visual C++ comes with a very good debugger.   ;  Hi, i have tried the visual debugger a little. I can see some different variable in the lower left corner of the screen and the value of them, a variable's value is sometimes red what does it mean? The debugger just shows me "disassembly" when the error occurs, how can i know where the error in my code is?   ;Required reading.   ;  Nice reading. I tried debugging a bit when visual studio crashed because of an acces violoation something. So i pressed the debug button and debugged the debugger :-)   ;  If you find yourself in the assembly code in visual studio, do a stack trace. It should show you the functions that were called, which will help you track down where the code went wrong. Also throw in break points for certain functions which you want to check.( maybe throw some breakpoints down where the new code is.) Then while the game is running, it will break on the break point and then you can use f10(i think, haven't done this for a while) to go line by line and f11 to step into all the function calls.   ;Quote:Original post by glPetter3fHi, the bug isn't some particular thing that doesn't work, everything becomes different, it is impossile to walk, all ennemies dissapear things become black and then the program crash or freeze. And eventhough some particular thing wouldn't work isn't it possible that the error is somewhere else in te code?I am wondering if there are any good debugging programs or anything like that?You're using visual studio 2003, that is a great tool for figuring out what is going on. When this happens, place a break point in an area you are familiar that is not working properly. For example if you are unable to walk, place a breakpoint in the part of code that makes your character walk. Investigate the state of things, you might not find the source of the problem immediately however you should be able to narrow down the list of possibilities. I'm assuming you are using version control? Since the game was running just fine for a while, you try binary searching for you change list in which the problem started. Check in what you have, and sync to an earlier version of your game. Test it, see if it happens and keep going until you find the problematic version. Then diff the changes and maybe you'll be able to eyeball the problem.