PDA

View Full Version : Debuggers, how to use?



DarkViper
01-04-2003, 01:33 PM
i dont understand debuggers. i have no clue how to use them to my advantage. i cna set breakpoints, thats the easy part, but then, whenever i press "debug" nothing happens. it recompiles the program, or in flash, it does nothing, as the breakpoints are in certain frame of actionscript.

but, i have Bloodshed Dev-C++ and i would like to know how to use the debugger, as it might actually help me! (besides recompiling it everytime to notice nothing has really changed!)

i dont have MSVC++, and i dont ever really plan on getting it, the resource editor is top notch, but i dont like the complexity of it (its really not beginner-friendly) so dont tell me how to debug using MSVC++. Bloodshed Dev-C++ is what i gots.

adrianxw
01-04-2003, 02:33 PM
All professionals use a debugger, I hope you can find something on Bloodshed. As you know, I've worked with you on the Windows board, and an elemental use of the debugger would have helped you a lot. I can't help you with this, I use VC.

RoD
01-04-2003, 02:43 PM
I am beginning to develop a large interest in using the VC debugger, i hope to learn soon.

Shadow
01-04-2003, 02:49 PM
i dont have MSVC++, and i dont ever really plan on getting it, the resource editor is top notch, but i dont like the complexity of it (its really not beginner-friendly)I thought it was fine. I still think it's fine. What parts intimidate you? What parts give you trouble?

Maybe someone who is a VC++ fanatic can help you out with it. If you're willing to try, I'm sure someone would love to share it's many tricks with you.

Shadow12345
01-04-2003, 04:49 PM
how do you get it to show exactly where the program ended. My application keeps crashing, I know it's something stupid but I would be able to find it if it only told me where exactly the app ended.

Stoned_Coder
01-04-2003, 07:35 PM
step thru it line by line. Most debuggers will offer that facility.

Shiro
01-05-2003, 04:13 AM
>i dont have MSVC++, and i dont ever really plan on getting it

It has a great debugger.

I'm working on embedded software projects, I'd like to use a debugger, but I can't. Therefore I have to put a lot of diagnostic functionality in the code, like printf's and it works fine with me. :)

adrianxw
01-05-2003, 11:38 AM
>>> I'm working on embedded software projects, I'd like to use a debugger, but I can't.

If your embedded target is running Windows CE, you can connect to the target using Platform Builder, and run the application in the target through the Embedded VC++ debugger, takes a bit of fiddling to get it working, but once it is, it is just like debugging a local application.

I have also seen this done with the Phar-Lap kernel, but they had to jump through some more serious hoops to get it to go, it is, however, possible.

My old workgroup is currently developing for VMS, and have had some success in debugging that with VC, although in that case, I think the printf() route would probably have been easier.

minesweeper
01-05-2003, 01:40 PM
Whilst on this topic, I am writing a multithreaded, WIN32 application using MSVC++. I have a bug that only occurs quite infrequently and I think it may be a small problem in my thread synchronisation. Is there any way with the MSVC++ debugger that I can view the operation of each thread simultaneously? Would Spy++ help me? I've never really looked at Spy++ but I seem to remember someone on here saying it was useful for WIN32 application debugging. Thanks in advance.

RoD
01-05-2003, 01:43 PM
not to stray OT but i wanna ask since u brought it up, what is multithreading? and why are so many people confused by it?

minesweeper
01-05-2003, 01:51 PM
The way I think of it is that it is like running multiple chunks of code, lets say two functions for arguments sake, simultaneously. Obviously they don't actually run simulataneously because a microprocessor can only only do one thing at a time. Windows allocates microprocessor time 'slices' to each thread that you are running so that all your threads, or chunks of code, appear to be running concurrently.

RoD
01-05-2003, 01:56 PM
kinda like when a function calls another function? its stepping from one function to the next instead of just main? Sorry if i am misunderstanding.

minesweeper
01-05-2003, 02:02 PM
No. Say the first line of your main function calls function 'A', the program would execute 'A', return from it and then move to the next line, where for our purposes we have function 'B'. So function 'B' wouldn't get a look in till 'A' had finished and returned. now lets make 'A' and 'B' threads. As soon as main has called 'A', 'A' begins executing, but at the same time as our main function is executing. So main goes straight to the next line and calls 'B', which also starts executing. So now we have 3 chunks of code running at the same time, 'A', 'B' and the main function.

RoD
01-05-2003, 05:17 PM
ok that makes sense, would it not be less effiecent or prone to problems tho?

minesweeper
01-05-2003, 05:26 PM
Well yeah I guess it might be less efficient in that every time windows allocates processor time to a new thread there is some extra processing involved in doing so. And it can also be quite problematic, you really need to thoroughly test your program, especially if numerous threads work with the same data. One thread might be reading an array whilst another writes to it and that sort of thing. However for some applications, and there are probably only a few, it can be a necessity.

RoD
01-05-2003, 05:28 PM
Hmm thanks for the basic information, maybe i'll research it someday, right now i'm getting ready to really buckle down into opengl programming.

Shiro
01-06-2003, 01:40 PM
If your embedded target is running Windows CE, you can connect to the target using Platform Builder, and run the application in the target through the Embedded VC++ debugger, takes a bit of fiddling to get it working, but once it is, it is just like debugging a local application.


I've seen Windows CE in action and it looks quite good, but we're using OS9000 and having to deal with a device consisting of a number of subdevices which each have their own processor. We're using an I2C tracer and terminal to do debugging in some way, but unfortenately we can't do things like single stepping and that sort of usefull things.



One thread might be reading an array whilst another writes to it and that sort of thing.


Such can usually be solved using semaphores, but also semaphores can lead to problems if they're not applied correctly. An even more harder to debug problem with multithreading is timing.

DarkViper
01-06-2003, 02:47 PM
ok, we are totallyoff-topic here.

i cant use MSVC++, as much as i want to, i cant, my comp is too slow and too small
heres my comp stats:
Speed: 200mgz
Space: 2GB
Space left: 400MB

and thats it. i cant have MSVC++ on there becuase it takes like, 400MB.

once i get winXP with my new comp, ill get it ASAP, but i still think BSDC++ is still an awsome beginners compiler.

there are a few things that bug me with MSVC++, the fact that when i compile a project, it gives me the total errors, and doesn;t tell me what lines or problems it has come up with. (maybe it does but i cant find it) and BSDC++ does, immediatly.

as for a debugger, i still have no clue how to use it, how many people here have BSDC++?

minesweeper
01-06-2003, 03:02 PM
>>there are a few things that bug me with MSVC++, the fact that when i compile a project, it gives me the total errors, and doesn;t tell me what lines or problems it has come up with.<<

You sure? Mine does :)

RoD
01-06-2003, 03:03 PM
enlarge your error window or scroll up in it, the errors are listed you just don't see them cuz the window is too small and u see the end of the compile attempt.

Double click an error and it takes u right to it.

DarkViper
01-06-2003, 10:59 PM
same thing with bloodshed, except it actually shows you without attempting to hide it then.

anyway, this still doesn;t help me with any debuggers!

Waldo2k2
01-07-2003, 10:43 PM
ok, if you want to use a debugger and get the most out of it you need to learn assembly. Otherwise it's pretty much pointless, even if you were able to use msvc. That's about all the advice I can give you, other than learning what some of the error codes mean (pBlock->inUse usually means you deleted something without using new :)) Good luck.

DarkViper
01-07-2003, 11:36 PM
why would i need to learn another language...just to use a debugger! thats plain retarded!

novacain
01-08-2003, 12:02 AM
>>ok, if you want to use a debugger and get the most out of it you need to learn assembly. Otherwise it's pretty much pointless, even if you were able to use msvc

No its not.


You can still watch the contents of variables, how if / switch statements ect are executing or where values are changing. You can use conditional break points, the call stack and a whole range of other tools.
I use it every time I have a bug.

Sounds like you just don't know how to use one Waldo2k2.

Else use MessageBox'es and GetLastError() to tell you when things go wrong.



if(!Win32_Function_Returns_Success())
{
iError=GetLastError();
sprintf(sBuffer," Win32_Function_Returns_Success in One_Of_My_Functions failed with error#%d.",iError);
MessageBox(hWnd,sBuffer, "App Error",MB_ICONERROR);
return FALSE;
}


To learn, just put a break point at the begining of your app and then use the 'step' (F10 in MSVC) to move on one line at a time.

Nick
01-08-2003, 12:14 AM
http://www.gnu.org/manual/gdb-4.17/gdb.html
You can also get information when inside gdb by help.
Useful commands are step, break, up, print, next, list.