.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
very simple debugging question (MSVC)
Old
  (#1)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default very simple debugging question (MSVC) - 26-01-2004

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.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#2)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: very simple debugging question (MSVC) - 26-01-2004

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.
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#3)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: very simple debugging question (MSVC) - 26-01-2004

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.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#4)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: very simple debugging question (MSVC) - 26-01-2004

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...
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: very simple debugging question (MSVC) - 26-01-2004

thank you !



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#6)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: very simple debugging question (MSVC) - 26-01-2004

Quote:
Originally Posted by Lazy
Ok, but what if you have all of your null pointer checks, ect in place but it mysteriously crashes every now and then?
That's when you dust off the old debugger you have not needed for at least a month and find out what has gone wrong.

Quote:
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...
A debugger can be a handy tool to have available when needed, I'm not totally mad ... at least I don't think I am

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.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut

Last edited by botmeister; 26-01-2004 at 08:05..
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: very simple debugging question (MSVC) - 26-01-2004

I found my bug !!!

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!



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#8)
koraX
Member
 
koraX's Avatar
 
Status: Offline
Posts: 145
Join Date: Jan 2004
Location: Slovak Republic
Default Re: very simple debugging question (MSVC) - 26-01-2004

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


kXBot
koraX's utils
- see my homepage for other projects (OpenGL CSG Editor, FAT16 Sim, NNetwork Sim, ...)
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#9)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: very simple debugging question (MSVC) - 26-01-2004

like this

right click on project, choose "settings" and then set up the parameters to something similar to this




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)



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: very simple debugging question (MSVC)
Old
  (#10)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: very simple debugging question (MSVC) - 26-01-2004

"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
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com