وبلاگ بلیان

Debugging with Gdb: The Gnu Source-Level Debugger, for Gdb Version 4.18

معرفی کتاب «Debugging with Gdb: The Gnu Source-Level Debugger, for Gdb Version 4.18» نوشتهٔ Richard M. Stallman, Roland H. Pesch, Stan Shebs, Richard Stallman, Cygnus Solutions، منتشرشده توسط نشر Free Software Foundation در سال 2002. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Debugging with Gdb: The Gnu Source-Level Debugger, for Gdb Version 4.18» در دستهٔ بدون دسته‌بندی قرار دارد.

The GNU Debugger allows you to see what is going on "inside" a program while it executes - or what a program was doing at the moment it crashed.GDB supports C, C++, Java, Fortran and Assembly among other languages; it is also designed to work closely with the GNU Compiler Collection (GCC).The GNU Debugger Program has four special features that helps you catch bugs in the act:\* It starts your program for you, specifying anything that might affect it's behavior.\* Makes your program stop under specified conditions.\* Examines what happened when the program stopped.\* Allows you to experiment with changes to see what effect they have on the program.This book will show you:\* setting and clearing breakpoints\* examining the stack, source files and data\* examining the symbol table\* altering program execution\* specifying a target for debugging\* how to control the debugger\* how to use canned command sequences\* how to install GDB\* and much more!This manual is written for programmers. It is designed so someone can begin utilizing GDB after just reading the first chapter, or read the whole manual and master the program. Synopsis of ideas and extensive examples are given. Debugging with GDB: the GNU Source-Level Debugger 1 Copyright 3 Table of Contents 4 Summary of GDB 12 Ch1 Sample GDB Session 18 Ch2 Getting In & Out of GDB 22 2.1 Invoking GDB 22 2.1.1 Choosing files 23 2.1.2 Choosing modes 24 2.2 Quitting GDB 26 2.3 Shell commands 26 Ch3 GDB Commands 28 3.1 Command syntax 28 3.2 Command completion 28 3.3 Getting help 30 Ch4 Running Programs under GDB 34 4.1 Compiling for debugging 34 4.2 Starting your program 34 4.3 Your program's arguments 35 4.4 Your program's environment 36 4.5 Your program's working directory 37 4.6 Your program's input & output 37 4.7 Debugging already-running process 38 4.8 Killing child process 39 4.9 Debugging programs with multiple threads 39 4.10 Debugging programs with multiple processes 41 Ch5 Stopping & Continuing 44 5.1 Breakpoints, watchpoints & catchpoints 44 5.1.1 Setting breakpoints 45 5.1.2 Setting watchpoints 48 5.1.3 Setting catchpoints 50 5.1.4 Deleting breakpoints 51 5.1.5 Disabling breakpoints 52 5.1.6 Break conditions 53 5.1.7 Breakpoint command lists 54 5.1.8 Breakpoint menus 55 5.1.9 "Cannot insert breakpoints" 56 5.2 Continuing & stepping 56 5.3 Signals 59 5.4 Stopping & starting multi-thread programs 61 Ch6 Examining Stack 64 6.1 Stack frames 64 6.2 Backtraces 65 6.3 Selecting frame 66 6.4 Information about frame 67 Ch7 Examining Source Files 68 7.1 Printing source lines 68 7.2 Searching source files 69 7.3 Specifying source directories 70 7.4 Source & machine code 70 Ch8 Examining Data 74 8.1 Expressions 74 8.2 Program variables 75 8.3 Artificial arrays 76 8.4 Output formats 77 8.5 Examining memory 78 8.6 Automatic display 79 8.7 Print settings 81 8.8 Value history 86 8.9 Convenience variables 87 8.10 Registers 88 8.11 Floating point hardware 89 8.12 Memory region attributes 89 8.12.1 Attributes 90 8.12.1.1 Memory access mode 90 8.12.1.2 Memory access size 90 8.12.1.3 Data cache 91 Ch9 Tracepoints 92 9.1 Commands to Set Tracepoints 92 9.1.1 Create & Delete Tracepoints 92 9.1.2 Enable & Disable Tracepoints 93 9.1.3 Tracepoint Passcounts 93 9.1.4 Tracepoint Action Lists 94 9.1.5 Listing Tracepoints 95 9.1.6 Starting & Stopping Trace Experiment 96 9.2 Using collected data 96 9.2.1 tfind n 96 9.2.2 tdump 98 9.2.3 save-tracepoints filename 99 9.3 Convenience Variables for Tracepoints 99 Ch10 Debugging Programs that Use Overlays 102 10.1 How Overlays Work 102 10.2 Overlay Commands 103 10.3 Automatic Overlay Debugging 105 10.4 Overlay Sample Program 106 Ch11 Using GDB with Different Languages 108 11.1 Switching between source languages 108 11.1.1 List of filename extensions & languages 108 11.1.2 Setting working language 109 11.1.3 Having GDB infer source language 109 11.2 Displaying language 109 11.3 Type & range checking 110 11.3.1 Overview of type checking 110 11.3.2 Overview of range checking 111 11.4 Supported languages 112 11.4.1 C & C++ 113 11.4.1.1 C & C++ operators 113 11.4.1.2 C & C++ constants 115 11.4.1.3 C++ expressions 115 11.4.1.4 C & C++ defaults 116 11.4.1.5 C & C++ type & range checks 116 11.4.1.6 GDB & C 117 11.4.1.7 GDB features for C++ 117 11.4.2 Modula-2 118 11.4.2.1 Operators 118 11.4.2.2 Built-in functions & procedures 120 11.4.2.3 Constants 121 11.4.2.4 Modula-2 defaults 121 11.4.2.5 Deviations from standard Modula-2 121 11.4.2.6 Modula-2 type & range checks 122 11.4.2.7 scope operators :: and . 122 11.4.2.8 GDB & Modula-2 122 11.4.3 Chill 123 11.4.3.1 How modes are displayed 123 11.4.3.2 Locations & their accesses 125 11.4.3.3 Values & their Operations 125 11.4.3.4 Chill type & range checks 127 11.4.3.5 Chill defaults 128 Ch12 Examining Symbol Table 130 Ch13 Altering Execution 134 13.1 Assignment to variables 134 13.2 Continuing at different address 135 13.3 Giving your program a signal 136 13.4 Returning from function 136 13.5 Calling program functions 137 13.6 Patching programs 137 Ch14 GDB Files 138 14.1 Commands to specify files 138 14.2 Errors reading symbol files 143 Ch15 Specifying Debugging Target 146 15.1 Active targets 146 15.2 Commands for managing targets 146 15.3 Choosing target byte order 148 15.4 Remote debugging 148 15.5 Kernel Object Display 149 Ch16 Debugging Remote Programs 150 16.1 Using gdbserver program 150 16.2 Using gdbserve.nlm program 151 16.3 Implementing remote stub 152 16.3.1 What stub can do for you 153 16.3.2 What you must do for stub 153 16.3.3 Putting it all together 155 Ch17 Con guration-Specific Information 158 17.1 Native 158 17.1.1 HP-UX 158 17.1.2 SVR4 process information 158 17.1.3 Features for Debugging DJGPP Programs 158 17.1.4 Features for Debugging MS Windows PE executables 160 17.2 Embedded Operating Systems 161 17.2.1 Using GDB with VxWorks 161 17.2.1.1 Connecting to VxWorks 162 17.2.1.2 VxWorks download 162 17.2.1.3 Running tasks 163 17.3 Embedded Processors 163 17.3.1 ARM 163 17.3.2 Hitachi H8/300 163 17.3.2.1 Connecting to Hitachi boards 164 17.3.2.2 Using E7000 ICE 165 17.3.2.3 Special GDB commands for Hitachi micros 166 17.3.3 H8/500 166 17.3.4 Intel i960 166 17.3.4.1 Startup with Nindy 167 17.3.4.2 Options for Nindy 167 17.3.4.3 Nindy reset command 167 17.3.5 Mitsubishi M32R/D 167 17.3.6 M68k 168 17.3.7 M88K 168 17.3.8 MIPS Embedded 168 17.3.9 PowerPC 170 17.3.10 HP PA Embedded 170 17.3.11 Hitachi SH 170 17.3.12 Tsqware Sparclet 171 17.3.12.1 Setting file to debug 171 17.3.12.2 Connecting to Sparclet 171 17.3.12.3 Sparclet download 172 17.3.12.4 Running & debugging 172 17.3.13 Fujitsu Sparclite 172 17.3.14 Tandem ST2000 172 17.3.15 Zilog Z8000 173 17.4 Architectures 174 17.4.1 A29K 174 17.4.2 Alpha 174 17.4.3 MIPS 174 Ch18 Controlling GDB 176 18.1 Prompt 176 18.2 Command editing 176 18.3 Command history 176 18.4 Screen size 178 18.5 Numbers 178 18.6 Optional warnings & messages 179 18.7 Optional messages about internal happenings 180 Ch19 Canned Sequences of Commands 182 19.1 User-defined commands 182 19.2 User-defined command hooks 183 19.3 Command files 184 19.4 Commands for controlled output 185 Ch20 GDB Text User Interface 188 20.1 TUI overview 188 20.2 TUI Key Bindings 188 20.3 TUI specific commands 189 20.4 TUI configuration variables 190 Ch21 Using GDB under GNU Emacs 192 Ch22 GDB Annotations 194 22.1 What is Annotation? 194 22.2 Server Prefix 194 22.3 Values 195 22.4 Frames 196 22.5 Displays 198 22.6 Annotation for GDB Input 198 22.7 Errors 199 22.8 Information on Breakpoints 199 22.9 Invalidation Notices 200 22.10 Running Program 200 22.11 Displaying Source 201 22.12 Annotations We might Want in Future 201 Ch23 GDB/MI Interface 202 23.1 GDB/MI Command Syntax 202 23.1.1 GDB/MI Input Syntax 202 23.1.2 GDB/MI Output Syntax 203 23.1.3 Simple Examples of GDB/MI Interaction 205 23.2 GDB/MI Compatibility with CLI 206 23.3 GDB/MI Output Records 206 23.3.1 GDB/MI Result Records 206 23.3.2 GDB/MI Stream Records 206 23.3.3 GDB/MI Out-of-Band Records 207 23.4 GDB/MI Command Description Format 207 23.5 GDB/MI Breakpoint table commands 208 23.6 GDB/MI Data Manipulation 216 23.7 GDB/MI Program control 226 23.8 Miscellaneous GDB commands in GDB/MI 236 23.9 GDB/MI Stack Manipulation Commands 238 23.10 GDB/MI Symbol Query Commands 243 23.11 GDB/MI Target Manipulation Commands 246 23.12 GDB/MI Thread Commands 251 23.13 GDB/MI Tracepoint Commands 253 23.14 GDB/MI Variable Objects 253 Ch24 Reporting Bugs in GDB 258 24.1 Have you found a bug? 258 24.2 How to report bugs 258 Ch25 Command Line Editing 262 25.1 Introduction to Line Editing 262 25.2 Readline Interaction 262 25.2.1 Readline Bare Essentials 262 25.2.2 Readline Movement Commands 263 25.2.3 Readline Killing Commands 263 25.2.4 Readline Arguments 264 25.2.5 Searching for Commands in History 264 25.3 Readline Init File 265 25.3.1 Readline Init File Syntax 265 25.3.2 Conditional Init Constructs 269 25.4 Bindable Readline Commands 273 25.4.1 Commands for Moving 273 25.4.2 Commands for Manipulating History 273 25.4.3 Commands for Changing Text 274 25.4.4 Killing & Yanking 275 25.4.5 Specifying Numeric Arguments 276 25.4.6 Letting Readline Type for You 277 25.4.7 Keyboard Macros 277 25.4.8 Some Miscellaneous Commands 278 25.5 Readline vi Mode 279 Ch26 Using History Interactively 280 26.1 History Expansion 280 26.1.1 Event Designators 280 26.1.2 Word Designators 281 26.1.3 Modifiers 281 AppA Formatting Documentation 284 AppB Installing GDB 286 B.1 Compiling GDB in another directory 287 B.2 Specifying names for hosts & targets 288 B.3 Configure options 288 AppC Maintenance Commands 290 AppD GDB Remote Serial Protocol 292 AppE GNU General Public License 304 How to Apply These Terms to Your New Programs 309 AppF GNU Free Documentation License 312 Index 318 Debugging with GDB: the GNU Source-Level Debugger......Page 1 Copyright......Page 3 Table of Contents......Page 4 Summary of GDB......Page 12 Ch1 Sample GDB Session......Page 18 2.1 Invoking GDB......Page 22 2.1.1 Choosing files......Page 23 2.1.2 Choosing modes......Page 24 2.3 Shell commands......Page 26 3.2 Command completion......Page 28 3.3 Getting help......Page 30 4.2 Starting your program......Page 34 4.3 Your program's arguments......Page 35 4.4 Your program's environment......Page 36 4.6 Your program's input & output......Page 37 4.7 Debugging already-running process......Page 38 4.9 Debugging programs with multiple threads......Page 39 4.10 Debugging programs with multiple processes......Page 41 5.1 Breakpoints, watchpoints & catchpoints......Page 44 5.1.1 Setting breakpoints......Page 45 5.1.2 Setting watchpoints......Page 48 5.1.3 Setting catchpoints......Page 50 5.1.4 Deleting breakpoints......Page 51 5.1.5 Disabling breakpoints......Page 52 5.1.6 Break conditions......Page 53 5.1.7 Breakpoint command lists......Page 54 5.1.8 Breakpoint menus......Page 55 5.2 Continuing & stepping......Page 56 5.3 Signals......Page 59 5.4 Stopping & starting multi-thread programs......Page 61 6.1 Stack frames......Page 64 6.2 Backtraces......Page 65 6.3 Selecting frame......Page 66 6.4 Information about frame......Page 67 7.1 Printing source lines......Page 68 7.2 Searching source files......Page 69 7.4 Source & machine code......Page 70 8.1 Expressions......Page 74 8.2 Program variables......Page 75 8.3 Artificial arrays......Page 76 8.4 Output formats......Page 77 8.5 Examining memory......Page 78 8.6 Automatic display......Page 79 8.7 Print settings......Page 81 8.8 Value history......Page 86 8.9 Convenience variables......Page 87 8.10 Registers......Page 88 8.12 Memory region attributes......Page 89 8.12.1.2 Memory access size......Page 90 8.12.1.3 Data cache......Page 91 9.1.1 Create & Delete Tracepoints......Page 92 9.1.3 Tracepoint Passcounts......Page 93 9.1.4 Tracepoint Action Lists......Page 94 9.1.5 Listing Tracepoints......Page 95 9.2.1 tfind n......Page 96 9.2.2 tdump......Page 98 9.3 Convenience Variables for Tracepoints......Page 99 10.1 How Overlays Work......Page 102 10.2 Overlay Commands......Page 103 10.3 Automatic Overlay Debugging......Page 105 10.4 Overlay Sample Program......Page 106 11.1.1 List of filename extensions & languages......Page 108 11.2 Displaying language......Page 109 11.3.1 Overview of type checking......Page 110 11.3.2 Overview of range checking......Page 111 11.4 Supported languages......Page 112 11.4.1.1 C & C++ operators......Page 113 11.4.1.3 C++ expressions......Page 115 11.4.1.5 C & C++ type & range checks......Page 116 11.4.1.7 GDB features for C++......Page 117 11.4.2.1 Operators......Page 118 11.4.2.2 Built-in functions & procedures......Page 120 11.4.2.5 Deviations from standard Modula-2......Page 121 11.4.2.8 GDB & Modula-2......Page 122 11.4.3.1 How modes are displayed......Page 123 11.4.3.3 Values & their Operations......Page 125 11.4.3.4 Chill type & range checks......Page 127 11.4.3.5 Chill defaults......Page 128 Ch12 Examining Symbol Table......Page 130 13.1 Assignment to variables......Page 134 13.2 Continuing at different address......Page 135 13.4 Returning from function......Page 136 13.6 Patching programs......Page 137 14.1 Commands to specify files......Page 138 14.2 Errors reading symbol files......Page 143 15.2 Commands for managing targets......Page 146 15.4 Remote debugging......Page 148 15.5 Kernel Object Display......Page 149 16.1 Using gdbserver program......Page 150 16.2 Using gdbserve.nlm program......Page 151 16.3 Implementing remote stub......Page 152 16.3.2 What you must do for stub......Page 153 16.3.3 Putting it all together......Page 155 17.1.3 Features for Debugging DJGPP Programs......Page 158 17.1.4 Features for Debugging MS Windows PE executables......Page 160 17.2.1 Using GDB with VxWorks......Page 161 17.2.1.2 VxWorks download......Page 162 17.3.2 Hitachi H8/300......Page 163 17.3.2.1 Connecting to Hitachi boards......Page 164 17.3.2.2 Using E7000 ICE......Page 165 17.3.4 Intel i960......Page 166 17.3.5 Mitsubishi M32R/D......Page 167 17.3.8 MIPS Embedded......Page 168 17.3.11 Hitachi SH......Page 170 17.3.12.2 Connecting to Sparclet......Page 171 17.3.14 Tandem ST2000......Page 172 17.3.15 Zilog Z8000......Page 173 17.4.3 MIPS......Page 174 18.3 Command history......Page 176 18.5 Numbers......Page 178 18.6 Optional warnings & messages......Page 179 18.7 Optional messages about internal happenings......Page 180 19.1 User-defined commands......Page 182 19.2 User-defined command hooks......Page 183 19.3 Command files......Page 184 19.4 Commands for controlled output......Page 185 20.2 TUI Key Bindings......Page 188 20.3 TUI specific commands......Page 189 20.4 TUI configuration variables......Page 190 Ch21 Using GDB under GNU Emacs......Page 192 22.2 Server Prefix......Page 194 22.3 Values......Page 195 22.4 Frames......Page 196 22.6 Annotation for GDB Input......Page 198 22.8 Information on Breakpoints......Page 199 22.10 Running Program......Page 200 22.12 Annotations We might Want in Future......Page 201 23.1.1 GDB/MI Input Syntax......Page 202 23.1.2 GDB/MI Output Syntax......Page 203 23.1.3 Simple Examples of GDB/MI Interaction......Page 205 23.3.2 GDB/MI Stream Records......Page 206 23.4 GDB/MI Command Description Format......Page 207 23.5 GDB/MI Breakpoint table commands......Page 208 23.6 GDB/MI Data Manipulation......Page 216 23.7 GDB/MI Program control......Page 226 23.8 Miscellaneous GDB commands in GDB/MI......Page 236 23.9 GDB/MI Stack Manipulation Commands......Page 238 23.10 GDB/MI Symbol Query Commands......Page 243 23.11 GDB/MI Target Manipulation Commands......Page 246 23.12 GDB/MI Thread Commands......Page 251 23.14 GDB/MI Variable Objects......Page 253 24.2 How to report bugs......Page 258 25.2.1 Readline Bare Essentials......Page 262 25.2.3 Readline Killing Commands......Page 263 25.2.5 Searching for Commands in History......Page 264 25.3.1 Readline Init File Syntax......Page 265 25.3.2 Conditional Init Constructs......Page 269 25.4.2 Commands for Manipulating History......Page 273 25.4.3 Commands for Changing Text......Page 274 25.4.4 Killing & Yanking......Page 275 25.4.5 Specifying Numeric Arguments......Page 276 25.4.7 Keyboard Macros......Page 277 25.4.8 Some Miscellaneous Commands......Page 278 25.5 Readline vi Mode......Page 279 26.1.1 Event Designators......Page 280 26.1.3 Modifiers......Page 281 AppA Formatting Documentation......Page 284 AppB Installing GDB......Page 286 B.1 Compiling GDB in another directory......Page 287 B.3 Configure options......Page 288 AppC Maintenance Commands......Page 290 AppD GDB Remote Serial Protocol......Page 292 AppE GNU General Public License......Page 304 How to Apply These Terms to Your New Programs......Page 309 AppF GNU Free Documentation License......Page 312 Index......Page 318 The GNU Debugger allows you to see what is going on "inside" a program while it executes - or what a program was doing at the moment it crashed. GDB supports C, C++, Java, Fortran and Assembly among other languages; it is also designed to work closely with the GNU Compiler Collection (GCC). The GNU Debugger Program has four special features that helps you catch bugs in the * It starts your program for you, specifying anything that might affect it's behavior. * Makes your program stop under specified conditions. * Examines what happened when the program stopped. * Allows you to experiment with changes to see what effect they have on the program. This book will show * setting and clearing breakpoints * examining the stack, source files and data * examining the symbol table * altering program execution * specifying a target for debugging * how to control the debugger * how to use canned command sequences * how to install GDB * and much more! This manual is written for programmers. It is designed so someone can begin utilizing GDB after just reading the first chapter, or read the whole manual and master the program. Synopsis of ideas and extensive examples are given. Summary of GDB A Sample GDB Session Getting In and Out of GDB GDB Commands Running Programs Under GDB Stopping and Continuing Examining the Stack Examining Source Files Examining Data Tracepoints Using GDB in Different Languages Examining the Symbol Table Altering Execution GDB Files Specifying a Debugging Target Configuration-Specific Information Controlling GDB Canned Sequences of Commands GDB Text User Interface Using GDB under GNU Emacs GDB Annotations The GDB/MI Interface Reporting Bugs in GDB Command Line Editing Using History Interactively Formatting Documentation Installing GDB GNU Free Documentation License Index
دانلود کتاب Debugging with Gdb: The Gnu Source-Level Debugger, for Gdb Version 4.18