The Art of Debugging with GDB, DDD, and Eclipse

The Art of Debugging with GDB, DDD, and Eclipse

The Art of Debugging with GDB, DDD, and Eclipse

The Art of Debugging with GDB, DDD, and Eclipse

eBook

$23.99 

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Debugging is crucial to successful software development, but even many experienced programmers find it challenging. Sophisticated debugging tools are available, yet it may be difficult to determine which features are useful in which situations. The Art of Debugging is your guide to making the debugging process more efficient and effective.

The Art of Debugging illustrates the use three of the most popular debugging tools on Linux/Unix platforms: GDB, DDD, and Eclipse. The text-command based GDB (the GNU Project Debugger) is included with most distributions. DDD is a popular GUI front end for GDB, while Eclipse provides a complete integrated development environment.

In addition to offering specific advice for debugging with each tool, authors Norm Matloff and Pete Salzman cover general strategies for improving the process of finding and fixing coding errors, including how to:
–Inspect variables and data structures
–Understand segmentation faults and core dumps
–Know why your program crashes or throws exceptions
–Use features like catchpoints, convenience variables, and artificial arrays
–Avoid common debugging pitfalls

Real world examples of coding errors help to clarify the authors’ guiding principles, and coverage of complex topics like thread, client-server, GUI, and parallel programming debugging will make you even more proficient. You'll also learn how to prevent errors in the first place with text editors, compilers, error reporting, and static code checkers.

Whether you dread the thought of debugging your programs or simply want to improve your current debugging efforts, you'll find a valuable ally in The Art of Debugging.

Product Details

ISBN-13: 9781593272319
Publisher: No Starch Press
Publication date: 09/15/2008
Sold by: Penguin Random House Publisher Services
Format: eBook
Pages: 280
File size: 4 MB

About the Author

Norman Matloff, a computer science professor at UC Davis, is the author of several popular public-domain software packages and online tutorials.
Peter Jay Salzman earned his PhD in physics from UC Davis and founded the Linux Users Group of Davis. He is currently a programmer with a Wall Street financial firm.

Table of Contents


Preface xi
1 Some Preliminaries for Beginners and Pros 1
1.1 Debugging Tools Used in This Book 1
1.2 Programming Language Focus 2
1.3 The Principles of Debugging 2
1.3.1 The Essence of Debugging: The Principle of Confirmation 2
1.3.2 Of What Value Is a Debugging Tool for the Principle of Confirmation? 3
1.3.3 Other Debugging Principles 4
1.4 Text-Based vs. GUI-Based Debugging Tools, and a Compromise Between Them 5
1.4.1 Brief Comparison of Interfaces 5
1.4.2 Compromises 12
1.5 Main Debugger Operations 14
1.5.1 Stepping Through the Source Code 14
1.5.2 Inspecting Variables 15
1.5.3 Issuing an "All Points Bulletin" for Changes to a Variable 17
1.5.4 Moving Up and Down the Call Stack 17
1.6 Online Help 19
1.7 Introductory Debugging Session 19
1.7.1 The GDB Approach 22
1.7.2 The Same Session in DDD 36
1.7.3 The Session in Eclipse 38
1.8 Use of Startup Files 43
2 Stopping to Take a Look Around 47
2.1 Mechanisms for Pause 47
2.2 Overview of Breakpoints 48
2.3 Keeping Track of Breakpoints 49
2.3.1 Breakpoint Lists in GDB 49
2.3.2 Breakpoint Lists in DDD 50
2.3.3 Breakpoint Lists in Eclipse 51
2.4 Setting Breakpoints 51
2.4.1 Setting Breakpoints in GDB 51
2.4.2 Setting Breakpoints in DDD 55
2.4.3 Setting Breakpoints in Eclipse 56
2.5 Extended GDB Example 56
2.6 Persistence of Breakpoints 59
2.7 Deleting and Disabling Breakpoints 60
2.7.1 Deleting Breakpoints in GDB 61
2.7.2 Disabling Breakpoints in GDB 62
2.7.3 Deleting and Disabling Breakpoints in DDD 62
2.7.4 Deleting and Disabling Breakpoints in Eclipse 63
2.7.5 "Moving" Breakpoints in DDD 64
2.7.6 Undoing/RedoingBreakpoint Actions in DDD 66
2.8 More on Viewing Breakpoint Attributes 67
2.8.1 GDB 67
2.8.2 DDD 69
2.8.3 Eclipse 69
2.9 Resuming Execution 69
2.9.1 In GDB 70
2.9.2 In DDD 78
2.9.3 In Eclipse 79
2.10 Conditional Breakpoints 79
2.10.1 GDB 80
2.10.2 DDD 83
2.10.3 Eclipse 84
2.11 Breakpoint Command Lists 85
2.12 Watchpoints 89
2.12.1 Setting Watchpoints 90
2.12.2 Expressions 93
3 Inspecting and Setting Variables 95
3.1 Our Main Example Code 95
3.2 Advanced Inspection and Setting of Variables 98
3.2.1 Inspection in GDB 98
3.2.2 Inspection in DDD 102
3.2.3 Inspection in Eclipse 103
3.2.4 Inspecting Dynamic Arrays 104
3.2.5 What About C++? 109
3.2.6 Monitoring Local Variables 112
3.2.7 Examining Memory Directly 112
3.2.8 Advanced Options for Print and Display 112
3.3 Setting Variables from Within GDB/DDD/Eclipse 113
3.4 GDB's Own Variables 113
3.4.1 Making Use of the Value History 114
3.4.2 Convenience Variables 114
4 When a Program Crashes 117
4.1 Background Material: Memory Management 118
4.1.1 Why Does a Program Crash? 118
4.1.2 Program Layout in Memory 118
4.1.3 The Notion of Pages 121
4.1.4 Details on the Role of the Page Table 122
4.1.5 A Slight Memory-Access Bug Might Not Cause a Seg Fault 124
4.1.6 Seg Faults and Unix Signals 125
4.1.7 Other Types of Exceptions 128
4.2 Core Files 129
4.2.1 How Core Files Are Created 129
4.2.2 Your Shell May Suppress the Creation of a Core File 130
4.3 Extended Example 131
4.3.1 First Bug 135
4.3.2 Don't Leave GDB During a Debugging Session 137
4.3.3 Second and Third Bugs 137
4.3.4 Fourth Bug 139
4.3.5 Fifth and Sixth Bugs 141
5 Debugging in a Multiple-Activities Context 145
5.1 Debugging Client/Server Network Programs 145
5.2 Debugging Threaded Code 151
5.2.1 Review of Processes and Threads 151
5.2.2 Basic Example 153
5.2.3 A Variation 159
5.2.4 GDB Threads Command Summary 161
5.2.5 Threads Commands in DDD 161
5.2.6 Threads Commands in Eclipse 161
5.3 Debugging Parallel Applications 163
5.3.1 Message-Passing Systems 164
5.3.2 Shared-Memory Systems 170
5.4 Extended Example 171
5.4.1 OpenMP Overview 171
5.4.2 OpenMP Example Program 172
6 Special Topics 185
6.1 What If It Doesn't Even Compile or Load? 185
6.1.1 Phantom Line Numbers in Syntax Error Messages 185
6.1.2 Missing Libraries 190
6.2 Debugging GUI Programs 194
6.2.1 Debugging Curses Programs 194
7 Other Tools 205
7.1 Making Good Use of a Text Editor 206
7.1.1 Syntax Highlighting 206
7.1.2 Matching Brackets 208
7.1.3 Vim and Makefiles 209
7.1.4 Makefiles and Compiler Warnings 210
7.1.5 Final Thoughts on a Text Editor as an IDE 211
7.2 Making Good Use of the Compiler 212
7.3 Error Reporting in C 213
7.3.1 Using errno 213
7.4 Better Living with strace and Itrace 217
7.5 Static Code Checkers: Iint and Friends 219
7.5.1 How to Use splint 221
7.5.2 Last Words 221
7.6 Debugging Dynamically Allocated Memory 221
7.6.1 Strategies for Detecting DAM Problems 224
7.6.2 Electric Fence 225
7.6.3 Debugging DAM Problems with GNU C Library Tools 228
8 Using GDB/DDD/Eclipse for Other Languages 235
8.1 Java 236
8.1.1 Direct Use of GDB for Debugging Java 238
8.1.2 Using DDD with GDB to Debug Java 240
8.1.3 Using DDD as a GUI for JDB 241
8.1.4 Debugging Java in Eclipse 241
8.2 Perl 242
8.2.1 Debugging Perl via DDD 244
8.2.2 Debugging Perl in Eclipse 246
8.3 Python 247
8.3.1 Debugging Python in DDD 249
8.3.2 Debugging Python in Eclipse 250
8.4 Debugging SWIG Code 251
8.5 Assembly Language 255 Index 259
From the B&N Reads Blog

Customer Reviews