Debugging C

Robert Ward

Publisher: Que, 1986, 349 pages

ISBN: 0-88022-261-1

Keywords: Programming

Last modified: July 1, 2021, 3:50 p.m.

If you've spent hours looking for a bug in your C program only to give up without having gained a clear idea of the nature of the program, Debugging C is for you.

The simple truth is that programs seldom run right the first time. Better than half of your program-development time can be spent debugging.

C programmers can't rely on debugging techniques borrowed from other programming languages. C's portability, flexibility, modularity, and wide-ranging expressiveness demand a methodical and incremental debugging approach unique to the language.

In Debugging C, Robert Ward presents an unparalleled analysis of bugs and debugging methods with a "how to" look at representative debugging tools.

Following a model based on the scientific method, Debugging C explores:

  • bug-classification schemes
  • bug-search methods that work for all modern compiled languages
  • program-test strategies
  • conventional debugging methods that can be adapted to C
  • commercial debugging tools

For both new and experienced C programmers, Debugging C offers a strategy for developing heuristic knowledge that provides for more effective and efficient searches.

Debugging C will challenge you to study and learn from the debugging process, to structure your debugging activities, and to return to the task of program design with greater respect for the intellectual challenge debugging offers.

  • Introduction
    • Why a Book on Debugging?
    • Debugging Then and Debugging Now
    • Debugging = Working Programs
    • Debugging C is Demanding
    • Who Should Read This Book?
    • Chapter Survey
  1. Foundations
    • Debugging and Scientific Method
    • The Debugging Process
      • Phase One: Testing
      • Phase Two: Stabilization
      • Phase Three: Localization
      • Phase Four: Correction
    • Principles of Proximity
      • Lexical Proximity
      • Temporal Proximity
      • Referential Proximity
    • Debugging Tools and Techniques
    • RETURN
  2. Program Testing
    • Recognizing Bugs
      • Lexical Errors
      • Syntactic Errors
      • Execution Errors
      • Intent Errors
    • Other Yardsticks
      • Some Bugs Stand Still
      • Some Bugs Are Input Dependent
      • Some Bugs Are Code Sensitive
      • Some Bugs Are Environment Sensitive
    • Before Attempting To Localize, Stabilize
    • Testing Strategies
    • How Testing Works
      • Top-Down Testing
      • Bottom-Up Testing
      • A Mixed Strategy
    • Selecting Test Data
    • Keeping Adequate Records
    • Hunting versus Verifying
    • RETURN
  3. Localizing Compile-Time Errors
    • Compiling: Process and Components
    • Syntax Errors: Some All-Purpose Advice
    • Forcing More Useful Error Messages
    • Using Curly Brace Checkers
    • Using Lint to Analyze Syntax
    • Isolating Bugs with Tiny Test Programs
    • Using the Preprocessor as a Stand-Alone Program
    • Understanding C Syntax
      • Using Hand Parsing
      • Using a Syntax-Directed Editor
    • RETURN
  4. Conventional Trace Methods
    • Control-Flow Tracing
      • Instrumenting If Statements
      • Tracing Control Values
      • Instrumenting Loops
      • Instrumenting Breaks and Continues
      • Instrumenting Case Statements
      • Methodical Instrumentation, Not Mystical Insight
      • Instrumenting Functions
    • Data-Flow Tracing
      • Selecting Variables
      • Using Snapshots
      • Tracing Local Variables
    • RETURN
  5. Managing Trace Facilities
    • Controlling Trace Output
      • Making Control More Convenient
      • Setting Control Variables
      • Temporal Switches
        • Hard-Wired Changes
        • Counting Mile Posts
        • Function-by-Function
      • Granularity
      • Practical Variations
      • To the Reader
    • Managing Source Code
    • RETURN
  6. Why Is Debugging C Difficult?
    • Strong Types and Error Detection
    • Orthogonality and Error Detection
    • General Impact of Structural Differences
    • The Virtual Machine and Our Expectations
      • Bugs that Attack the Virtual Machine
        • Pointer Bugs and the Stack
        • Out-of-Range Subscripts
        • Variations
        • Uninitialized Pointers
        • Pointers that Write on Code
    • RETURN
  7. Stabilizing Pointer Bugs
    • The Importance of Unallocated Memory
    • The Benefits of Initialized Memory
    • Initializing Unallocated Memory with a Debug Tool
      • Initializing Memory Using DDT
      • Initializing Memory Using MS-DOS's DEBUG
        • Generating a Load Map
        • 8086 Address Notation
        • Identifying Globals
    • Using DEBUG
      • Exploring with DEBUG
      • Words of Caution
    • Building a Memory-Initialization Function
    • Adding a Special Initialization Program to the Invocation Sequence
    • MS-DOS Initialization Programs
    • Special Loaders
    • Initializing Local Variables
    •  Accessing the Stack
    • Automatic Local Traces
    • RETURN
  8. Special Trace Techniques
    • Monitoring the Virtual Machine
      • Checksums on Code Space
        • Checksums under CP/M
        • Problems with CP/M Checksums
        • Checksums under MS-DOS
        • Managing Checksums
      • Stack Walk-Back
        • A Sample Walk-Back
        • A Pointer Bug that Writes on the Stack
        • Interpreting the Stack-Trace Detail
          • Return Address
          • The Stack Address and the Frame pointer
    • Machine-Level Tracing
      • Trace Preparation
      • Displaying the Code for a Specific Function
      • Tracing Execution
      • Monitoring Local Variables with DEBUG
    • RETURN
  9. Source-Level Debuggers
    • sdb: UNIX's Symbolic Debugging Program
      • Using sdb
      • Command Format
      • Functions and Variable Locators
      • Other Locators
        • Commands that Display Code
        • Commands that Display Variables
        • Commands that Manipulate Breakpoints
        • Commands that Control Execution
        • Direct Function Evaluation
        • The Monitor Command
        • The Stack Traceback Command
      • sdb Application: Postmortem
      • sdb Application: Locating Pointer Bugs that Write on Globals
      • sdb Application: Locating Pointer Bugs that Write on Locals
      • sdb Application: Locating Pointer Bugs that Destroy Return Addresses
        • Testing Modules
      • Caution
      • sdb Weaknesses
      • Other UNIX Debugging Aids
    • CodeView: Microsoft's Source-Level Debugger
      • User Interface
      • Expression Evaluation
      • Watch Windows
      • CodeView Weaknesses
    • RETURN
  10. Interpreters and Integrated Environments
    • Edit-Compile-Link Costs
    • Interpreting versus Compilation
    • Controlling Debugging Facilities
    • An Overview of C-terp
      • C-terp Debugging Functions
        • The trace() Function
        • The dump() Function
        • The check() Function
        • The breakpt() Function
      • Debug Mode
        • (D/d)isplay
        • Traceback
        • (N/n)ext-Step
        • (S/s)ide-step
        • Continue
      • Restore, Flip, Window, and Edit
    • Using C-terp
        • Selecting Breakpoints by Function Name
        • Finding Pointers that Write on Data
        • Building a Watch Function
        • Bottom-up Testing with C-terp
    • RETURN
  11. Conclusion
    • Looking Back
      • The Formal Framework
      • Universal Techniques
      • C's Unique Problems
      • Arcane Tricks
      • Sophisticated Systems
    • A Curious State of Affairs
    • A Challenge to Compiler Vendors
    • A Challenge to the Reader
  1. Resource List
  2. A Full Featured Debugging System
  3. Assembly Language Functions
  4. A Poor Man's Ctrace
  5. sdb Command Summary


Debugging C

Reviewed by Roland Buresund

Excrement * (1 out of 10)

Last modified: May 21, 2007, 3 a.m.

This is pure bullshit. Avoid at all costs and if you happen to find the author, trash the bastard.


There are currently no comments

New Comment


required (not published)