Learning to debug? No please not yet!

This is a discussion on Learning to debug? No please not yet! within the C++ Programming forums, part of the General Programming Boards category; Hi! I'm building a game engine from source. Learning an awful lot about it too, and getting my attitude well ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    87

    Smile Learning to debug? No please not yet!

    Hi!

    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

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    There is no generalized debugger. If you are using Visual Studio, then you need to learn how to use the built in debugger. If you are using Code::Blocks, then you probably want to learn GDB. Different debuggers behave differently, and use different commands to print variable values or set watchpoints, etc.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    87
    Sounds good, new information to me for sure. I think I need to find out which debugger Code::Blocks uses and maybe try and get a book on it. Thanks

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by shrink_tubing View Post
    Sounds good, new information to me for sure. I think I need to find out which debugger Code::Blocks uses and maybe try and get a book on it. Thanks
    Learn GDB. You don't need to get a book though; there's an online manual that's free.
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    87
    Yay! Thanks mate I've bookmarked it. I'll also probably get the book too though (found one on Amazon). Cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-12-2010, 01:57 PM
  2. Binary was not built with debug information.
    By studentffm in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2010, 12:13 PM
  3. makefiles - debug & release?
    By cpjust in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 05:00 PM
  4. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 12:08 PM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-25-2002, 12:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21