Debugging Techniques and Tools for Software Developers, Slides of Business Administration
An overview of various debugging techniques and tools for software developers, including the use of assertions, conditional compilation, debugging aids like lint and garbage collectors, and handling tricky cases. It also covers the importance of testing and the role of debuggers in determining the cause of software issues.
Download Debugging Techniques and Tools for Software Developers and more Slides Business Administration in PDF only on Docsity!
Debug Prompts
Windows does not use core files.
If you run your code outside of a debugger and a problem occurs you will be given the option of either debugging the code or killing the executing process.
Abort Signal (Unix)
You can use the abort signal to help determine the cause of your problem
SIGBUS: Likely a dereference of a NULL pointer
SIGSEGV: Likely a dereference of a bogus pointer, an invalid write to code space, or a bad branch to data space
SIGFPE: Division by zero
Debugging Techniques
Use assertions liberally
Add conditionally compilable debugging code
Multiple platform execution has a way of bringing bugs to the surface
Assertions
Can be used to enforce function pre and post conditions
Make your implicit assumptions explicit
Can be turned off in final release for a performance boost or left in with messages to help in bug report creation
Multiple Platform Execution
Additional initial design effort
Great debugging aid
Can be a commercial selling point
A few tricky cases before moving
on...
The library function calls go nuts, but only when they are called after function X...
My program is freeing block x prematurely. How do I find out why (and more importantly because of where)?
I am using files to synchronize two programs “halves” under nfs. The process periodically breaks when a file open fails.
Lint
Lint is a semantic checker that identifies potential bugs in C programs
Lint is a mistake!
In the early days of C on UNIX complete semantic checking was removed from the C compiler as a design decision. This allowed for smaller, simpler, and faster compilers at the expense of potentially buggy code.
Lint exists on UNIX systems (but not LINUX)
Most modern ANSI C compilers include Lint semantic checking functionality but only some of Lint’s other features
Use Lint Early and Often!
What does Lint Do?
Checks for consistency in function use across multiple files
Finds
bugs
non-portable code
wasteful code
Typical Bugs Detected include
Argument types transposed between function and call
Function with wrong number of arguments takes junk from stack