Learning to debug? No please not yet!
I'm building a game engine from source. Learning an awful lot about it too, and getting my attitude well and truly readjusted along the way - learning alot of respect for people who can program professionally. There is so much to know!
Problem is the code I'm using seems rather dependent on being compiled in Visual. I don't really want this because I want to learn what's going on properly and compile using GCC which I am. I've got most stuff to work up to now and it's been quite a rollercoaster ride to say the least. Very interesting though, but often attacking it hard and fast with unrealistic expectations about progress has left me very frustrated. Guess I really have to learn that it won't happen overnight.
Having said that non-portable code is throwing up enough problems to make me realise how important portable code really is.
Anyways enough of that. Basically in days not too far gone by, I would debug 'manually' so to speak, using the std::cout statements to display strings on the command line to allow me to see where a program had hung up. The idea being, if the string didn't show, it hadn't got that far. That's ok for small projects but no good at all for when code starts to get big, and when the interface definitions are getting longer and longer and the dll's getting bigger and bigger.
I managed finally to compile the math library code after some tweaks to make it friendly to GCC. It had inline declarations in the header file but function definitions in .cpp files. No good, the compiler didn't like it much and when trying to link to this static library some functions could not be found - presumably due to some sort of name mangling or function names not being defined at all. Stripping the inline keyword away fixed it all.
Anyway that's the sort of issue I've been having - and I learned alot about cyclic dependency too when trying to put all inline definitions of all inter related classes right into the header file. I got through it though, just.
Now however the main demo application will not run. It must surely be down to something in the DLL file as it compiles and links fine, and gets part way through the initialisation procedure, then hangs - and writes nothing to the log file. Great.
So I started the debugger and was amazed how much it brings to error hunting. It found the offending function and even told me that an error of type SIGSEGV had returned - a memory issue. Basically it's tried to access a aportion of memory which contained either nothing, or not what it was expecting. That is useful but still leaves me with a huge function to sift through.
So I think it's about time I learned to properly use a debugger. All I know how to do right now is fire it up and read back it's output, but I'm told you can do an awful lot more, even tracing it all the way down to very exact command that has caused the issue. Sounds good to me indeed!
So what I would like is, if someone could recommend to me a very good book for a beginner so I can get started and fix this problem, as well as learn to fix just about any other problem I might or would ever have when hitting run time errors. I don't want anything orientated directly for Visual C++ although I am not anti-Microsoft, I just want something generalised and yet rather exhaustive.
Thanks! As always ;)