Debugging with Gdb the Gnu Source-Level Debugger

Debugging with Gdb the Gnu Source-Level Debugger

Debugging with gdb The gnu Source-Level Debugger Tenth Edition, for gdb version 8.0.50.20171128-git (GNU Tools for Arm Embedded Processors 7-2017-q4-major) Richard Stallman, Roland Pesch, Stan Shebs, et al. (Send bugs and comments on gdb to http://www.gnu.org/software/gdb/bugs/.) Debugging with gdb TEXinfo 2013-09-11.11 Published by the Free Software Foundation 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ISBN 978-0-9831592-3-0 Copyright c 1988-2017 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being \Free Software" and \Free Software Needs Free Documentation", with the Front-Cover Texts being \A GNU Manual," and with the Back-Cover Texts as in (a) below. (a) The FSF's Back-Cover Text is: \You are free to copy and modify this GNU Man- ual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom." i Table of Contents Summary of gdb :::::::::::::::::::::::::::::::::::: 1 Free Software ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 Free Software Needs Free Documentation :::::::::::::::::::::::::::: 1 Contributors to gdb::::::::::::::::::::::::::::::::::::::::::::::::: 3 1 A Sample gdb Session :::::::::::::::::::::::::: 7 2 Getting In and Out of gdb ::::::::::::::::::: 11 2.1 Invoking gdb ::::::::::::::::::::::::::::::::::::::::::::::::: 11 2.1.1 Choosing Files ::::::::::::::::::::::::::::::::::::::::::: 12 2.1.2 Choosing Modes ::::::::::::::::::::::::::::::::::::::::: 13 2.1.3 What gdb Does During Startup :::::::::::::::::::::::::: 16 2.2 Quitting gdb ::::::::::::::::::::::::::::::::::::::::::::::::: 17 2.3 Shell Commands :::::::::::::::::::::::::::::::::::::::::::::: 17 2.4 Logging Output ::::::::::::::::::::::::::::::::::::::::::::::: 18 3 gdb Commands :::::::::::::::::::::::::::::::: 19 3.1 Command Syntax ::::::::::::::::::::::::::::::::::::::::::::: 19 3.2 Command Completion :::::::::::::::::::::::::::::::::::::::: 19 3.3 Getting Help :::::::::::::::::::::::::::::::::::::::::::::::::: 22 4 Running Programs Under gdb ::::::::::::::: 25 4.1 Compiling for Debugging :::::::::::::::::::::::::::::::::::::: 25 4.2 Starting your Program :::::::::::::::::::::::::::::::::::::::: 26 4.3 Your Program's Arguments ::::::::::::::::::::::::::::::::::: 30 4.4 Your Program's Environment:::::::::::::::::::::::::::::::::: 30 4.5 Your Program's Working Directory :::::::::::::::::::::::::::: 31 4.6 Your Program's Input and Output :::::::::::::::::::::::::::: 32 4.7 Debugging an Already-running Process :::::::::::::::::::::::: 33 4.8 Killing the Child Process :::::::::::::::::::::::::::::::::::::: 34 4.9 Debugging Multiple Inferiors and Programs:::::::::::::::::::: 34 4.10 Debugging Programs with Multiple Threads :::::::::::::::::: 37 4.11 Debugging Forks ::::::::::::::::::::::::::::::::::::::::::::: 41 4.12 Setting a Bookmark to Return to Later::::::::::::::::::::::: 43 4.12.1 A Non-obvious Benefit of Using Checkpoints::::::::::::: 45 ii Debugging with gdb 5 Stopping and Continuing ::::::::::::::::::::: 47 5.1 Breakpoints, Watchpoints, and Catchpoints ::::::::::::::::::: 47 5.1.1 Setting Breakpoints :::::::::::::::::::::::::::::::::::::: 48 5.1.2 Setting Watchpoints:::::::::::::::::::::::::::::::::::::: 54 5.1.3 Setting Catchpoints :::::::::::::::::::::::::::::::::::::: 56 5.1.4 Deleting Breakpoints ::::::::::::::::::::::::::::::::::::: 61 5.1.5 Disabling Breakpoints :::::::::::::::::::::::::::::::::::: 62 5.1.6 Break Conditions::::::::::::::::::::::::::::::::::::::::: 63 5.1.7 Breakpoint Command Lists :::::::::::::::::::::::::::::: 64 5.1.8 Dynamic Printf :::::::::::::::::::::::::::::::::::::::::: 66 5.1.9 How to save breakpoints to a file ::::::::::::::::::::::::: 67 5.1.10 Static Probe Points ::::::::::::::::::::::::::::::::::::: 67 5.1.11 \Cannot insert breakpoints"::::::::::::::::::::::::::::: 69 5.1.12 \Breakpoint address adjusted..." :::::::::::::::::::::::: 69 5.2 Continuing and Stepping :::::::::::::::::::::::::::::::::::::: 70 5.3 Skipping Over Functions and Files :::::::::::::::::::::::::::: 73 5.4 Signals:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 76 5.5 Stopping and Starting Multi-thread Programs ::::::::::::::::: 79 5.5.1 All-Stop Mode ::::::::::::::::::::::::::::::::::::::::::: 79 5.5.2 Non-Stop Mode :::::::::::::::::::::::::::::::::::::::::: 80 5.5.3 Background Execution ::::::::::::::::::::::::::::::::::: 81 5.5.4 Thread-Specific Breakpoints :::::::::::::::::::::::::::::: 82 5.5.5 Interrupted System Calls ::::::::::::::::::::::::::::::::: 83 5.5.6 Observer Mode::::::::::::::::::::::::::::::::::::::::::: 84 6 Running programs backward ::::::::::::::::: 87 7 Recording Inferior's Execution and Replaying It :::::::::::::::::::::::::::::::::::::::::::::: 89 8 Examining the Stack :::::::::::::::::::::::::: 97 8.1 Stack Frames ::::::::::::::::::::::::::::::::::::::::::::::::: 97 8.2 Backtraces :::::::::::::::::::::::::::::::::::::::::::::::::::: 98 8.3 Selecting a Frame :::::::::::::::::::::::::::::::::::::::::::: 100 8.4 Information About a Frame :::::::::::::::::::::::::::::::::: 101 8.5 Management of Frame Filters.:::::::::::::::::::::::::::::::: 102 iii 9 Examining Source Files :::::::::::::::::::::: 105 9.1 Printing Source Lines :::::::::::::::::::::::::::::::::::::::: 105 9.2 Specifying a Location :::::::::::::::::::::::::::::::::::::::: 106 9.2.1 Linespec Locations :::::::::::::::::::::::::::::::::::::: 106 9.2.2 Explicit Locations::::::::::::::::::::::::::::::::::::::: 107 9.2.3 Address Locations::::::::::::::::::::::::::::::::::::::: 108 9.3 Editing Source Files:::::::::::::::::::::::::::::::::::::::::: 108 9.3.1 Choosing your Editor ::::::::::::::::::::::::::::::::::: 109 9.4 Searching Source Files ::::::::::::::::::::::::::::::::::::::: 109 9.5 Specifying Source Directories ::::::::::::::::::::::::::::::::: 109 9.6 Source and Machine Code :::::::::::::::::::::::::::::::::::: 112 10 Examining Data::::::::::::::::::::::::::::: 117 10.1 Expressions ::::::::::::::::::::::::::::::::::::::::::::::::: 119 10.2 Ambiguous Expressions ::::::::::::::::::::::::::::::::::::: 120 10.3 Program Variables :::::::::::::::::::::::::::::::::::::::::: 121 10.4 Artificial Arrays :::::::::::::::::::::::::::::::::::::::::::: 124 10.5 Output Formats :::::::::::::::::::::::::::::::::::::::::::: 124 10.6 Examining Memory ::::::::::::::::::::::::::::::::::::::::: 126 10.7 Automatic Display :::::::::::::::::::::::::::::::::::::::::: 128 10.8 Print Settings::::::::::::::::::::::::::::::::::::::::::::::: 130 10.9 Pretty Printing ::::::::::::::::::::::::::::::::::::::::::::: 138 10.9.1 Pretty-Printer Introduction :::::::::::::::::::::::::::: 138 10.9.2 Pretty-Printer Example :::::::::::::::::::::::::::::::: 139 10.9.3 Pretty-Printer Commands:::::::::::::::::::::::::::::: 139 10.10 Value History:::::::::::::::::::::::::::::::::::::::::::::: 140 10.11 Convenience Variables ::::::::::::::::::::::::::::::::::::: 141 10.12 Convenience Functions::::::::::::::::::::::::::::::::::::: 144 10.13 Registers :::::::::::::::::::::::::::::::::::::::::::::::::: 146 10.14 Floating Point Hardware::::::::::::::::::::::::::::::::::: 148 10.15 Vector Unit:::::::::::::::::::::::::::::::::::::::::::::::: 148 10.16 Operating System Auxiliary Information ::::::::::::::::::: 148 10.17 Memory Region Attributes::::::::::::::::::::::::::::::::: 150 10.17.1 Attributes :::::::::::::::::::::::::::::::::::::::::::: 151 10.17.1.1 Memory Access Mode :::::::::::::::::::::::::::: 151 10.17.1.2 Memory Access Size:::::::::::::::::::::::::::::: 152 10.17.1.3 Data Cache :::::::::::::::::::::::::::::::::::::: 152 10.17.2 Memory Access Checking ::::::::::::::::::::::::::::: 152 10.18 Copy Between Memory and a File ::::::::::::::::::::::::: 152 10.19 How to Produce a Core File from Your Program ::::::::::: 153 10.20 Character Sets::::::::::::::::::::::::::::::::::::::::::::: 154 10.21 Caching Data of Targets ::::::::::::::::::::::::::::::::::: 157 10.22 Search Memory :::::::::::::::::::::::::::::::::::::::::::: 158 10.23 Value Sizes :::::::::::::::::::::::::::::::::::::::::::::::: 159 11 Debugging Optimized Code :::::::::::::::: 161 11.1 Inline Functions :::::::::::::::::::::::::::::::::::::::::::: 161 11.2 Tail Call Frames :::::::::::::::::::::::::::::::::::::::::::: 162 iv Debugging with gdb 12 C Preprocessor Macros::::::::::::::::::::: 165 13 Tracepoints :::::::::::::::::::::::::::::::::: 169 13.1 Commands to Set Tracepoints :::::::::::::::::::::::::::::: 169 13.1.1 Create and Delete Tracepoints ::::::::::::::::::::::::: 170 13.1.2 Enable and Disable Tracepoints :::::::::::::::::::::::: 172 13.1.3 Tracepoint Passcounts ::::::::::::::::::::::::::::::::: 172 13.1.4 Tracepoint Conditions:::::::::::::::::::::::::::::::::: 173 13.1.5 Trace State Variables :::::::::::::::::::::::::::::::::: 173 13.1.6 Tracepoint Action Lists :::::::::::::::::::::::::::::::: 174 13.1.7 Listing Tracepoints :::::::::::::::::::::::::::::::::::: 176 13.1.8 Listing Static Tracepoint Markers :::::::::::::::::::::: 177 13.1.9 Starting and Stopping Trace Experiments :::::::::::::: 178 13.1.10 Tracepoint Restrictions ::::::::::::::::::::::::::::::: 180 13.2 Using the Collected Data ::::::::::::::::::::::::::::::::::: 181 13.2.1 tfind n:::::::::::::::::::::::::::::::::::::::::::::::: 181 13.2.2 tdump:::::::::::::::::::::::::::::::::::::::::::::::::: 183 13.2.3 save tracepoints filename ::::::::::::::::::::::::::: 184 13.3 Convenience Variables

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    810 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us