Thread: Non-invasive debugging poll

  1. #1
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875

    Non-invasive debugging poll

    While working on some recent problems at work lately I have come up with some challenges due to the harsh environmental situation that I am working to address. The issues that I am aware of (and find solutions to) are:
    1. The environment (Suse Linux 10.3). Resolving package dependencies on such an old distribute can be tricky, particularly since we are locked into the first DVD of the distro.
    2. We have to work in a chroot jail which has a pretty limited set of dev libraries to pick from.
    3. We cannot alter the make files/system w/o getting permission from on high.
    4. We cannot significantly add stuff to the codebase.

    With that in mind I am looking for ideas for debugging tools. For one example as part of an answer I gave in another thread ( Codeblocks. ) I ran across cppcheck which is like lint except that it works. We can use GDB but given our weird hardware requires that GDB be run over a serial cable. Because we cannot alter our makefiles that immediately puts the kibosh on things like Electric Fence and most other new/delete overloaders. Valgrind jave a hard time in our world because the strange almost component design means that it doesn't attach to the right process some/most of the time.

    So at the end of the day I am looking for any kind of toolset that I can use by just including a header file. If you look at the Linux forum I have demonstrated just such a tool that is bt.hpp; a simple set of function calls that generates a callstack on-demand. The key things about this is it just uses the default libs on any Linux distro; to use it, just include it and call a single function when you need a callstack. This gives you an idea of where the program has been with something bad happens.

    I would like to find what other tools like this that others are using that might fit this bill. I have looked at electric fence (which needs a library linked to do its work), DUMA, Valgrind. I am working on a simple smart ptr class that in addition to what a class of that type does (watch for deletes to go with new allocations) but by overloading the [] operator I am trying to watch for a certain class of buffer over and under-runs. Oh yes and this class needs nothing more than a include "bt.hpp" and a single call to trigger it.

    The issues I need to solve is a variables being created and used before being initialized, buffer over and underruns, pointers and such being used after they have been deleted, etc. Even header-only code for monitoring hardware and/or system resources (total memory in use, graphics memory, etc. I am slowing building up a library of such tools but with everything that there is already on my plate, any suggestions would be a win.

    Thanks and feel free to ask any questions that would help clarify the situation.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jeffcobb
    For one example as part of an answer I gave in another thread ( Codeblocks. ) I ran across cppcheck which is like lint except that it works.
    Speaking of static code analysis tools, I came across Coverity Static Analysis when Coverity started offering it for free to high profile open source projects.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    So they've dumped a piece of garbage with multiple serious problems in your lap, then stuck their fingers in their ears and said "Neener neener, our code is so awesome you can't possibly be trusted to actually WORK on it, just fix all the problems in our awesome code by MAGIC!"

    Run! Run away!
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > 3. We cannot alter the make files/system w/o getting permission from on high.
    Why would you have to, if you have no reason to check the files in?

    Also, how many problems could you detect if you ran the s/w on a recent distro with all the latest toys (again, as a prototype exercise, not committing anything to the mainline codebase).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Speaking of static code analysis tools, I came across Coverity Static Analysis when Coverity started offering it for free to high profile open source projects.
    Coverity does more than just static analysis but I think the open source version only does static analysis. Coverity is an extremely nice tool.

    The request sounds odd indeed. Just how much do they mean when they say you cannot 'significantly alter the codebase'. I could spin that one far and wide and I'm sure you can too.

  6. #6
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by Salem View Post
    > 3. We cannot alter the make files/system w/o getting permission from on high.
    Why would you have to, if you have no reason to check the files in?

    Also, how many problems could you detect if you ran the s/w on a recent distro with all the latest toys (again, as a prototype exercise, not committing anything to the mainline codebase).
    It has to do with a combination of company policy and regulatory hurdles (Nevada gaming laws). I admit I don't understand them yet being new to the area but there are some strict rules about how deeply you can inject debug code into projects, how they can be tested, etc. Maybe when I learn more about the slot machine biz this part will make sense but I did try to get things like electric fence, etc linked into the system just for debugging but the makefiles were created by another department and the rule is literally thou shalt not touch. Thus the thing I posted about instant callstacks is fine since I don't need to muck with the makefiles. Getting beyond that though will take some coding skills but it seems more like management management skills if you catch my drift.

    In the mean time I have a job to do and am looking for just what I mentioned above. Telling me that I am wrong for even asking is an opinion by someone who doesn't want to help solve the situation.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Are these people clueless about the difference between development and production?

    How were the buggy routines written in the first place, before being hidden behind a wall of officialdom?

    Get them to sign a release absolving you of any fault should it be revealed in future that a problem would have been found had you been able to use proper tools.

    Or ask them if they'd ever drive a car if the testers were always forced to use blindfolds.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Salem View Post
    Are these people clueless about the difference between development and production?
    You mean legislators and law enforcement? I believe ignorance is their forte.

    Or ask them if they'd ever drive a car if the testers were always forced to use blindfolds.
    Hmm, since automotive software is closed source and proprietary most of us are actually doing that already, crazy as it sounds...
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  9. #9
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jeffcobb View Post
    In the mean time I have a job to do and am looking for just what I mentioned above. Telling me that I am wrong for even asking is an opinion by someone who doesn't want to help solve the situation.
    I'm not telling you you're wrong, I'm telling you THEY are wrong, and you're going to get burned.

    Reasonable people do not give you a job to do and then deny you access to all reasonable tools with which to do it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  10. #10
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Look I don't doubt they are wrong and yes the lack of proper tools has lead to some heinous issues. The fact remains I need to figure out more non-intrusive ways of catching boundary overwrites (and underwrites), leaks, etc. static code analysis and the dipsh!t header I wrote will only get be so far. Honest if you don't have something like "Have you tried tool X?" it really doesn't help. Having worked in many of the corners of this industry I know having sound code is worth its weight in gold and the value it brings. Being the "new guy" here I have to figure out ways (for now) of getting around these issues and still doing a great job.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  11. #11
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I admit I don't understand them yet being new to the area but there are some strict rules about how deeply you can inject debug code into projects, how they can be tested, etc.
    I don't know of any federal gaming laws that specifically address that issue. Of course it depends on what class of gaming you are talking about and what jurisdiction or state the game will be in, etc., etc.

  12. #12
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Oh believe me, they are there. I cannot even have a DEBUG_LOG(x) macro that compiles to nothing in release mode...and since I seem to spend more time arguing about the parameters of the problem than seeking solutions, moderators, pls close this thread. It is not helping anyone.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  13. #13
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jeffcobb View Post
    Oh believe me, they are there. I cannot even have a DEBUG_LOG(x) macro that compiles to nothing in release mode...and since I seem to spend more time arguing about the parameters of the problem than seeking solutions, moderators, pls close this thread. It is not helping anyone.
    Well, hold your horses. I made my point, we can move on...

    Are you able to inject a shared library into the process via LD_PRELOAD? You may be able to inject Electric Fence at runtime instead of compiling it in. If I remember, it just replaces malloc() and free() with its own implementations, and I know for a fact you can do that replacement at runtime by injecting a library.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Oh believe me, they are there. I cannot even have a DEBUG_LOG(x) macro that compiles to nothing in release mode...and since I seem to spend more time arguing about the parameters of the problem than seeking solutions, moderators, pls close this thread. It is not helping anyone.
    That would be either your company's policy or a policy put in place by the gaming commission in Nevada. I've never heard of such a law as it relates to gaming. The only company I know if in NV that might have these issues shall remain nameless to protect the innocent but even then I've never been exposed to such strict requirements in the gaming industry.

    Perhaps you could do some searching and spin this one on its head to your PMs so you can get some more leverage to work with. If not then I'm not sure what you can do given they have said build a house with what amounts to a paperclip. Not even MacGyver could do that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help on debugging
    By Masterx in forum C++ Programming
    Replies: 56
    Last Post: 01-30-2009, 10:09 AM
  2. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 10:48 AM
  3. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  4. Today on Cprogramming....When Polls go bad?
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 01-25-2002, 01:41 PM
  5. Poll this Poll that
    By ski6ski in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-28-2001, 04:19 AM