The Art of Debugging with GDB, DDD, and Eclipse

The Art of Debugging with GDB, DDD, and Eclipse

Language: English

Pages: 280

ISBN: 1593271743

Format: PDF / Kindle (mobi) / ePub

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.

JavaScript Enlightenment

Understanding TCP/IP

The International Bank of Bob: Connecting Our Worlds One $25 Kiva Loan at a Time

Jenkins: The Definitive Guide

Friction: An Ethnography of Global Connection















done. For example, some parallel-processing software packages use artificial seg faults, to which a special handler responds, to maintain consistency between the various nodes of the system, as you will see in Section 5. Another use for specialized handlers for SIGSEGV, to be discussed in Chapter 7, involves tools for detecting and gracefully reacting to seg faults. However, custom signal handlers may cause complications when using GDB/DDD/Eclipse. Whether it is used on its own or through the

this. (gdb) print lastchar $1 = 0 '\0' We were expecting lastchar to be '!', but instead it's the null character. This looks like it's probably an "off by one" error. Let's figure it out. We can visualize the string like so: pointer offset: 0 1 2 3 4 5 6 cstring->str: H e l l o ! \0 string length: 1 2 3 4 5 6 The last character of the string is stored at the address cstring->str + 5, but because the string length is a character count, rather than an index, the address cstring->str +

error is somewhere in insert(). Now, uncomment the lines of that function (again, preferably using a text editor shortcut such as "undo") and save the file. Also, just to make sure you've restored things correctly, re-run GCC to confirm that the syntax error resurfaces (not shown here). At this point you can apply another principle stated in Chapter 1: the Principle of Binary Search. Repeatedly narrow down your search area in the function insert(), cutting the area in half each time, until you

features, similar to EFence, that you can use to catch and recover from dynamic memory problems. We'll discuss them briefly here. The MALLOC_CHECK_ Environment Variable The GNU C library provides a shell environment variable named MALLOC_CHECK_ that can be used, like EFence, to catch DAM access violations, but you don't need to recompile your program to use it. The settings and their effects are as follows: All DAM checking is turned off (this is also the case if the variable is reads in numbers from the command line, builds up a linked list consisting of those numbers in sorted order, and then prints out the sorted list. Here are the source files: 1 // usage: [java] TestLL list_of_test_integers 2 3 // simple example program; reads integers from the command line, 4 // storing them in a linear linked list, maintaining ascending order, 5 // and then prints out the final list to the screen 6 7 public class TestLL 8 { 9

Download sample