Start free trial
Trending New Genres Authors
EnglishEnglish
EspañolSpanish
简体中文Chinese
繁體中文Chinese (Traditional)
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Searching...
SoBrief
The Art of Debugging with GDB, DDD and Eclipse

The Art of Debugging with GDB, DDD and Eclipse

Turn crashes, hangs, and wrong answers into evidence you can follow through the code.
by Norman Matloff 2007 280 pages
3.91
106 ratings
Listen
Immersive
V2.3
Amazon Kindle Audible
Try Full Access for 3 Days
Unlock listening & more!
Continue

Key Takeaways

Debug by testing assumptions, not by guessing where the bug lives

Make assumptions testable. The book’s central method, the Fundamental Principle of Confirmation, treats debugging as checking beliefs about what the program should do against what it actually does. When an observation contradicts an expectation, that surprise narrows the search. In the running insertion-sort example, the program hangs on just two numbers. Checking the loop state reveals that a mistaken assignment in a condition repeatedly resets a counter, explaining the apparent infinite loop.

Let evidence direct the next step. The debugger makes these checks quick: pause execution, inspect a variable, and compare its value with the prediction. Print statements can expose values too, but repeatedly editing, recompiling, and removing diagnostic code interrupts the reasoning process. The goal is not to stare at more output. It is to ask sharper questions of the program.

Analysis

What's valuable here is the shift from hunting for suspicious code to designing small tests of a mental model. That resembles scientific falsification: a theory earns confidence by surviving attempts to disprove it, not by sounding plausible. In programming, the test can be unusually precise because the debugger exposes the state at a specific instruction. The method still depends on a useful prediction. If expectations are vague, inspection becomes aimless, so each pause should answer a concrete question about a value, branch, or call.

Shrink the case, then bisect the search before reading everything

Make the failure manageable. Start with simple inputs, such as two numbers in a sorting program, because early iterations often expose basic defects before a complex run adds noise. Debug from the top down as well: if a function's output looks correct, do not immediately inspect every line inside it. Step over the call, check its result, and enter the function only if evidence points there.

Cut the search space. Binary search applies beyond sorted arrays. If a variable becomes wrong somewhere in 1,000 loop iterations, inspect a midpoint, then halve the remaining interval. The same logic helps with a misleading compiler error: comment out half a function, rebuild, and keep the half that still produces the error. Preserve the original code, and remove whole logical blocks so the experiment does not introduce new syntax errors.

Analysis

The shared principle behind small test cases, top-down inspection, and binary search is controlled reduction: change the scale of the investigation while keeping the question clear. This is a practical form of experimental design, where each test should eliminate plausible explanations. But bisection works best when the failure behaves consistently and the code can be divided without changing the phenomenon. In stateful or timing-sensitive programs, cutting a block may alter the bug itself. There, a debugger's direct observation is often safer than aggressive source editing.

Place stops where evidence can distinguish competing explanations

Pause with a purpose. A breakpoint stops execution at a chosen point, allowing inspection before the next statement runs. Breakpoints can target a line or function, and temporary breakpoints disappear after being reached once. A conditional breakpoint adds a test, such as stopping only when a loop counter reaches a suspect value. This avoids stepping through thousands of irrelevant iterations.

Watch a changing value. A watchpoint pauses when a variable, memory location, or expression changes. It helps when the programmer knows which value goes wrong but not where it changes. For example, watching whether a variable exceeds a threshold can reveal the first moment an assumption fails. Keep track of breakpoint conditions and enabled status: a forgotten condition or disabled stop can make a correct debugging plan appear ineffective.

Analysis

A breakpoint is most useful when it separates hypotheses. If a bug appears only for one input value, a conditional stop can focus attention on that case; if the source of a mutation is unknown, a watchpoint searches across execution. The distinction is similar to choosing between targeted sampling and continuous monitoring. More instrumentation is not automatically better: frequent stops can bury the relevant event in noise, while complex conditions can themselves be hard to reason about. The strongest setup is the simplest one that can discriminate among likely causes.

Inspect changing state and call history before entering every function

Look at the program's state. After a pause, inspect the values that should determine the next action. GDB's print command handles individual variables and structures; display repeats an inspection whenever execution pauses. The call stack shows which functions led to the current point, and moving between stack frames exposes the callers' local variables and arguments. This can reveal that a bad value was created before the current function began.

Choose a useful view. In a binary-tree example, printing a pointer's target reveals the node's value and child links. DDD can draw linked structures and let the programmer follow pointers visually, while Eclipse provides variable and stack views. Dynamically allocated arrays need special treatment: GDB can display a chosen number of elements as an artificial array. Inspect only the data that answers the current question.

Analysis

The call stack and variable views turn execution into a traceable chain of causes rather than a flat list of lines. That is especially important in modular programs, where the function exhibiting a symptom may simply have received bad input from its caller. Visual tools can reduce the mental effort of following pointers, but a polished diagram is not proof that a data structure is valid. Values still need to be checked against invariants, such as whether each tree node belongs on the expected side of its parent.

Treat a crash address as a clue, not a verdict

Use the crash site. A segmentation fault usually means the program attempted an access it was not permitted to make. Reproduce the failure under a debugger, then inspect the reported line and use a backtrace to see the calls that led there. If the program cannot easily be rerun, a core file preserves information about its final state for postmortem inspection.

Remember page boundaries. Memory protection is applied in pages, not separately to each array element. In the book's example, an array overrun continues without a fault because the invalid indexes still land within an accessible page. The crash occurs only when access crosses into a page without the required permission. Therefore, the line that finally faults may be where damage becomes visible, not where the original mistake began, and the absence of a fault does not prove an access was valid.

Analysis

The distinction between a faulting instruction and the defect that produced it is a basic but easily forgotten causal distinction. A crash gives a precise observation point, not a complete explanation. The page-granularity example makes this concrete: machine protection can catch some invalid accesses while silently allowing others. That is why a debugger's backtrace and state inspection matter alongside the exception itself. The practical lesson extends to any diagnostic signal: it marks where a system detected trouble, which may differ from where the trouble was introduced.

Memory corruption can travel far before it crashes

Follow allocation and ownership. The book's CString example, a small managed-string implementation, contains several distinct memory errors. It allocates the structure but forgets to allocate space for its character data, reads the character after the string's end, writes the character '0' instead of the null terminator, frees the structure before reading its field, and underallocates space when appending text. Some errors crash immediately; others merely truncate or corrupt the result.

Use dedicated checks. Tools such as Electric Fence can make certain out-of-bounds accesses fail close to the offending operation. GNU C library facilities can detect heap inconsistencies, leaks, or repeated frees. These tools complement the debugger because corrupted memory may otherwise cause symptoms far from the original mistake. Check allocation results, reserve room for the terminating null character, and release memory only after all needed fields have been used.

Analysis

Memory bugs are difficult because their effects are not reliably local or immediate. The CString example is useful precisely because a short program can contain several independent failures, each requiring a different kind of check. Treating allocation size, string length, termination, and freeing order as separate invariants makes the code easier to audit. Automatic tools can expose violations, but they cannot decide whether an object's ownership rules make sense. A clean run is evidence, not a guarantee, especially when the faulty access happens to land in usable memory.

In concurrent code, make shared updates indivisible and inspect every thread

Expect timing to vary. In threaded programs, the operating system can switch between threads at unpredictable points. If two workers update the shared variable that assigns their next task, an unprotected update can be interrupted midway, causing work to be repeated or skipped. A critical section, guarded by a mutex, allows only one thread at a time to perform that update. Forgetting to release the lock can leave every worker waiting indefinitely.

Debug the whole activity. GDB can list threads, switch focus, and show each thread's call stack. In the book's sieve example, two workers are found waiting for a lock while the main thread waits for them to finish. Parallel programs also use message passing, such as MPI, and shared-memory directives, such as OpenMP. A pause in one process or thread may be explained by another participant's state.

Analysis

Concurrency changes the debugging question from “What did this line do?” to “What sequence of events could have reached this state?” That calls for reasoning about shared state, ordering, and waiting, not just source order. Mutexes make critical sections easier to reason about, but they can introduce deadlocks if acquisition and release are not balanced. Debugger pauses can also alter timing, so a race may disappear during inspection. Thread and process views are essential, but repeated runs and careful attention to synchronization remain necessary.

Pair the debugger with compiler checks, tracing, and memory tools

Build a diagnostic toolkit. A debugger is only one layer. Compiler warnings can catch suspicious code before execution, and the authors recommend enabling GCC's broad warning set. A capable editor can highlight syntax, match brackets, and jump between compiler errors. For failures involving operating-system interactions, errno can identify an error category, while strace records system calls and their results; ltrace provides a similar view of library calls.

Choose tools by symptom. Static checkers such as splint flag questionable code without running it. Memory tools can expose allocation errors that ordinary runs miss. If code does not compile, narrowing the source region can help locate a misplaced brace or other syntax problem. No single tool explains everything: a system-call trace may reveal a refused network connection, while a source debugger is better for understanding the program state that led to it.

Analysis

The book's strongest practical claim is not that one debugger can solve every problem, but that different tools expose different layers of a program. A compiler sees suspicious construction, a source debugger sees state and control flow, and a system-call trace sees the program's interaction with the operating system. This layered view reduces the temptation to force every symptom into one explanation. Tool output still needs interpretation: warnings can be false alarms, and tracing can produce more detail than a programmer can use without a focused question.

Choose the interface and language adapter that fit the debugging job

Use the right front end. GDB's text commands are quick, compact, and useful over remote terminal connections. DDD and Eclipse make stepping, breakpoint management, and variable inspection more visual, though their larger interfaces can consume screen space. DDD also permits direct GDB commands, combining mouse operations with command-line flexibility. The best choice depends on the program and the working environment, not on a universal ranking of interfaces.

Carry the method across languages. The book shows GDB, DDD, and Eclipse applied beyond C and C++ to Java, Perl, Python, assembly, and code that connects interpreted languages to C through SWIG. It also shows why GUI programs may need a separate execution terminal, as with curses. The principles remain recognizable, but language support and debugger capabilities differ, so the underlying tool must be verified rather than assumed.

Analysis

The durable skill is not memorizing one interface's menus. It is understanding the operations common to debuggers, then learning how a particular tool exposes them. That distinction helps programmers transfer knowledge between languages and environments without assuming feature parity. A graphical interface can make state easier to see, while a command interface can be more efficient in constrained settings. The book's specific software versions date from an earlier era, so its strategic lessons travel better than every setup instruction or feature claim.

Analysis

This is a technical manual organized around a practical progression: establish a way to reason about bugs, learn the debugger's control and inspection tools, then apply them to crashes, concurrent programs, and other development problems. Its central contribution is not a catalogue of GDB commands. It is a disciplined habit of turning vague suspicion into a sequence of checks. The repeated insertion-sort session makes that method memorable: a program first hangs, then produces wrong output, then crashes, and each newly observed symptom redirects the investigation. The reader sees debugging as iterative diagnosis rather than a single clever leap.

The breadth is unusually useful for a debugging guide. Memory layout explains why some invalid accesses crash and others appear to work. Thread and MPI examples show that a process's state cannot always be understood in isolation. Companion tools extend the view into compilation, system calls, static analysis, and dynamic allocation. The comparisons among GDB, DDD, and Eclipse also resist the easy claim that a graphical interface is always superior. Each changes the cost of observing and controlling execution.

The book's strongest advice is to make every debugging action answer a specific question. Its limitation is that detailed demonstrations can make the process look more deterministic than real investigations often are. Bugs may depend on inputs, timing, or environmental conditions that are hard to reproduce, and debugger instrumentation can change those conditions. Even the absence of a crash is weak evidence of correctness, as the page-based memory example shows. The most reliable approach is therefore layered: reason about expected behavior, inspect runtime state, use specialized checks, and test the repair against cases that challenge the original assumption. The command details reflect the tools available when the book was written, but this diagnostic mindset remains applicable across modern debuggers and languages.

Summary in 30 Seconds
Debugging becomes more reliable when each pause tests a specific expectation. Reduce failures to small cases, then narrow the search by checking intermediate states, using conditional breakpoints, watchpoints, and call stacks. A crash may expose where damage surfaced, not where it began, so pair runtime inspection with memory checks and compiler warnings. In concurrent programs, inspect every thread and protect shared updates with locks. Use tracing and static analysis when the source debugger cannot explain the symptom.
Contains spoilers

Last updated:

Report Issue

Review Summary

3.91 out of 5
Average of 106 ratings from Goodreads and Amazon.

The Art of Debugging with GDB, DDD and Eclipse receives mixed reviews. Some praise it as essential for developers, highlighting its focus on GDB and practical debugging scenarios. Others find it outdated, with examples needing adjustment for current systems. The book is commended for its systematic approach to common debugging issues and introducing GDB's capabilities. However, criticisms include excessive length, outdated code examples, and limited coverage of DDD and Eclipse. Overall, it's seen as a helpful resource for beginners, despite its flaws and age.

Your rating:
4.41
115 ratings
Want to read the full book?

Glossary

Fundamental Principle of Confirmation

Test beliefs against execution

The book's central debugging principle: fixing a program means checking, one by one, whether assumptions about its behavior match what the program actually does. A mismatch is useful evidence that narrows the likely location or cause of a defect. The method encourages deliberate questions about values, branches, and calls instead of unsupported guesses.

watchpoint

Pause when data changes

A debugger instruction that pauses execution when a selected memory location or expression changes value. A basic watchpoint can track a variable; an expression-based watchpoint can detect a condition becoming true. It is especially useful when a value is known to become incorrect but the code that changes it is not known.

conditional breakpoint

Stop only when a condition holds

A breakpoint that pauses execution at a selected program location only when a specified condition is true. For example, it can stop at a loop line only when an index reaches a suspected value. This avoids repeatedly stopping at an unhelpful point and lets the debugger focus on a particular input, iteration, or state.

core file

Saved state after a crash

A file that can preserve information about a process when it terminates abnormally, including its stack, register state, and statically allocated variables. A debugger can inspect the file after the original run has ended. Core files are useful when a crash is difficult to reproduce, occurs under another user's run, or depends on unpredictable conditions.

critical section

Protected shared-state operation

A region of concurrent code that accesses shared state and must not be executed simultaneously by competing threads. A mutex or similar synchronization mechanism protects entry and exit. Without protection, a thread switch during a multi-step update can cause lost or duplicated work; an unmatched lock can instead leave threads waiting indefinitely.

software distributed shared memory

Shared memory simulated across machines

A software layer that gives programs running across networked computers the appearance of accessing shared memory. The system coordinates local copies of shared data, sometimes using virtual-memory page faults to trigger updates. Those mechanisms can create pauses that resemble ordinary faults, so debugging requires understanding that some apparent errors are part of the runtime's coordination.

Electric Fence

Detect invalid heap access

A debugging library that can make certain accesses outside dynamically allocated memory fail immediately, often producing a segmentation fault near the offending operation. It can also help detect accesses to freed memory and invalid frees. Because its protection has limits and changes program behavior, it supplements rather than replaces ordinary debugging and careful memory-management checks.

About the Author

Norman Matloff is an academic and author known for his work in computer science and statistics. He has written several books on programming and data analysis, including "The Art of Debugging with GDB, DDD and Eclipse." Matloff is a professor at the University of California, Davis, where he teaches in the Department of Computer Science. His research interests include statistical computing, parallel processing, and software engineering. Matloff is recognized for his ability to explain complex technical concepts in an accessible manner, making his books popular among students and professionals alike. He has contributed significantly to the field of debugging and software development through his publications and teaching.

Download PDF

To save this The Art of Debugging with GDB, DDD and Eclipse summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.30 MB     Pages: 15

Download EPUB

To read this The Art of Debugging with GDB, DDD and Eclipse summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 1.36 MB     Pages: 18
Want to read the full book?
Follow
Listen
Home
Swipe
Library
Get App
Try Full Access for 3 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
Read unlimited summaries. Free users get 3 per month
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
—
❤️ Unlimited Bookmarks
Free users are limited to 4
—
📜 Unlimited History
Free users are limited to 4
—
📥 Unlimited Downloads
Free users are limited to 1
—
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 26,000+ books. That's 12,000+ hours of audio!
Day 2: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 3: Your subscription begins
You'll be charged on Nov 28,
cancel anytime before.
Consume 2.8× More Books
2.8× more books Listening Reading
Our users love us
1M+ readers
Trustpilot Rating
TrustPilot
4.6 Excellent
This site is a total game-changer. I've been flying through book summaries like never before. Highly, highly recommend.
— Dave G
Worth my money and time, and really well made. I've never seen this quality of summaries on other websites. Very helpful!
— Em
Highly recommended!! Fantastic service. Perfect for those that want a little more than a teaser but not all the intricate details of a full audio book.
— Greg M
Save 62%
Yearly
$119.88 $44.99/year/yr
$3.75/mo
Monthly
$9.99/mo
Start a 3-Day Free Trial
3 days free, then $44.99/year. Cancel anytime.
Unlock a world of fiction & nonfiction books
26,000+ books for the price of 2 books
Read any book in 10 minutes
Discover new books like Tinder
Request any book if it's not summarized
Read more books than anyone you know
#1 app for book lovers
Lifelike & immersive summaries
30-day money-back guarantee
Download summaries in EPUBs or PDFs
Cancel anytime in a few clicks

Why one summary?

Scanner
Find a barcode to scan

⭐
⭐
⭐
We have a special gift for you
Open
38% off
DISCOUNT FOR YOU
⭐
⭐
⭐
$79.99
$49.99/year
Only $4.16 per month
Continue
2 taps to start, super easy to cancel
Settings
General
Widget
Loading...