Access Errors, Defined, 223 Addresses, See Also Virtual Memory Addresses
Total Page:16
File Type:pdf, Size:1020Kb
INDEX A C access errors, defined, 223 C language, see also GNU C library addresses, see also virtual memory error reporting, 213–217 addresses C99 library extensions, splint, 221 breakpoints, 68 call command, 100 arrays, see also dynamic arrays call stacks, moving up and down, 17 inspecting, 37 catchpoints artificial arrays defined, 55 DDD, 107 GDB, 48 GDB, 106 CGDB, 13 assembly language, GDB and DDD, client/server network programs, 255–258 multiprogramming attributes, breakpoints, 67–69 techniques, 145–151 command lists, breakpoints, 85–89 B commands, see also specific commands DDD, 161 backtrace, seg fault location, 4 Eclipse, 161 binary search principle GDB, 161 syntax errors, 189 commands command, 99 using, 4 compilers binary trees, example, 95 using, 212 brackets, matching, 208 warnings, 210 breakpoints, 47–94, see also compiling, 185–193 hardware-assisted breakpoints; missing libraries, 190 temporary breakpoints multi-file programs, 57 about, 47 phantom line numbers in syntax command lists, 85–89 error messages, 185–190 conditional, 79–84 conditional breakpoints DDD, 9 Eclipse, 42 deleting, disabling and moving, using, 79–84 60–66 conditional expressions, watchpoints, GDB example, 56 17 lists, 49 configure scripts, 193 persistence, 59 confirmation principle resuming execution, 69–79 about, 2 setting, 51–56 GDB, 25, 31 using, 14 Java, 239 viewing attributes, 67–69 resuming execution, 69 watchpoints, 89–94 syntax error messages, 187 bugs, memory-access and seg faults, continue command, 74 124 convenience variables build scripts, libraries, 193 names, 115 bus errors, 128 The Art of Debugging with GDB, DDD, and Eclipse (C) 2008 by Norman Matloff and Peter Jay Salzman using, 114 detecting problems, 224 core files Electric Fence library, 225–228 crashes, 129–131 GNU C library tools, 228–233 seg fault location, 4 crashes, 117–144 E core files, 129–131 Eclipse example, 131–144 about, 2 memory management, 118–129 breakpoint lists, 51 critical sections, using, 156 command summary, 161 curses programs, 194–201 conditional breakpoints, 84 versus DDD, 9 D deleting and disabling breakpoints, data section, 119 63 DDD (Data Display Debugger) example, 38–43 about, 2 inspecting variables, 103 assembly language, 255–258 Perl, 246–247 breakpoint lists, 50 Python, 250 command summary, 161 resuming execution, 79 conditional breakpoints, 83 setting breakpoints, 56 deleting and disabling breakpoints, setting variables, 113 62 using GUI, 7 versus Eclipse, 9 viewing breakpoint attributes, 69 example, 36–37 Electric Fence library, dynamically inspecting variables, 102 allocated memory, 225–228 Java, 240–241 Emacs, features, 206 moving breakpoints, 64 enabling, breakpoints, 62 Perl, 244 errno, using, 213–217 Python, 249 errors, see also access errors; bus errors; resuming execution, 78 double frees; warnings setting breakpoints, 55 compiler options for checking, 213 setting variables, 113 reporting in C, 213–217 undoing and redoing breakpoint examples, see sample programs actions, 66 exceptions, crashes, 128 using GUI, 6 execution, resuming, 69–79 viewing breakpoint attributes, 69 expressions, see also conditional defaults, signal handlers, 126 expressions deleting breakpoints, 60–64 library functions, 82 Dijkstra algorithm, 172 watchpoints, 92, 93 disabling breakpoints, 62–64 display command, 98, 102 F displaying variables, 112 faults, see segmentation faults disposition, breakpoints, 68 FIFO queue, example, 251 double frees files, see core files; startup files defined, 224 compiling multi-file programs, 57 mtrace(), 231 finish command, 74 dumping core, 129, 130 FPE (floating-point exception), 128 dynamic arrays, inspecting, 104 functions, see also specific functions dynamically allocated memory, string handling, 132 221–233 The Art of Debugging with GDB, DDD, and Eclipse (C) 2008 by Norman Matloff and Peter Jay Salzman 260 INDEX G infinite loops GDB (GNU Project Debugger), see also GDB, 27 CGDB interrupts, 4 about, 2 inspecting variables, 15 advantages, 11 installing assembly language, 255–258 DDD, 2 breakpoint lists, 49 Eclipse, 2 command summary, 161 integrated development environments conditional breakpoints, 80–83 (IDE), text editors as, 211 deleting breakpoints, 61 Intel stacks, 256 disabling breakpoints, 62 interfaces, text-based versus GUI, 5–14 example, 22–36 interrupts, infinite loops, 4 expressions, 93 inspecting variables, 98 J Java, 238–241 Java, using GDB, DDD and Eclipse, resuming execution, 70–78 236–242 setting breakpoints, 51 JDB (Java Debugger), DDD as GUI for, setting variables, 113 241 startup files, 43 TUI mode, 12 L viewing breakpoint attributes, 67 .gbdinit files, 43 layout, see program layout general protection fault, see lexical highlighting, defined, 206 segmentation fault libraries, see also C99 library GNU C library extensions; curses programs; dynamically allocated memory, Electric Fence library; GNU C 228–233 library; static libraries GNU Project Debugger, see GDB compiling missing, 190 GNU/Linux, see Linux NOW architectures, 170 guard statements, using, 156 SDSM, 170 GUI programs, 194–201 types of, 191 GUI-based tools, see also DDD (Data library calls, errno, 213 Display Debugger); Eclipse library functions advantages, 10 compared to system calls, 217 versus text-based tools, 5–14 GDB expressions, 82 using DDD as a GUI for JDB, 241 line numbers, see phantom line numbers H lint, using, 219–221 Linux, dumping core, 130 hardware watchpoints, 91 lists, see also command lists hardware-assisted breakpoints, breakpoints, 49 defined, 54 loading, 185–193 help, see online help missing libraries, 190 phantom line numbers in syntax I error messages, 185–190 IDE (integrated development local variables, monitoring, 112 environment), text editors as, loops, see infinite loops 211 ltrace, using, 217–219 identifiers, breakpoints, 49 The Art of Debugging with GDB, DDD, and Eclipse (C) 2008 by Norman Matloff and Peter Jay Salzman INDEX 261 M moving up and down call stacks, 17 makefiles stepping though source code, 14 and compiler warnings, 210 watchpoints, 17 and Vim, 209 MALLOC_CHECK_, 228 P mcheck(), 230 page tables, 122 memory, see also dynamically allocated pages memory; virtual address space; about, 121 virtual memory addresses SDMS systems, 170 examining directly, 112 parallel applications, memory leaks, mtrace, 231 multiprogramming memory management, crashes, techniques, 163–171 118–129 parentheses, balancing, 208 message passing, defined, 163 Perl, DDD and Eclipse, 242–247 message-passing systems, perror(), 216 multiprogramming persistence, breakpoints, 59 techniques, 164–169 phantom line numbers, syntax error modular approach, see top-down messages, 185–190 approach pkconfig program, 193 monitoring, local variables, 112 plain text, see text moving, breakpoints in DDD, 64 principles, 2–5, see also binary search mtrace(), 231 principle; confirmation multiprogramming techniques, principle; top-down approach 145–183 confirmation, 2 client/server network programs, other, 4 145–151 printf(), using with trace code, 3 example, 171–183 printing, variables, 112 parallel applications, 163–171 process tables, defined, 152 threaded code, 151–163 processes, defined, 152 muntrace(), 231 program layout, memory, 118 Pthreads, example, 151 N Python, DDD and Eclipse, 247–251 networks, multiprogramming techniques for client/server R network programs, 145–151 redoing breakpoint actions in DDD, 66 non-int returning functions, 83 reporting, see errors; warnings NOW architectures libraries, 170 S O sample programs inspecting and setting variables, 95, offsets, GDB, 53 109 online help introductory debugging session, about, 19 19–43 OpenMP seg faults, 131–144, 171–183 example, 171–183 setting breakpoints with GDB, 56 true shared memory, 170 threaded code, 153–161 operations, 14–18 saving symbol tables, 21 inspecting variables, 15 The Art of Debugging with GDB, DDD, and Eclipse (C) 2008 by Norman Matloff and Peter Jay Salzman 262 INDEX SDSM (software distributed shared symbol tables, saving, 21 memory), libraries, 170 syntax error messages, phantom line segmentation faults numbers, 185–190 core files, 131 syntax highlighting, text editors, 206 defined, 118 system calls, compared to library determining location, 4 functions, 217 Eclipse, 42 GDB, 32 T memory-access bugs, 124 tables, see process tables; symbol tables Unix signals, 125 tasks, see processes setting temporary breakpoints breakpoints, 51–56 defined, 52 variables, 113 Eclipse, 56 watchpoints, 90 text editors, 206–212 shared memory, defined, 163 as IDEs, 211 shared-memory systems makefiles and compiler warnings, example, 171–183 210 multiprogramming techniques, 170 matching brockets, 208 shells, core files, 130 syntax highlighting, 206 Sieve of Eratosthenes, 153 Vim and makefiles, 209 signal handlers, Unix signals, 126 text section, 118 signals text, GDB, 6 seg faults, 125 versus GUI-based tools, 5–14 Simplified Wrapper and Interface threads Generator (SWIG), using, about, 151 251–254 defined, 153 snprintf(), 143 multiprogramming techniques, sockets, using, 148 151–163 software distributed shared memory top-down approach (SDSM), libraries, 170 about, 4 source code, stepping through, 14 GDB, 29 splint, using, 220–221 stepping, 73 stack frames, 17 trace code, using, 3 stack sections, 119 trees, see binary trees stacks, see call stacks; Intel stacks TUI mode, GDB, 12 startup files, using, 43–45 static code checkers, lint and other tools, 219–221 U static libraries, using, 191 ulimit command, 131 stepping undoing breakpoint actions in DDD, into versus over a function, 72 66 through source code, 14 Unix strace, using, 217–219 signals