![]() |
very simple debugging question (MSVC)
Okay I know this will soud very dumb to most of you, but I need to know how to break into the debugger when a particuliar variable in the program reaches a certain value.
Let's say I have a boolean flag in my bot structure. I want the DLL to break into the debugger as soon as the bot code decides to set it to TRUE. I know this is possible, however I'm clueless how. You have permission to make fun of me. |
Re: very simple debugging question (MSVC)
Ok - I just did a small test...
Go into your debug menu and add a new breakpoint. Go to the data tab. Add in the variable name. ex ( mystruct.member ) Leave the context blank ( or try adding in a function? ) Click condition Make sure "has changed" is selected. When you start in debug mode it should go into the debugger as soon as it has changed. I'm sure there are more options around there to play with. Hope that helps. |
Re: very simple debugging question (MSVC)
Sometimes a debugger is usefull to those who know how and when to use one, and I'm sure that's what PMB is doing in this case.
My advice to anyone who uses a debugger more than once a month is to toss it into the trash can and learn how to program without one. A debugger is like training wheels on a bicycle, and unless you take them off you'll never learn how to ride a bike on only two wheels. A bike without training wheels is way more fun and goes a lot faster. :) |
Re: very simple debugging question (MSVC)
Ok, but what if you have all of your null pointer checks, ect in place but it mysteriously crashes every now and then?
I can see your point but it's hard to not see myself using it. Or, maybe its time I read my debugging c++ book. It might talk about what you've been saying... |
Re: very simple debugging question (MSVC)
thank you ! :)
|
Re: very simple debugging question (MSVC)
Quote:
Quote:
Debuggers are such a handy crutch it can be difficult to imagine life without one. If you can go without a debugger for long enough, you will eventually reach the opposite point of view where you can't imagine using a debugger frequently, except in certain types of difficult situations. It has been my observation that people who make frequent use of a debugger tend to have a frequent occurance of bugs and produce difficult to understand code. The debugger provides the quick fix to these problems, which sustains a level of programming methods that would otherwise be intolerable. If a debugger were no longer available, some of these programming methods would become intolerable, and adjustments would have to be made to compensate, leading to better quality code. |
Re: very simple debugging question (MSVC)
w00t w00t I found my bug !!! :D :D :D
the bots' stuck flag was never set because I was resetting their input buttons BEFORE the sensing part of the AI and not AFTER it (and the stuck check evaluates the past frame's input buttons state...) thank you debugger! :P |
Re: very simple debugging question (MSVC)
how can you debug a bot in MSVC ? I'll set Debug build and then what ? What should I specify as executable and how shoud I set up HL for debugging ? thnx
|
Re: very simple debugging question (MSVC)
like this
right click on project, choose "settings" and then set up the parameters to something similar to this http://racc.bots-united.com/msvc-debug-1.png http://racc.bots-united.com/msvc-debug-2.png http://racc.bots-united.com/msvc-debug-3.png http://racc.bots-united.com/msvc-debug-4.png Then just put breakpoints and stuff wherever you want, and in order to run HLDS inside a debugger, just hit F5 (or click on the "Go" button in MSVC) :) |
Re: very simple debugging question (MSVC)
"If you can go without a debugger for long enough, you will eventually reach the opposite point of view where you can't imagine using a debugger frequently, except in certain types of difficult situations."
A debugger is invaluable for verifying that your code is functioning properly. When you are dealing with simple applications ("Hello, world", etc.) a debugger is hardly necessary. When you are dealing with complex data structures (think something like a BSP tree) or complex algorithms (especially things like compression, encryption, or complex pattern matching), debuggers become an invaluable tool that allows you to examine things in individual steps. It's way to easy to create fencepost errors with loops (having one to few or one too many loops through a block of code) and it's easy to have array index out of range problems when bad pointers will overwrite the wrong stuff in memory (not always causing an access violation which are easy to catch). A debugger is just a tool. Like a compiler, or an editor is just a tool. You can do without any of these, but it makes life a whole lot harder. If you are constantly using MSVC's Edit-and-Continue feature to fix your code, then you are probably a sloppy programmer. If you use the debugger to verify that your loops are all correct, your pointers are always valid and your code is doing exactly what you designed it to do, then you are simply using a tool to make your code more stable and correct. botman |
All times are GMT +2. The time now is 08:43. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.