| OLD | NEW |
| 1 This is gdb.info, produced by makeinfo version 4.8 from ./gdb.texinfo. | 1 This is gdb.info, produced by makeinfo version 4.8 from ./gdb.texinfo. |
| 2 | 2 |
| 3 INFO-DIR-SECTION Software development | 3 INFO-DIR-SECTION Software development |
| 4 START-INFO-DIR-ENTRY | 4 START-INFO-DIR-ENTRY |
| 5 * Gdb: (gdb). The GNU debugger. | 5 * Gdb: (gdb). The GNU debugger. |
| 6 END-INFO-DIR-ENTRY | 6 END-INFO-DIR-ENTRY |
| 7 | 7 |
| 8 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, | 8 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
| 9 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, | 9 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
| 10 2010 Free Software Foundation, Inc. | 10 2010 2011, 2012 Free Software Foundation, Inc. |
| 11 | 11 |
| 12 Permission is granted to copy, distribute and/or modify this document | 12 Permission is granted to copy, distribute and/or modify this document |
| 13 under the terms of the GNU Free Documentation License, Version 1.3 or | 13 under the terms of the GNU Free Documentation License, Version 1.3 or |
| 14 any later version published by the Free Software Foundation; with the | 14 any later version published by the Free Software Foundation; with the |
| 15 Invariant Sections being "Free Software" and "Free Software Needs Free | 15 Invariant Sections being "Free Software" and "Free Software Needs Free |
| 16 Documentation", with the Front-Cover Texts being "A GNU Manual," and | 16 Documentation", with the Front-Cover Texts being "A GNU Manual," and |
| 17 with the Back-Cover Texts as in (a) below. | 17 with the Back-Cover Texts as in (a) below. |
| 18 | 18 |
| 19 (a) The FSF's Back-Cover Text is: "You are free to copy and modify | 19 (a) The FSF's Back-Cover Text is: "You are free to copy and modify |
| 20 this GNU Manual. Buying copies from GNU Press supports the FSF in | 20 this GNU Manual. Buying copies from GNU Press supports the FSF in |
| 21 developing GNU and promoting software freedom." | 21 developing GNU and promoting software freedom." |
| 22 | 22 |
| 23 This file documents the GNU debugger GDB. | 23 This file documents the GNU debugger GDB. |
| 24 | 24 |
| 25 This is the Tenth Edition, of `Debugging with GDB: the GNU | 25 This is the Tenth Edition, of `Debugging with GDB: the GNU |
| 26 Source-Level Debugger' for GDB (GDB) Version 7.4.1. | 26 Source-Level Debugger' for GDB (GDB) Version 7.5.1. |
| 27 | 27 |
| 28 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, | 28 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
| 29 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, | 29 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
| 30 2010 Free Software Foundation, Inc. | 30 2010 2011, 2012 Free Software Foundation, Inc. |
| 31 | 31 |
| 32 Permission is granted to copy, distribute and/or modify this document | 32 Permission is granted to copy, distribute and/or modify this document |
| 33 under the terms of the GNU Free Documentation License, Version 1.3 or | 33 under the terms of the GNU Free Documentation License, Version 1.3 or |
| 34 any later version published by the Free Software Foundation; with the | 34 any later version published by the Free Software Foundation; with the |
| 35 Invariant Sections being "Free Software" and "Free Software Needs Free | 35 Invariant Sections being "Free Software" and "Free Software Needs Free |
| 36 Documentation", with the Front-Cover Texts being "A GNU Manual," and | 36 Documentation", with the Front-Cover Texts being "A GNU Manual," and |
| 37 with the Back-Cover Texts as in (a) below. | 37 with the Back-Cover Texts as in (a) below. |
| 38 | 38 |
| 39 (a) The FSF's Back-Cover Text is: "You are free to copy and modify | 39 (a) The FSF's Back-Cover Text is: "You are free to copy and modify |
| 40 this GNU Manual. Buying copies from GNU Press supports the FSF in | 40 this GNU Manual. Buying copies from GNU Press supports the FSF in |
| 41 developing GNU and promoting software freedom." | 41 developing GNU and promoting software freedom." |
| 42 | 42 |
| 43 | 43 |
| 44 File: gdb.info, Node: Top, Next: Summary, Prev: (dir), Up: (dir) | 44 File: gdb.info, Node: Top, Next: Summary, Prev: (dir), Up: (dir) |
| 45 | 45 |
| 46 Debugging with GDB | 46 Debugging with GDB |
| 47 ****************** | 47 ****************** |
| 48 | 48 |
| 49 This file describes GDB, the GNU symbolic debugger. | 49 This file describes GDB, the GNU symbolic debugger. |
| 50 | 50 |
| 51 This is the Tenth Edition, for GDB (GDB) Version 7.4.1. | 51 This is the Tenth Edition, for GDB (GDB) Version 7.5.1. |
| 52 | 52 |
| 53 Copyright (C) 1988-2010 Free Software Foundation, Inc. | 53 Copyright (C) 1988-2012 Free Software Foundation, Inc. |
| 54 | 54 |
| 55 This edition of the GDB manual is dedicated to the memory of Fred | 55 This edition of the GDB manual is dedicated to the memory of Fred |
| 56 Fish. Fred was a long-standing contributor to GDB and to Free software | 56 Fish. Fred was a long-standing contributor to GDB and to Free software |
| 57 in general. We will miss him. | 57 in general. We will miss him. |
| 58 | 58 |
| 59 * Menu: | 59 * Menu: |
| 60 | 60 |
| 61 * Summary:: Summary of GDB | 61 * Summary:: Summary of GDB |
| 62 * Sample Session:: A sample GDB session | 62 * Sample Session:: A sample GDB session |
| 63 | 63 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 84 * Remote Debugging:: Debugging remote programs | 84 * Remote Debugging:: Debugging remote programs |
| 85 * Configurations:: Configuration-specific information | 85 * Configurations:: Configuration-specific information |
| 86 * Controlling GDB:: Controlling GDB | 86 * Controlling GDB:: Controlling GDB |
| 87 * Extending GDB:: Extending GDB | 87 * Extending GDB:: Extending GDB |
| 88 * Interpreters:: Command Interpreters | 88 * Interpreters:: Command Interpreters |
| 89 * TUI:: GDB Text User Interface | 89 * TUI:: GDB Text User Interface |
| 90 * Emacs:: Using GDB under GNU Emacs | 90 * Emacs:: Using GDB under GNU Emacs |
| 91 * GDB/MI:: GDB's Machine Interface. | 91 * GDB/MI:: GDB's Machine Interface. |
| 92 * Annotations:: GDB's annotation interface. | 92 * Annotations:: GDB's annotation interface. |
| 93 * JIT Interface:: Using the JIT debugging interface. | 93 * JIT Interface:: Using the JIT debugging interface. |
| 94 * In-Process Agent:: In-Process Agent |
| 94 | 95 |
| 95 * GDB Bugs:: Reporting bugs in GDB | 96 * GDB Bugs:: Reporting bugs in GDB |
| 96 | 97 |
| 97 | 98 |
| 98 * Command Line Editing:: Command Line Editing | 99 * Command Line Editing:: Command Line Editing |
| 99 * Using History Interactively:: Using History Interactively | 100 * Using History Interactively:: Using History Interactively |
| 100 * In Memoriam:: In Memoriam | 101 * In Memoriam:: In Memoriam |
| 101 * Formatting Documentation:: How to format and print GDB documentation | 102 * Formatting Documentation:: How to format and print GDB documentation |
| 102 * Installing GDB:: Installing GDB | 103 * Installing GDB:: Installing GDB |
| 103 * Maintenance Commands:: Maintenance Commands | 104 * Maintenance Commands:: Maintenance Commands |
| 104 * Remote Protocol:: GDB Remote Serial Protocol | 105 * Remote Protocol:: GDB Remote Serial Protocol |
| 105 * Agent Expressions:: The GDB Agent Expression Mechanism | 106 * Agent Expressions:: The GDB Agent Expression Mechanism |
| 106 * Target Descriptions:: How targets can describe themselves to | 107 * Target Descriptions:: How targets can describe themselves to |
| 107 GDB | 108 GDB |
| 108 * Operating System Information:: Getting additional information from | 109 * Operating System Information:: Getting additional information from |
| 109 the operating system | 110 the operating system |
| 110 * Trace File Format:: GDB trace file format | 111 * Trace File Format:: GDB trace file format |
| 111 * Index Section Format:: .gdb_index section format | 112 * Index Section Format:: .gdb_index section format |
| 112 * Copying:: GNU General Public License says | 113 * Copying:: GNU General Public License says |
| 113 how you can copy and share GDB | 114 how you can copy and share GDB |
| 114 * GNU Free Documentation License:: The license for this documentation | 115 * GNU Free Documentation License:: The license for this documentation |
| 115 * Index:: Index | 116 * Concept Index:: Index of GDB concepts |
| 117 * Command and Variable Index:: Index of GDB commands, variables, |
| 118 functions, and Python data types |
| 116 | 119 |
| 117 | 120 |
| 118 File: gdb.info, Node: Summary, Next: Sample Session, Prev: Top, Up: Top | 121 File: gdb.info, Node: Summary, Next: Sample Session, Prev: Top, Up: Top |
| 119 | 122 |
| 120 Summary of GDB | 123 Summary of GDB |
| 121 ************** | 124 ************** |
| 122 | 125 |
| 123 The purpose of a debugger such as GDB is to allow you to see what is | 126 The purpose of a debugger such as GDB is to allow you to see what is |
| 124 going on "inside" another program while it executes--or what another | 127 going on "inside" another program while it executes--or what another |
| 125 program was doing at the moment it crashed. | 128 program was doing at the moment it crashed. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 156 | 159 |
| 157 GDB can be used to debug programs written in Fortran, although it | 160 GDB can be used to debug programs written in Fortran, although it |
| 158 may be necessary to refer to some variables with a trailing underscore. | 161 may be necessary to refer to some variables with a trailing underscore. |
| 159 | 162 |
| 160 GDB can be used to debug programs written in Objective-C, using | 163 GDB can be used to debug programs written in Objective-C, using |
| 161 either the Apple/NeXT or the GNU Objective-C runtime. | 164 either the Apple/NeXT or the GNU Objective-C runtime. |
| 162 | 165 |
| 163 * Menu: | 166 * Menu: |
| 164 | 167 |
| 165 * Free Software:: Freely redistributable software | 168 * Free Software:: Freely redistributable software |
| 169 * Free Documentation:: Free Software Needs Free Documentation |
| 166 * Contributors:: Contributors to GDB | 170 * Contributors:: Contributors to GDB |
| 167 | 171 |
| 168 | 172 |
| 169 File: gdb.info, Node: Free Software, Next: Contributors, Up: Summary | 173 File: gdb.info, Node: Free Software, Next: Free Documentation, Up: Summary |
| 170 | 174 |
| 171 Free Software | 175 Free Software |
| 172 ============= | 176 ============= |
| 173 | 177 |
| 174 GDB is "free software", protected by the GNU General Public License | 178 GDB is "free software", protected by the GNU General Public License |
| 175 (GPL). The GPL gives you the freedom to copy or adapt a licensed | 179 (GPL). The GPL gives you the freedom to copy or adapt a licensed |
| 176 program--but every person getting a copy also gets with it the freedom | 180 program--but every person getting a copy also gets with it the freedom |
| 177 to modify that copy (which means that they must get access to the | 181 to modify that copy (which means that they must get access to the |
| 178 source code), and the freedom to distribute further copies. Typical | 182 source code), and the freedom to distribute further copies. Typical |
| 179 software companies use copyrights to limit your freedoms; the Free | 183 software companies use copyrights to limit your freedoms; the Free |
| 180 Software Foundation uses the GPL to preserve these freedoms. | 184 Software Foundation uses the GPL to preserve these freedoms. |
| 181 | 185 |
| 182 Fundamentally, the General Public License is a license which says | 186 Fundamentally, the General Public License is a license which says |
| 183 that you have these freedoms and that you cannot take these freedoms | 187 that you have these freedoms and that you cannot take these freedoms |
| 184 away from anyone else. | 188 away from anyone else. |
| 185 | 189 |
| 190 |
| 191 File: gdb.info, Node: Free Documentation, Next: Contributors, Prev: Free Soft
ware, Up: Summary |
| 192 |
| 186 Free Software Needs Free Documentation | 193 Free Software Needs Free Documentation |
| 187 ====================================== | 194 ====================================== |
| 188 | 195 |
| 189 The biggest deficiency in the free software community today is not in | 196 The biggest deficiency in the free software community today is not in |
| 190 the software--it is the lack of good free documentation that we can | 197 the software--it is the lack of good free documentation that we can |
| 191 include with the free software. Many of our most important programs do | 198 include with the free software. Many of our most important programs do |
| 192 not come with free reference manuals and free introductory texts. | 199 not come with free reference manuals and free introductory texts. |
| 193 Documentation is an essential part of any software package; when an | 200 Documentation is an essential part of any software package; when an |
| 194 important free software package does not come with a free manual and a | 201 important free software package does not come with a free manual and a |
| 195 free tutorial, that is a major gap. We have many such gaps today. | 202 free tutorial, that is a major gap. We have many such gaps today. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 all. Check the distribution terms of a manual before you buy it, and | 273 all. Check the distribution terms of a manual before you buy it, and |
| 267 insist that whoever seeks your business must respect your freedom. | 274 insist that whoever seeks your business must respect your freedom. |
| 268 Check the history of the book, and try to reward the publishers that | 275 Check the history of the book, and try to reward the publishers that |
| 269 have paid or pay the authors to work on it. | 276 have paid or pay the authors to work on it. |
| 270 | 277 |
| 271 The Free Software Foundation maintains a list of free documentation | 278 The Free Software Foundation maintains a list of free documentation |
| 272 published by other publishers, at | 279 published by other publishers, at |
| 273 `http://www.fsf.org/doc/other-free-books.html'. | 280 `http://www.fsf.org/doc/other-free-books.html'. |
| 274 | 281 |
| 275 | 282 |
| 276 File: gdb.info, Node: Contributors, Prev: Free Software, Up: Summary | 283 File: gdb.info, Node: Contributors, Prev: Free Documentation, Up: Summary |
| 277 | 284 |
| 278 Contributors to GDB | 285 Contributors to GDB |
| 279 =================== | 286 =================== |
| 280 | 287 |
| 281 Richard Stallman was the original author of GDB, and of many other GNU | 288 Richard Stallman was the original author of GDB, and of many other GNU |
| 282 programs. Many others have contributed to its development. This | 289 programs. Many others have contributed to its development. This |
| 283 section attempts to credit major contributors. One of the virtues of | 290 section attempts to credit major contributors. One of the virtues of |
| 284 free software is that everyone is free to contribute to it; with | 291 free software is that everyone is free to contribute to it; with |
| 285 regret, we cannot actually acknowledge everyone here. The file | 292 regret, we cannot actually acknowledge everyone here. The file |
| 286 `ChangeLog' in the GDB distribution approximates a blow-by-blow account. | 293 `ChangeLog' in the GDB distribution approximates a blow-by-blow account. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 489 |
| 483 Let us use GDB to try to see what is going on. | 490 Let us use GDB to try to see what is going on. |
| 484 | 491 |
| 485 $ gdb m4 | 492 $ gdb m4 |
| 486 GDB is free software and you are welcome to distribute copies | 493 GDB is free software and you are welcome to distribute copies |
| 487 of it under certain conditions; type "show copying" to see | 494 of it under certain conditions; type "show copying" to see |
| 488 the conditions. | 495 the conditions. |
| 489 There is absolutely no warranty for GDB; type "show warranty" | 496 There is absolutely no warranty for GDB; type "show warranty" |
| 490 for details. | 497 for details. |
| 491 | 498 |
| 492 GDB 7.4.1, Copyright 1999 Free Software Foundation, Inc... | 499 GDB 7.5.1, Copyright 1999 Free Software Foundation, Inc... |
| 493 (gdb) | 500 (gdb) |
| 494 | 501 |
| 495 GDB reads only enough symbol data to know where to find the rest when | 502 GDB reads only enough symbol data to know where to find the rest when |
| 496 needed; as a result, the first prompt comes up very quickly. We now | 503 needed; as a result, the first prompt comes up very quickly. We now |
| 497 tell GDB to use a narrower display width than usual, so that examples | 504 tell GDB to use a narrower display width than usual, so that examples |
| 498 fit in this manual. | 505 fit in this manual. |
| 499 | 506 |
| 500 (gdb) set width 70 | 507 (gdb) set width 70 |
| 501 | 508 |
| 502 We need to see how the `m4' built-in `changequote' works. Having | 509 We need to see how the `m4' built-in `changequote' works. Having |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 `-eval-command COMMAND' | 810 `-eval-command COMMAND' |
| 804 `-ex COMMAND' | 811 `-ex COMMAND' |
| 805 Execute a single GDB command. | 812 Execute a single GDB command. |
| 806 | 813 |
| 807 This option may be used multiple times to call multiple commands. | 814 This option may be used multiple times to call multiple commands. |
| 808 It may also be interleaved with `-command' as required. | 815 It may also be interleaved with `-command' as required. |
| 809 | 816 |
| 810 gdb -ex 'target sim' -ex 'load' \ | 817 gdb -ex 'target sim' -ex 'load' \ |
| 811 -x setbreakpoints -ex 'run' a.out | 818 -x setbreakpoints -ex 'run' a.out |
| 812 | 819 |
| 820 `-init-command FILE' |
| 821 `-ix FILE' |
| 822 Execute commands from file FILE before loading the inferior (but |
| 823 after loading gdbinit files). *Note Startup::. |
| 824 |
| 825 `-init-eval-command COMMAND' |
| 826 `-iex COMMAND' |
| 827 Execute a single GDB command before loading the inferior (but |
| 828 after loading gdbinit files). *Note Startup::. |
| 829 |
| 813 `-directory DIRECTORY' | 830 `-directory DIRECTORY' |
| 814 `-d DIRECTORY' | 831 `-d DIRECTORY' |
| 815 Add DIRECTORY to the path to search for source and script files. | 832 Add DIRECTORY to the path to search for source and script files. |
| 816 | 833 |
| 817 `-r' | 834 `-r' |
| 818 `-readnow' | 835 `-readnow' |
| 819 Read each symbol file's entire symbol table immediately, rather | 836 Read each symbol file's entire symbol table immediately, rather |
| 820 than the default, which is to read it incrementally as it is | 837 than the default, which is to read it incrementally as it is |
| 821 needed. This makes startup slower, but makes future operations | 838 needed. This makes startup slower, but makes future operations |
| 822 faster. | 839 faster. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 remote debugging. | 973 remote debugging. |
| 957 | 974 |
| 958 `-tty DEVICE' | 975 `-tty DEVICE' |
| 959 `-t DEVICE' | 976 `-t DEVICE' |
| 960 Run using DEVICE for your program's standard input and output. | 977 Run using DEVICE for your program's standard input and output. |
| 961 | 978 |
| 962 `-tui' | 979 `-tui' |
| 963 Activate the "Text User Interface" when starting. The Text User | 980 Activate the "Text User Interface" when starting. The Text User |
| 964 Interface manages several text windows on the terminal, showing | 981 Interface manages several text windows on the terminal, showing |
| 965 source, assembly, registers and GDB command outputs (*note GDB | 982 source, assembly, registers and GDB command outputs (*note GDB |
| 966 Text User Interface: TUI.). Alternatively, the Text User | 983 Text User Interface: TUI.). Do not use this option if you run GDB |
| 967 Interface can be enabled by invoking the program `gdbtui'. Do not | 984 from Emacs (*note Using GDB under GNU Emacs: Emacs.). |
| 968 use this option if you run GDB from Emacs (*note Using GDB under | |
| 969 GNU Emacs: Emacs.). | |
| 970 | 985 |
| 971 `-interpreter INTERP' | 986 `-interpreter INTERP' |
| 972 Use the interpreter INTERP for interface with the controlling | 987 Use the interpreter INTERP for interface with the controlling |
| 973 program or device. This option is meant to be set by programs | 988 program or device. This option is meant to be set by programs |
| 974 which communicate with GDB using it as a back end. *Note Command | 989 which communicate with GDB using it as a back end. *Note Command |
| 975 Interpreters: Interpreters. | 990 Interpreters: Interpreters. |
| 976 | 991 |
| 977 `--interpreter=mi' (or `--interpreter=mi2') causes GDB to use the | 992 `--interpreter=mi' (or `--interpreter=mi2') causes GDB to use the |
| 978 "GDB/MI interface" (*note The GDB/MI Interface: GDB/MI.) included | 993 "GDB/MI interface" (*note The GDB/MI Interface: GDB/MI.) included |
| 979 since GDB version 6.0. The previous GDB/MI interface, included in | 994 since GDB version 6.0. The previous GDB/MI interface, included in |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1006 (*note interpreter: Mode Options.). | 1021 (*note interpreter: Mode Options.). |
| 1007 | 1022 |
| 1008 2. Reads the system-wide "init file" (if `--with-system-gdbinit' was | 1023 2. Reads the system-wide "init file" (if `--with-system-gdbinit' was |
| 1009 used when building GDB; *note System-wide configuration and | 1024 used when building GDB; *note System-wide configuration and |
| 1010 settings: System-wide configuration.) and executes all the | 1025 settings: System-wide configuration.) and executes all the |
| 1011 commands in that file. | 1026 commands in that file. |
| 1012 | 1027 |
| 1013 3. Reads the init file (if any) in your home directory(1) and | 1028 3. Reads the init file (if any) in your home directory(1) and |
| 1014 executes all the commands in that file. | 1029 executes all the commands in that file. |
| 1015 | 1030 |
| 1016 4. Processes command line options and operands. | 1031 4. Executes commands and command files specified by the `-iex' and |
| 1032 `-ix' options in their specified order. Usually you should use the |
| 1033 `-ex' and `-x' options instead, but this way you can apply |
| 1034 settings before GDB init files get executed and before inferior |
| 1035 gets loaded. |
| 1017 | 1036 |
| 1018 5. Reads and executes the commands from init file (if any) in the | 1037 5. Processes command line options and operands. |
| 1019 current working directory. This is only done if the current | |
| 1020 directory is different from your home directory. Thus, you can | |
| 1021 have more than one init file, one generic in your home directory, | |
| 1022 and another, specific to the program you are debugging, in the | |
| 1023 directory where you invoke GDB. | |
| 1024 | 1038 |
| 1025 6. If the command line specified a program to debug, or a process to | 1039 6. Reads and executes the commands from init file (if any) in the |
| 1040 current working directory as long as `set auto-load local-gdbinit' |
| 1041 is set to `on' (*note Init File in the Current Directory::). This |
| 1042 is only done if the current directory is different from your home |
| 1043 directory. Thus, you can have more than one init file, one |
| 1044 generic in your home directory, and another, specific to the |
| 1045 program you are debugging, in the directory where you invoke GDB. |
| 1046 |
| 1047 7. If the command line specified a program to debug, or a process to |
| 1026 attach to, or a core file, GDB loads any auto-loaded scripts | 1048 attach to, or a core file, GDB loads any auto-loaded scripts |
| 1027 provided for the program or for its loaded shared libraries. | 1049 provided for the program or for its loaded shared libraries. |
| 1028 *Note Auto-loading::. | 1050 *Note Auto-loading::. |
| 1029 | 1051 |
| 1030 If you wish to disable the auto-loading during startup, you must | 1052 If you wish to disable the auto-loading during startup, you must |
| 1031 do something like the following: | 1053 do something like the following: |
| 1032 | 1054 |
| 1033 $ gdb -ex "set auto-load-scripts off" -ex "file myprogram" | 1055 $ gdb -iex "set auto-load python-scripts off" myprogram |
| 1034 | 1056 |
| 1035 The following does not work because the auto-loading is turned off | 1057 Option `-ex' does not work because the auto-loading is then turned |
| 1036 too late: | 1058 off too late. |
| 1037 | 1059 |
| 1038 $ gdb -ex "set auto-load-scripts off" myprogram | 1060 8. Executes commands and command files specified by the `-ex' and |
| 1061 `-x' options in their specified order. *Note Command Files::, for |
| 1062 more details about GDB command files. |
| 1039 | 1063 |
| 1040 7. Reads command files specified by the `-x' option. *Note Command | 1064 9. Reads the command history recorded in the "history file". *Note |
| 1041 Files::, for more details about GDB command files. | |
| 1042 | |
| 1043 8. Reads the command history recorded in the "history file". *Note | |
| 1044 Command History::, for more details about the command history and | 1065 Command History::, for more details about the command history and |
| 1045 the files where GDB records it. | 1066 the files where GDB records it. |
| 1046 | 1067 |
| 1047 Init files use the same syntax as "command files" (*note Command | 1068 Init files use the same syntax as "command files" (*note Command |
| 1048 Files::) and are processed by GDB in the same way. The init file in | 1069 Files::) and are processed by GDB in the same way. The init file in |
| 1049 your home directory can set options (such as `set complaints') that | 1070 your home directory can set options (such as `set complaints') that |
| 1050 affect subsequent processing of command line options and operands. | 1071 affect subsequent processing of command line options and operands. |
| 1051 Init files are not executed if you use the `-nx' option (*note Choosing | 1072 Init files are not executed if you use the `-nx' option (*note Choosing |
| 1052 Modes: Mode Options.). | 1073 Modes: Mode Options.). |
| 1053 | 1074 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 | 1420 |
| 1400 `help COMMAND' | 1421 `help COMMAND' |
| 1401 With a command name as `help' argument, GDB displays a short | 1422 With a command name as `help' argument, GDB displays a short |
| 1402 paragraph on how to use that command. | 1423 paragraph on how to use that command. |
| 1403 | 1424 |
| 1404 `apropos ARGS' | 1425 `apropos ARGS' |
| 1405 The `apropos' command searches through all of the GDB commands, | 1426 The `apropos' command searches through all of the GDB commands, |
| 1406 and their documentation, for the regular expression specified in | 1427 and their documentation, for the regular expression specified in |
| 1407 ARGS. It prints out all matches found. For example: | 1428 ARGS. It prints out all matches found. For example: |
| 1408 | 1429 |
| 1409 apropos reload | 1430 apropos alias |
| 1410 | 1431 |
| 1411 results in: | 1432 results in: |
| 1412 | 1433 |
| 1413 set symbol-reloading -- Set dynamic symbol table reloading | 1434 alias -- Define a new command that is an alias of an existing command |
| 1414 multiple times in one run | 1435 aliases -- Aliases of other commands |
| 1415 show symbol-reloading -- Show dynamic symbol table reloading | 1436 d -- Delete some breakpoints or auto-display expressions |
| 1416 multiple times in one run | 1437 del -- Delete some breakpoints or auto-display expressions |
| 1438 delete -- Delete some breakpoints or auto-display expressions |
| 1417 | 1439 |
| 1418 `complete ARGS' | 1440 `complete ARGS' |
| 1419 The `complete ARGS' command lists all the possible completions for | 1441 The `complete ARGS' command lists all the possible completions for |
| 1420 the beginning of a command. Use ARGS to specify the beginning of | 1442 the beginning of a command. Use ARGS to specify the beginning of |
| 1421 the command you want completed. For example: | 1443 the command you want completed. For example: |
| 1422 | 1444 |
| 1423 complete i | 1445 complete i |
| 1424 | 1446 |
| 1425 results in: | 1447 results in: |
| 1426 | 1448 |
| 1427 if | 1449 if |
| 1428 ignore | 1450 ignore |
| 1429 info | 1451 info |
| 1430 inspect | 1452 inspect |
| 1431 | 1453 |
| 1432 This is intended for use by GNU Emacs. | 1454 This is intended for use by GNU Emacs. |
| 1433 | 1455 |
| 1434 In addition to `help', you can use the GDB commands `info' and | 1456 In addition to `help', you can use the GDB commands `info' and |
| 1435 `show' to inquire about the state of your program, or the state of GDB | 1457 `show' to inquire about the state of your program, or the state of GDB |
| 1436 itself. Each command supports many topics of inquiry; this manual | 1458 itself. Each command supports many topics of inquiry; this manual |
| 1437 introduces each of them in the appropriate context. The listings under | 1459 introduces each of them in the appropriate context. The listings under |
| 1438 `info' and under `show' in the Index point to all the sub-commands. | 1460 `info' and under `show' in the Command, Variable, and Function Index |
| 1439 *Note Index::. | 1461 point to all the sub-commands. *Note Command and Variable Index::. |
| 1440 | 1462 |
| 1441 `info' | 1463 `info' |
| 1442 This command (abbreviated `i') is for describing the state of your | 1464 This command (abbreviated `i') is for describing the state of your |
| 1443 program. For example, you can show the arguments passed to a | 1465 program. For example, you can show the arguments passed to a |
| 1444 function with `info args', list the registers currently in use | 1466 function with `info args', list the registers currently in use |
| 1445 with `info registers', or list the breakpoints you have set with | 1467 with `info registers', or list the breakpoints you have set with |
| 1446 `info breakpoints'. You can get a complete list of the `info' | 1468 `info breakpoints'. You can get a complete list of the `info' |
| 1447 sub-commands with `help info'. | 1469 sub-commands with `help info'. |
| 1448 | 1470 |
| 1449 `set' | 1471 `set' |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2372 If this variable is set, PATH is a colon-separated list of | 2394 If this variable is set, PATH is a colon-separated list of |
| 2373 directories GDB will use to search for `libthread_db'. If you | 2395 directories GDB will use to search for `libthread_db'. If you |
| 2374 omit PATH, `libthread-db-search-path' will be reset to its default | 2396 omit PATH, `libthread-db-search-path' will be reset to its default |
| 2375 value (`$sdir:$pdir' on GNU/Linux and Solaris systems). | 2397 value (`$sdir:$pdir' on GNU/Linux and Solaris systems). |
| 2376 Internally, the default value comes from the | 2398 Internally, the default value comes from the |
| 2377 `LIBTHREAD_DB_SEARCH_PATH' macro. | 2399 `LIBTHREAD_DB_SEARCH_PATH' macro. |
| 2378 | 2400 |
| 2379 On GNU/Linux and Solaris systems, GDB uses a "helper" | 2401 On GNU/Linux and Solaris systems, GDB uses a "helper" |
| 2380 `libthread_db' library to obtain information about threads in the | 2402 `libthread_db' library to obtain information about threads in the |
| 2381 inferior process. GDB will use `libthread-db-search-path' to find | 2403 inferior process. GDB will use `libthread-db-search-path' to find |
| 2382 `libthread_db'. | 2404 `libthread_db'. GDB also consults first if inferior specific |
| 2405 thread debugging library loading is enabled by `set auto-load |
| 2406 libthread-db' (*note libthread_db.so.1 file::). |
| 2383 | 2407 |
| 2384 A special entry `$sdir' for `libthread-db-search-path' refers to | 2408 A special entry `$sdir' for `libthread-db-search-path' refers to |
| 2385 the default system directories that are normally searched for | 2409 the default system directories that are normally searched for |
| 2386 loading shared libraries. | 2410 loading shared libraries. The `$sdir' entry is the only kind not |
| 2411 needing to be enabled by `set auto-load libthread-db' (*note |
| 2412 libthread_db.so.1 file::). |
| 2387 | 2413 |
| 2388 A special entry `$pdir' for `libthread-db-search-path' refers to | 2414 A special entry `$pdir' for `libthread-db-search-path' refers to |
| 2389 the directory from which `libpthread' was loaded in the inferior | 2415 the directory from which `libpthread' was loaded in the inferior |
| 2390 process. | 2416 process. |
| 2391 | 2417 |
| 2392 For any `libthread_db' library GDB finds in above directories, GDB | 2418 For any `libthread_db' library GDB finds in above directories, GDB |
| 2393 attempts to initialize it with the current inferior process. If | 2419 attempts to initialize it with the current inferior process. If |
| 2394 this initialization fails (which could happen because of a version | 2420 this initialization fails (which could happen because of a version |
| 2395 mismatch between `libthread_db' and `libpthread'), GDB will unload | 2421 mismatch between `libthread_db' and `libpthread'), GDB will unload |
| 2396 `libthread_db', and continue with the next directory. If none of | 2422 `libthread_db', and continue with the next directory. If none of |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2753 | 2779 |
| 2754 * Menu: | 2780 * Menu: |
| 2755 | 2781 |
| 2756 * Set Breaks:: Setting breakpoints | 2782 * Set Breaks:: Setting breakpoints |
| 2757 * Set Watchpoints:: Setting watchpoints | 2783 * Set Watchpoints:: Setting watchpoints |
| 2758 * Set Catchpoints:: Setting catchpoints | 2784 * Set Catchpoints:: Setting catchpoints |
| 2759 * Delete Breaks:: Deleting breakpoints | 2785 * Delete Breaks:: Deleting breakpoints |
| 2760 * Disabling:: Disabling breakpoints | 2786 * Disabling:: Disabling breakpoints |
| 2761 * Conditions:: Break conditions | 2787 * Conditions:: Break conditions |
| 2762 * Break Commands:: Breakpoint command lists | 2788 * Break Commands:: Breakpoint command lists |
| 2789 * Dynamic Printf:: Dynamic printf |
| 2763 * Save Breakpoints:: How to save breakpoints in a file | 2790 * Save Breakpoints:: How to save breakpoints in a file |
| 2791 * Static Probe Points:: Listing static probe points |
| 2764 * Error in Breakpoints:: ``Cannot insert breakpoints'' | 2792 * Error in Breakpoints:: ``Cannot insert breakpoints'' |
| 2765 * Breakpoint-related Warnings:: ``Breakpoint address adjusted...'' | 2793 * Breakpoint-related Warnings:: ``Breakpoint address adjusted...'' |
| 2766 | 2794 |
| 2767 | 2795 |
| 2768 File: gdb.info, Node: Set Breaks, Next: Set Watchpoints, Up: Breakpoints | 2796 File: gdb.info, Node: Set Breaks, Next: Set Watchpoints, Up: Breakpoints |
| 2769 | 2797 |
| 2770 5.1.1 Setting Breakpoints | 2798 5.1.1 Setting Breakpoints |
| 2771 ------------------------- | 2799 ------------------------- |
| 2772 | 2800 |
| 2773 Breakpoints are set with the `break' command (abbreviated `b'). The | 2801 Breakpoints are set with the `break' command (abbreviated `b'). The |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 breakpoint with several locations will have `<MULTIPLE>' in | 2950 breakpoint with several locations will have `<MULTIPLE>' in |
| 2923 this field--see below for details. | 2951 this field--see below for details. |
| 2924 | 2952 |
| 2925 _What_ | 2953 _What_ |
| 2926 Where the breakpoint is in the source for your program, as a | 2954 Where the breakpoint is in the source for your program, as a |
| 2927 file and line number. For a pending breakpoint, the original | 2955 file and line number. For a pending breakpoint, the original |
| 2928 string passed to the breakpoint command will be listed as it | 2956 string passed to the breakpoint command will be listed as it |
| 2929 cannot be resolved until the appropriate shared library is | 2957 cannot be resolved until the appropriate shared library is |
| 2930 loaded in the future. | 2958 loaded in the future. |
| 2931 | 2959 |
| 2932 If a breakpoint is conditional, `info break' shows the condition on | 2960 If a breakpoint is conditional, there are two evaluation modes: |
| 2933 the line following the affected breakpoint; breakpoint commands, | 2961 "host" and "target". If mode is "host", breakpoint condition |
| 2934 if any, are listed after that. A pending breakpoint is allowed to | 2962 evaluation is done by GDB on the host's side. If it is "target", |
| 2935 have a condition specified for it. The condition is not parsed | 2963 then the condition is evaluated by the target. The `info break' |
| 2936 for validity until a shared library is loaded that allows the | 2964 command shows the condition on the line following the affected |
| 2937 pending breakpoint to resolve to a valid location. | 2965 breakpoint, together with its condition evaluation mode in between |
| 2966 parentheses. |
| 2967 |
| 2968 Breakpoint commands, if any, are listed after that. A pending |
| 2969 breakpoint is allowed to have a condition specified for it. The |
| 2970 condition is not parsed for validity until a shared library is |
| 2971 loaded that allows the pending breakpoint to resolve to a valid |
| 2972 location. |
| 2938 | 2973 |
| 2939 `info break' with a breakpoint number N as argument lists only | 2974 `info break' with a breakpoint number N as argument lists only |
| 2940 that breakpoint. The convenience variable `$_' and the default | 2975 that breakpoint. The convenience variable `$_' and the default |
| 2941 examining-address for the `x' command are set to the address of | 2976 examining-address for the `x' command are set to the address of |
| 2942 the last breakpoint listed (*note Examining Memory: Memory.). | 2977 the last breakpoint listed (*note Examining Memory: Memory.). |
| 2943 | 2978 |
| 2944 `info break' displays a count of the number of times the breakpoint | 2979 `info break' displays a count of the number of times the breakpoint |
| 2945 has been hit. This is especially useful in conjunction with the | 2980 has been hit. This is especially useful in conjunction with the |
| 2946 `ignore' command. You can ignore a large number of breakpoint | 2981 `ignore' command. You can ignore a large number of breakpoint |
| 2947 hits, look at the breakpoint info to see how many times the | 2982 hits, look at the breakpoint info to see how many times the |
| 2948 breakpoint was hit, and then run again, ignoring one less than | 2983 breakpoint was hit, and then run again, ignoring one less than |
| 2949 that number. This will get you quickly to the last hit of that | 2984 that number. This will get you quickly to the last hit of that |
| 2950 breakpoint. | 2985 breakpoint. |
| 2951 | 2986 |
| 2987 For a breakpoints with an enable count (xref) greater than 1, |
| 2988 `info break' also displays that count. |
| 2989 |
| 2990 |
| 2952 GDB allows you to set any number of breakpoints at the same place in | 2991 GDB allows you to set any number of breakpoints at the same place in |
| 2953 your program. There is nothing silly or meaningless about this. When | 2992 your program. There is nothing silly or meaningless about this. When |
| 2954 the breakpoints are conditional, this is even useful (*note Break | 2993 the breakpoints are conditional, this is even useful (*note Break |
| 2955 Conditions: Conditions.). | 2994 Conditions: Conditions.). |
| 2956 | 2995 |
| 2957 It is possible that a breakpoint corresponds to several locations in | 2996 It is possible that a breakpoint corresponds to several locations in |
| 2958 your program. Examples of this situation are: | 2997 your program. Examples of this situation are: |
| 2959 | 2998 |
| 2960 * Multiple functions in the program may have the same name. | 2999 * Multiple functions in the program may have the same name. |
| 2961 | 3000 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 A breakpoint is removed from the target only when breakpoint | 3131 A breakpoint is removed from the target only when breakpoint |
| 3093 itself is removed. | 3132 itself is removed. |
| 3094 | 3133 |
| 3095 `set breakpoint always-inserted auto' | 3134 `set breakpoint always-inserted auto' |
| 3096 This is the default mode. If GDB is controlling the inferior in | 3135 This is the default mode. If GDB is controlling the inferior in |
| 3097 non-stop mode (*note Non-Stop Mode::), gdb behaves as if | 3136 non-stop mode (*note Non-Stop Mode::), gdb behaves as if |
| 3098 `breakpoint always-inserted' mode is on. If GDB is controlling | 3137 `breakpoint always-inserted' mode is on. If GDB is controlling |
| 3099 the inferior in all-stop mode, GDB behaves as if `breakpoint | 3138 the inferior in all-stop mode, GDB behaves as if `breakpoint |
| 3100 always-inserted' mode is off. | 3139 always-inserted' mode is off. |
| 3101 | 3140 |
| 3141 GDB handles conditional breakpoints by evaluating these conditions |
| 3142 when a breakpoint breaks. If the condition is true, then the process |
| 3143 being debugged stops, otherwise the process is resumed. |
| 3144 |
| 3145 If the target supports evaluating conditions on its end, GDB may |
| 3146 download the breakpoint, together with its conditions, to it. |
| 3147 |
| 3148 This feature can be controlled via the following commands: |
| 3149 |
| 3150 `set breakpoint condition-evaluation host' |
| 3151 This option commands GDB to evaluate the breakpoint conditions on |
| 3152 the host's side. Unconditional breakpoints are sent to the target |
| 3153 which in turn receives the triggers and reports them back to GDB |
| 3154 for condition evaluation. This is the standard evaluation mode. |
| 3155 |
| 3156 `set breakpoint condition-evaluation target' |
| 3157 This option commands GDB to download breakpoint conditions to the |
| 3158 target at the moment of their insertion. The target is |
| 3159 responsible for evaluating the conditional expression and reporting |
| 3160 breakpoint stop events back to GDB whenever the condition is true. |
| 3161 Due to limitations of target-side evaluation, some conditions |
| 3162 cannot be evaluated there, e.g., conditions that depend on local |
| 3163 data that is only known to the host. Examples include conditional |
| 3164 expressions involving convenience variables, complex types that |
| 3165 cannot be handled by the agent expression parser and expressions |
| 3166 that are too long to be sent over to the target, specially when the |
| 3167 target is a remote system. In these cases, the conditions will be |
| 3168 evaluated by GDB. |
| 3169 |
| 3170 `set breakpoint condition-evaluation auto' |
| 3171 This is the default mode. If the target supports evaluating |
| 3172 breakpoint conditions on its end, GDB will download breakpoint |
| 3173 conditions to the target (limitations mentioned previously apply). |
| 3174 If the target does not support breakpoint condition evaluation, |
| 3175 then GDB will fallback to evaluating all these conditions on the |
| 3176 host's side. |
| 3177 |
| 3102 GDB itself sometimes sets breakpoints in your program for special | 3178 GDB itself sometimes sets breakpoints in your program for special |
| 3103 purposes, such as proper handling of `longjmp' (in C programs). These | 3179 purposes, such as proper handling of `longjmp' (in C programs). These |
| 3104 internal breakpoints are assigned negative numbers, starting with `-1'; | 3180 internal breakpoints are assigned negative numbers, starting with `-1'; |
| 3105 `info breakpoints' does not display them. You can see these | 3181 `info breakpoints' does not display them. You can see these |
| 3106 breakpoints with the GDB maintenance command `maint info breakpoints' | 3182 breakpoints with the GDB maintenance command `maint info breakpoints' |
| 3107 (*note maint info breakpoints::). | 3183 (*note maint info breakpoints::). |
| 3108 | 3184 |
| 3109 | 3185 |
| 3110 File: gdb.info, Node: Set Watchpoints, Next: Set Catchpoints, Prev: Set Break
s, Up: Breakpoints | 3186 File: gdb.info, Node: Set Watchpoints, Next: Set Catchpoints, Prev: Set Break
s, Up: Breakpoints |
| 3111 | 3187 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3466 syscall's names. | 3542 syscall's names. |
| 3467 | 3543 |
| 3468 `fork' | 3544 `fork' |
| 3469 A call to `fork'. This is currently only available for HP-UX | 3545 A call to `fork'. This is currently only available for HP-UX |
| 3470 and GNU/Linux. | 3546 and GNU/Linux. |
| 3471 | 3547 |
| 3472 `vfork' | 3548 `vfork' |
| 3473 A call to `vfork'. This is currently only available for HP-UX | 3549 A call to `vfork'. This is currently only available for HP-UX |
| 3474 and GNU/Linux. | 3550 and GNU/Linux. |
| 3475 | 3551 |
| 3552 `load [regexp]' |
| 3553 `unload [regexp]' |
| 3554 The loading or unloading of a shared library. If REGEXP is |
| 3555 given, then the catchpoint will stop only if the regular |
| 3556 expression matches one of the affected libraries. |
| 3557 |
| 3476 | 3558 |
| 3477 `tcatch EVENT' | 3559 `tcatch EVENT' |
| 3478 Set a catchpoint that is enabled only for one stop. The | 3560 Set a catchpoint that is enabled only for one stop. The |
| 3479 catchpoint is automatically deleted after the first time the event | 3561 catchpoint is automatically deleted after the first time the event |
| 3480 is caught. | 3562 is caught. |
| 3481 | 3563 |
| 3482 | 3564 |
| 3483 Use the `info break' command to list the current catchpoints. | 3565 Use the `info break' command to list the current catchpoints. |
| 3484 | 3566 |
| 3485 There are currently some limitations to C++ exception handling | 3567 There are currently some limitations to C++ exception handling |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 | 3667 |
| 3586 You disable and enable breakpoints, watchpoints, and catchpoints with | 3668 You disable and enable breakpoints, watchpoints, and catchpoints with |
| 3587 the `enable' and `disable' commands, optionally specifying one or more | 3669 the `enable' and `disable' commands, optionally specifying one or more |
| 3588 breakpoint numbers as arguments. Use `info break' to print a list of | 3670 breakpoint numbers as arguments. Use `info break' to print a list of |
| 3589 all breakpoints, watchpoints, and catchpoints if you do not know which | 3671 all breakpoints, watchpoints, and catchpoints if you do not know which |
| 3590 numbers to use. | 3672 numbers to use. |
| 3591 | 3673 |
| 3592 Disabling and enabling a breakpoint that has multiple locations | 3674 Disabling and enabling a breakpoint that has multiple locations |
| 3593 affects all of its locations. | 3675 affects all of its locations. |
| 3594 | 3676 |
| 3595 A breakpoint, watchpoint, or catchpoint can have any of four | 3677 A breakpoint, watchpoint, or catchpoint can have any of several |
| 3596 different states of enablement: | 3678 different states of enablement: |
| 3597 | 3679 |
| 3598 * Enabled. The breakpoint stops your program. A breakpoint set | 3680 * Enabled. The breakpoint stops your program. A breakpoint set |
| 3599 with the `break' command starts out in this state. | 3681 with the `break' command starts out in this state. |
| 3600 | 3682 |
| 3601 * Disabled. The breakpoint has no effect on your program. | 3683 * Disabled. The breakpoint has no effect on your program. |
| 3602 | 3684 |
| 3603 * Enabled once. The breakpoint stops your program, but then becomes | 3685 * Enabled once. The breakpoint stops your program, but then becomes |
| 3604 disabled. | 3686 disabled. |
| 3605 | 3687 |
| 3688 * Enabled for a count. The breakpoint stops your program for the |
| 3689 next N times, then becomes disabled. |
| 3690 |
| 3606 * Enabled for deletion. The breakpoint stops your program, but | 3691 * Enabled for deletion. The breakpoint stops your program, but |
| 3607 immediately after it does so it is deleted permanently. A | 3692 immediately after it does so it is deleted permanently. A |
| 3608 breakpoint set with the `tbreak' command starts out in this state. | 3693 breakpoint set with the `tbreak' command starts out in this state. |
| 3609 | 3694 |
| 3610 You can use the following commands to enable or disable breakpoints, | 3695 You can use the following commands to enable or disable breakpoints, |
| 3611 watchpoints, and catchpoints: | 3696 watchpoints, and catchpoints: |
| 3612 | 3697 |
| 3613 `disable [breakpoints] [RANGE...]' | 3698 `disable [breakpoints] [RANGE...]' |
| 3614 Disable the specified breakpoints--or all breakpoints, if none are | 3699 Disable the specified breakpoints--or all breakpoints, if none are |
| 3615 listed. A disabled breakpoint has no effect but is not forgotten. | 3700 listed. A disabled breakpoint has no effect but is not forgotten. |
| 3616 All options such as ignore-counts, conditions and commands are | 3701 All options such as ignore-counts, conditions and commands are |
| 3617 remembered in case the breakpoint is enabled again later. You may | 3702 remembered in case the breakpoint is enabled again later. You may |
| 3618 abbreviate `disable' as `dis'. | 3703 abbreviate `disable' as `dis'. |
| 3619 | 3704 |
| 3620 `enable [breakpoints] [RANGE...]' | 3705 `enable [breakpoints] [RANGE...]' |
| 3621 Enable the specified breakpoints (or all defined breakpoints). | 3706 Enable the specified breakpoints (or all defined breakpoints). |
| 3622 They become effective once again in stopping your program. | 3707 They become effective once again in stopping your program. |
| 3623 | 3708 |
| 3624 `enable [breakpoints] once RANGE...' | 3709 `enable [breakpoints] once RANGE...' |
| 3625 Enable the specified breakpoints temporarily. GDB disables any of | 3710 Enable the specified breakpoints temporarily. GDB disables any of |
| 3626 these breakpoints immediately after stopping your program. | 3711 these breakpoints immediately after stopping your program. |
| 3627 | 3712 |
| 3713 `enable [breakpoints] count COUNT RANGE...' |
| 3714 Enable the specified breakpoints temporarily. GDB records COUNT |
| 3715 with each of the specified breakpoints, and decrements a |
| 3716 breakpoint's count when it is hit. When any count reaches 0, GDB |
| 3717 disables that breakpoint. If a breakpoint has an ignore count |
| 3718 (*note Break Conditions: Conditions.), that will be decremented to |
| 3719 0 before COUNT is affected. |
| 3720 |
| 3628 `enable [breakpoints] delete RANGE...' | 3721 `enable [breakpoints] delete RANGE...' |
| 3629 Enable the specified breakpoints to work once, then die. GDB | 3722 Enable the specified breakpoints to work once, then die. GDB |
| 3630 deletes any of these breakpoints as soon as your program stops | 3723 deletes any of these breakpoints as soon as your program stops |
| 3631 there. Breakpoints set by the `tbreak' command start out in this | 3724 there. Breakpoints set by the `tbreak' command start out in this |
| 3632 state. | 3725 state. |
| 3633 | 3726 |
| 3634 Except for a breakpoint set with `tbreak' (*note Setting | 3727 Except for a breakpoint set with `tbreak' (*note Setting |
| 3635 Breakpoints: Set Breaks.), breakpoints that you set are initially | 3728 Breakpoints: Set Breaks.), breakpoints that you set are initially |
| 3636 enabled; subsequently, they become disabled or enabled only when you | 3729 enabled; subsequently, they become disabled or enabled only when you |
| 3637 use one of the commands above. (The command `until' can set and delete | 3730 use one of the commands above. (The command `until' can set and delete |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3668 in your program. This can be useful, for example, to activate functions | 3761 in your program. This can be useful, for example, to activate functions |
| 3669 that log program progress, or to use your own print functions to format | 3762 that log program progress, or to use your own print functions to format |
| 3670 special data structures. The effects are completely predictable unless | 3763 special data structures. The effects are completely predictable unless |
| 3671 there is another enabled breakpoint at the same address. (In that | 3764 there is another enabled breakpoint at the same address. (In that |
| 3672 case, GDB might see the other breakpoint first and stop your program | 3765 case, GDB might see the other breakpoint first and stop your program |
| 3673 without checking the condition of this one.) Note that breakpoint | 3766 without checking the condition of this one.) Note that breakpoint |
| 3674 commands are usually more convenient and flexible than break conditions | 3767 commands are usually more convenient and flexible than break conditions |
| 3675 for the purpose of performing side effects when a breakpoint is reached | 3768 for the purpose of performing side effects when a breakpoint is reached |
| 3676 (*note Breakpoint Command Lists: Break Commands.). | 3769 (*note Breakpoint Command Lists: Break Commands.). |
| 3677 | 3770 |
| 3771 Breakpoint conditions can also be evaluated on the target's side if |
| 3772 the target supports it. Instead of evaluating the conditions locally, |
| 3773 GDB encodes the expression into an agent expression (*note Agent |
| 3774 Expressions::) suitable for execution on the target, independently of |
| 3775 GDB. Global variables become raw memory locations, locals become stack |
| 3776 accesses, and so forth. |
| 3777 |
| 3778 In this case, GDB will only be notified of a breakpoint trigger when |
| 3779 its condition evaluates to true. This mechanism may provide faster |
| 3780 response times depending on the performance characteristics of the |
| 3781 target since it does not need to keep GDB informed about every |
| 3782 breakpoint trigger, even those with false conditions. |
| 3783 |
| 3678 Break conditions can be specified when a breakpoint is set, by using | 3784 Break conditions can be specified when a breakpoint is set, by using |
| 3679 `if' in the arguments to the `break' command. *Note Setting | 3785 `if' in the arguments to the `break' command. *Note Setting |
| 3680 Breakpoints: Set Breaks. They can also be changed at any time with the | 3786 Breakpoints: Set Breaks. They can also be changed at any time with the |
| 3681 `condition' command. | 3787 `condition' command. |
| 3682 | 3788 |
| 3683 You can also use the `if' keyword with the `watch' command. The | 3789 You can also use the `if' keyword with the `watch' command. The |
| 3684 `catch' command does not recognize the `if' keyword; `condition' is the | 3790 `catch' command does not recognize the `if' keyword; `condition' is the |
| 3685 only way to impose a further condition on a catchpoint. | 3791 only way to impose a further condition on a catchpoint. |
| 3686 | 3792 |
| 3687 `condition BNUM EXPRESSION' | 3793 `condition BNUM EXPRESSION' |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 resumes checking the condition. | 3841 resumes checking the condition. |
| 3736 | 3842 |
| 3737 You could achieve the effect of the ignore count with a condition | 3843 You could achieve the effect of the ignore count with a condition |
| 3738 such as `$foo-- <= 0' using a debugger convenience variable that | 3844 such as `$foo-- <= 0' using a debugger convenience variable that |
| 3739 is decremented each time. *Note Convenience Variables: | 3845 is decremented each time. *Note Convenience Variables: |
| 3740 Convenience Vars. | 3846 Convenience Vars. |
| 3741 | 3847 |
| 3742 Ignore counts apply to breakpoints, watchpoints, and catchpoints. | 3848 Ignore counts apply to breakpoints, watchpoints, and catchpoints. |
| 3743 | 3849 |
| 3744 | 3850 |
| 3745 File: gdb.info, Node: Break Commands, Next: Save Breakpoints, Prev: Condition
s, Up: Breakpoints | 3851 File: gdb.info, Node: Break Commands, Next: Dynamic Printf, Prev: Conditions,
Up: Breakpoints |
| 3746 | 3852 |
| 3747 5.1.7 Breakpoint Command Lists | 3853 5.1.7 Breakpoint Command Lists |
| 3748 ------------------------------ | 3854 ------------------------------ |
| 3749 | 3855 |
| 3750 You can give any breakpoint (or watchpoint or catchpoint) a series of | 3856 You can give any breakpoint (or watchpoint or catchpoint) a series of |
| 3751 commands to execute when your program stops due to that breakpoint. For | 3857 commands to execute when your program stops due to that breakpoint. For |
| 3752 example, you might want to print the values of certain expressions, or | 3858 example, you might want to print the values of certain expressions, or |
| 3753 enable other breakpoints. | 3859 enable other breakpoints. |
| 3754 | 3860 |
| 3755 `commands [RANGE...]' | 3861 `commands [RANGE...]' |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3814 that no output is produced. Here is an example: | 3920 that no output is produced. Here is an example: |
| 3815 | 3921 |
| 3816 break 403 | 3922 break 403 |
| 3817 commands | 3923 commands |
| 3818 silent | 3924 silent |
| 3819 set x = y + 4 | 3925 set x = y + 4 |
| 3820 cont | 3926 cont |
| 3821 end | 3927 end |
| 3822 | 3928 |
| 3823 | 3929 |
| 3824 File: gdb.info, Node: Save Breakpoints, Next: Error in Breakpoints, Prev: Bre
ak Commands, Up: Breakpoints | 3930 File: gdb.info, Node: Dynamic Printf, Next: Save Breakpoints, Prev: Break Com
mands, Up: Breakpoints |
| 3825 | 3931 |
| 3826 5.1.8 How to save breakpoints to a file | 3932 5.1.8 Dynamic Printf |
| 3933 -------------------- |
| 3934 |
| 3935 The dynamic printf command `dprintf' combines a breakpoint with |
| 3936 formatted printing of your program's data to give you the effect of |
| 3937 inserting `printf' calls into your program on-the-fly, without having |
| 3938 to recompile it. |
| 3939 |
| 3940 In its most basic form, the output goes to the GDB console. However, |
| 3941 you can set the variable `dprintf-style' for alternate handling. For |
| 3942 instance, you can ask to format the output by calling your program's |
| 3943 `printf' function. This has the advantage that the characters go to |
| 3944 the program's output device, so they can recorded in redirects to files |
| 3945 and so forth. |
| 3946 |
| 3947 If you are doing remote debugging with a stub or agent, you can also |
| 3948 ask to have the printf handled by the remote agent. In addition to |
| 3949 ensuring that the output goes to the remote program's device along with |
| 3950 any other output the program might produce, you can also ask that the |
| 3951 dprintf remain active even after disconnecting from the remote target. |
| 3952 Using the stub/agent is also more efficient, as it can do everything |
| 3953 without needing to communicate with GDB. |
| 3954 |
| 3955 `dprintf LOCATION,TEMPLATE,EXPRESSION[,EXPRESSION...]' |
| 3956 Whenever execution reaches LOCATION, print the values of one or |
| 3957 more EXPRESSIONS under the control of the string TEMPLATE. To |
| 3958 print several values, separate them with commas. |
| 3959 |
| 3960 `set dprintf-style STYLE' |
| 3961 Set the dprintf output to be handled in one of several different |
| 3962 styles enumerated below. A change of style affects all existing |
| 3963 dynamic printfs immediately. (If you need individual control over |
| 3964 the print commands, simply define normal breakpoints with |
| 3965 explicitly-supplied command lists.) |
| 3966 |
| 3967 `gdb' |
| 3968 Handle the output using the GDB `printf' command. |
| 3969 |
| 3970 `call' |
| 3971 Handle the output by calling a function in your program (normally |
| 3972 `printf'). |
| 3973 |
| 3974 `agent' |
| 3975 Have the remote debugging agent (such as `gdbserver') handle the |
| 3976 output itself. This style is only available for agents that |
| 3977 support running commands on the target. |
| 3978 |
| 3979 `set dprintf-function FUNCTION' |
| 3980 Set the function to call if the dprintf style is `call'. By |
| 3981 default its value is `printf'. You may set it to any expression. |
| 3982 that GDB can evaluate to a function, as per the `call' command. |
| 3983 |
| 3984 `set dprintf-channel CHANNEL' |
| 3985 Set a "channel" for dprintf. If set to a non-empty value, GDB |
| 3986 will evaluate it as an expression and pass the result as a first |
| 3987 argument to the `dprintf-function', in the manner of `fprintf' and |
| 3988 similar functions. Otherwise, the dprintf format string will be |
| 3989 the first argument, in the manner of `printf'. |
| 3990 |
| 3991 As an example, if you wanted `dprintf' output to go to a logfile |
| 3992 that is a standard I/O stream assigned to the variable `mylog', |
| 3993 you could do the following: |
| 3994 |
| 3995 (gdb) set dprintf-style call |
| 3996 (gdb) set dprintf-function fprintf |
| 3997 (gdb) set dprintf-channel mylog |
| 3998 (gdb) dprintf 25,"at line 25, glob=%d\n",glob |
| 3999 Dprintf 1 at 0x123456: file main.c, line 25. |
| 4000 (gdb) info break |
| 4001 1 dprintf keep y 0x00123456 in main at main.c:25 |
| 4002 call (void) fprintf (mylog,"at line 25, glob=%d\n",glob) |
| 4003 continue |
| 4004 (gdb) |
| 4005 |
| 4006 Note that the `info break' displays the dynamic printf commands as |
| 4007 normal breakpoint commands; you can thus easily see the effect of |
| 4008 the variable settings. |
| 4009 |
| 4010 `set disconnected-dprintf on' |
| 4011 `set disconnected-dprintf off' |
| 4012 Choose whether `dprintf' commands should continue to run if GDB |
| 4013 has disconnected from the target. This only applies if the |
| 4014 `dprintf-style' is `agent'. |
| 4015 |
| 4016 `show disconnected-dprintf off' |
| 4017 Show the current choice for disconnected `dprintf'. |
| 4018 |
| 4019 |
| 4020 GDB does not check the validity of function and channel, relying on |
| 4021 you to supply values that are meaningful for the contexts in which they |
| 4022 are being used. For instance, the function and channel may be the |
| 4023 values of local variables, but if that is the case, then all enabled |
| 4024 dynamic prints must be at locations within the scope of those locals. |
| 4025 If evaluation fails, GDB will report an error. |
| 4026 |
| 4027 |
| 4028 File: gdb.info, Node: Save Breakpoints, Next: Static Probe Points, Prev: Dyna
mic Printf, Up: Breakpoints |
| 4029 |
| 4030 5.1.9 How to save breakpoints to a file |
| 3827 --------------------------------------- | 4031 --------------------------------------- |
| 3828 | 4032 |
| 3829 To save breakpoint definitions to a file use the `save breakpoints' | 4033 To save breakpoint definitions to a file use the `save breakpoints' |
| 3830 command. | 4034 command. |
| 3831 | 4035 |
| 3832 `save breakpoints [FILENAME]' | 4036 `save breakpoints [FILENAME]' |
| 3833 This command saves all current breakpoint definitions together with | 4037 This command saves all current breakpoint definitions together with |
| 3834 their commands and ignore counts, into a file `FILENAME' suitable | 4038 their commands and ignore counts, into a file `FILENAME' suitable |
| 3835 for use in a later debugging session. This includes all types of | 4039 for use in a later debugging session. This includes all types of |
| 3836 breakpoints (breakpoints, watchpoints, catchpoints, tracepoints). | 4040 breakpoints (breakpoints, watchpoints, catchpoints, tracepoints). |
| 3837 To read the saved breakpoint definitions, use the `source' command | 4041 To read the saved breakpoint definitions, use the `source' command |
| 3838 (*note Command Files::). Note that watchpoints with expressions | 4042 (*note Command Files::). Note that watchpoints with expressions |
| 3839 involving local variables may fail to be recreated because it may | 4043 involving local variables may fail to be recreated because it may |
| 3840 not be possible to access the context where the watchpoint is | 4044 not be possible to access the context where the watchpoint is |
| 3841 valid anymore. Because the saved breakpoint definitions are | 4045 valid anymore. Because the saved breakpoint definitions are |
| 3842 simply a sequence of GDB commands that recreate the breakpoints, | 4046 simply a sequence of GDB commands that recreate the breakpoints, |
| 3843 you can edit the file in your favorite editing program, and remove | 4047 you can edit the file in your favorite editing program, and remove |
| 3844 the breakpoint definitions you're not interested in, or that can | 4048 the breakpoint definitions you're not interested in, or that can |
| 3845 no longer be recreated. | 4049 no longer be recreated. |
| 3846 | 4050 |
| 3847 | 4051 |
| 3848 File: gdb.info, Node: Error in Breakpoints, Next: Breakpoint-related Warnings,
Prev: Save Breakpoints, Up: Breakpoints | 4052 File: gdb.info, Node: Static Probe Points, Next: Error in Breakpoints, Prev:
Save Breakpoints, Up: Breakpoints |
| 3849 | 4053 |
| 3850 5.1.9 "Cannot insert breakpoints" | 4054 5.1.10 Static Probe Points |
| 3851 --------------------------------- | 4055 -------------------------- |
| 4056 |
| 4057 GDB supports "SDT" probes in the code. SDT stands for Statically |
| 4058 Defined Tracing, and the probes are designed to have a tiny runtime |
| 4059 code and data footprint, and no dynamic relocations. They are usable |
| 4060 from assembly, C and C++ languages. See |
| 4061 `http://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation' for |
| 4062 a good reference on how the SDT probes are implemented. |
| 4063 |
| 4064 Currently, `SystemTap' (`http://sourceware.org/systemtap/') SDT |
| 4065 probes are supported on ELF-compatible systems. See |
| 4066 `http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps' for |
| 4067 more information on how to add `SystemTap' SDT probes in your |
| 4068 applications. |
| 4069 |
| 4070 Some probes have an associated semaphore variable; for instance, this |
| 4071 happens automatically if you defined your probe using a DTrace-style |
| 4072 `.d' file. If your probe has a semaphore, GDB will automatically |
| 4073 enable it when you specify a breakpoint using the `-probe-stap' |
| 4074 notation. But, if you put a breakpoint at a probe's location by some |
| 4075 other method (e.g., `break file:line'), then GDB will not automatically |
| 4076 set the semaphore. |
| 4077 |
| 4078 You can examine the available static static probes using `info |
| 4079 probes', with optional arguments: |
| 4080 |
| 4081 `info probes stap [PROVIDER [NAME [OBJFILE]]]' |
| 4082 If given, PROVIDER is a regular expression used to match against |
| 4083 provider names when selecting which probes to list. If omitted, |
| 4084 probes by all probes from all providers are listed. |
| 4085 |
| 4086 If given, NAME is a regular expression to match against probe names |
| 4087 when selecting which probes to list. If omitted, probe names are |
| 4088 not considered when deciding whether to display them. |
| 4089 |
| 4090 If given, OBJFILE is a regular expression used to select which |
| 4091 object files (executable or shared libraries) to examine. If not |
| 4092 given, all object files are considered. |
| 4093 |
| 4094 `info probes all' |
| 4095 List the available static probes, from all types. |
| 4096 |
| 4097 A probe may specify up to twelve arguments. These are available at |
| 4098 the point at which the probe is defined--that is, when the current PC is |
| 4099 at the probe's location. The arguments are available using the |
| 4100 convenience variables (*note Convenience Vars::) |
| 4101 `$_probe_arg0'...`$_probe_arg11'. Each probe argument is an integer of |
| 4102 the appropriate size; types are not preserved. The convenience |
| 4103 variable `$_probe_argc' holds the number of arguments at the current |
| 4104 probe point. |
| 4105 |
| 4106 These variables are always available, but attempts to access them at |
| 4107 any location other than a probe point will cause GDB to give an error |
| 4108 message. |
| 4109 |
| 4110 |
| 4111 File: gdb.info, Node: Error in Breakpoints, Next: Breakpoint-related Warnings,
Prev: Static Probe Points, Up: Breakpoints |
| 4112 |
| 4113 5.1.11 "Cannot insert breakpoints" |
| 4114 ---------------------------------- |
| 3852 | 4115 |
| 3853 If you request too many active hardware-assisted breakpoints and | 4116 If you request too many active hardware-assisted breakpoints and |
| 3854 watchpoints, you will see this error message: | 4117 watchpoints, you will see this error message: |
| 3855 | 4118 |
| 3856 Stopped; cannot insert breakpoints. | 4119 Stopped; cannot insert breakpoints. |
| 3857 You may have requested too many hardware breakpoints and watchpoints. | 4120 You may have requested too many hardware breakpoints and watchpoints. |
| 3858 | 4121 |
| 3859 This message is printed when you attempt to resume the program, since | 4122 This message is printed when you attempt to resume the program, since |
| 3860 only then GDB knows exactly how many hardware breakpoints and | 4123 only then GDB knows exactly how many hardware breakpoints and |
| 3861 watchpoints it needs to insert. | 4124 watchpoints it needs to insert. |
| 3862 | 4125 |
| 3863 When this message is printed, you need to disable or remove some of | 4126 When this message is printed, you need to disable or remove some of |
| 3864 the hardware-assisted breakpoints and watchpoints, and then continue. | 4127 the hardware-assisted breakpoints and watchpoints, and then continue. |
| 3865 | 4128 |
| 3866 | 4129 |
| 3867 File: gdb.info, Node: Breakpoint-related Warnings, Prev: Error in Breakpoints,
Up: Breakpoints | 4130 File: gdb.info, Node: Breakpoint-related Warnings, Prev: Error in Breakpoints,
Up: Breakpoints |
| 3868 | 4131 |
| 3869 5.1.10 "Breakpoint address adjusted..." | 4132 5.1.12 "Breakpoint address adjusted..." |
| 3870 --------------------------------------- | 4133 --------------------------------------- |
| 3871 | 4134 |
| 3872 Some processor architectures place constraints on the addresses at | 4135 Some processor architectures place constraints on the addresses at |
| 3873 which breakpoints may be placed. For architectures thus constrained, | 4136 which breakpoints may be placed. For architectures thus constrained, |
| 3874 GDB will attempt to adjust the breakpoint's address to comply with the | 4137 GDB will attempt to adjust the breakpoint's address to comply with the |
| 3875 constraints dictated by the architecture. | 4138 constraints dictated by the architecture. |
| 3876 | 4139 |
| 3877 One example of such an architecture is the Fujitsu FR-V. The FR-V is | 4140 One example of such an architecture is the Fujitsu FR-V. The FR-V is |
| 3878 a VLIW architecture in which a number of RISC-like instructions may be | 4141 a VLIW architecture in which a number of RISC-like instructions may be |
| 3879 bundled together for parallel execution. The FR-V architecture | 4142 bundled together for parallel execution. The FR-V architecture |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5423 | 5686 |
| 5424 `info args' | 5687 `info args' |
| 5425 Print the arguments of the selected frame, each on a separate line. | 5688 Print the arguments of the selected frame, each on a separate line. |
| 5426 | 5689 |
| 5427 `info locals' | 5690 `info locals' |
| 5428 Print the local variables of the selected frame, each on a separate | 5691 Print the local variables of the selected frame, each on a separate |
| 5429 line. These are all variables (declared either static or | 5692 line. These are all variables (declared either static or |
| 5430 automatic) accessible at the point of execution of the selected | 5693 automatic) accessible at the point of execution of the selected |
| 5431 frame. | 5694 frame. |
| 5432 | 5695 |
| 5433 `info catch' | |
| 5434 Print a list of all the exception handlers that are active in the | |
| 5435 current stack frame at the current point of execution. To see | |
| 5436 other exception handlers, visit the associated frame (using the | |
| 5437 `up', `down', or `frame' commands); then type `info catch'. *Note | |
| 5438 Setting Catchpoints: Set Catchpoints. | |
| 5439 | |
| 5440 | 5696 |
| 5441 | 5697 |
| 5442 File: gdb.info, Node: Source, Next: Data, Prev: Stack, Up: Top | 5698 File: gdb.info, Node: Source, Next: Data, Prev: Stack, Up: Top |
| 5443 | 5699 |
| 5444 9 Examining Source Files | 5700 9 Examining Source Files |
| 5445 ************************ | 5701 ************************ |
| 5446 | 5702 |
| 5447 GDB can print parts of your program's source, since the debugging | 5703 GDB can print parts of your program's source, since the debugging |
| 5448 information recorded in the program tells GDB what source files were | 5704 information recorded in the program tells GDB what source files were |
| 5449 used to build it. When your program stops, GDB spontaneously prints | 5705 used to build it. When your program stops, GDB spontaneously prints |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5563 `+OFFSET' | 5819 `+OFFSET' |
| 5564 Specifies the line OFFSET lines before or after the "current | 5820 Specifies the line OFFSET lines before or after the "current |
| 5565 line". For the `list' command, the current line is the last one | 5821 line". For the `list' command, the current line is the last one |
| 5566 printed; for the breakpoint commands, this is the line at which | 5822 printed; for the breakpoint commands, this is the line at which |
| 5567 execution stopped in the currently selected "stack frame" (*note | 5823 execution stopped in the currently selected "stack frame" (*note |
| 5568 Frames: Frames, for a description of stack frames.) When used as | 5824 Frames: Frames, for a description of stack frames.) When used as |
| 5569 the second of the two linespecs in a `list' command, this | 5825 the second of the two linespecs in a `list' command, this |
| 5570 specifies the line OFFSET lines up or down from the first linespec. | 5826 specifies the line OFFSET lines up or down from the first linespec. |
| 5571 | 5827 |
| 5572 `FILENAME:LINENUM' | 5828 `FILENAME:LINENUM' |
| 5573 Specifies the line LINENUM in the source file FILENAME. | 5829 Specifies the line LINENUM in the source file FILENAME. If |
| 5830 FILENAME is a relative file name, then it will match any source |
| 5831 file name with the same trailing components. For example, if |
| 5832 FILENAME is `gcc/expr.c', then it will match source file name of |
| 5833 `/build/trunk/gcc/expr.c', but not `/build/trunk/libcpp/expr.c' or |
| 5834 `/build/trunk/gcc/x-expr.c'. |
| 5574 | 5835 |
| 5575 `FUNCTION' | 5836 `FUNCTION' |
| 5576 Specifies the line that begins the body of the function FUNCTION. | 5837 Specifies the line that begins the body of the function FUNCTION. |
| 5577 For example, in C, this is the line with the open brace. | 5838 For example, in C, this is the line with the open brace. |
| 5578 | 5839 |
| 5579 `FUNCTION:LABEL' | 5840 `FUNCTION:LABEL' |
| 5580 Specifies the line where LABEL appears in FUNCTION. | 5841 Specifies the line where LABEL appears in FUNCTION. |
| 5581 | 5842 |
| 5582 `FILENAME:FUNCTION' | 5843 `FILENAME:FUNCTION' |
| 5583 Specifies the line that begins the body of the function FUNCTION | 5844 Specifies the line that begins the body of the function FUNCTION |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5621 instruction, before the stack frame and arguments have been | 5882 instruction, before the stack frame and arguments have been |
| 5622 set up. | 5883 set up. |
| 5623 | 5884 |
| 5624 `'FILENAME'::FUNCADDR' | 5885 `'FILENAME'::FUNCADDR' |
| 5625 Like FUNCADDR above, but also specifies the name of the source | 5886 Like FUNCADDR above, but also specifies the name of the source |
| 5626 file explicitly. This is useful if the name of the function | 5887 file explicitly. This is useful if the name of the function |
| 5627 does not specify the function unambiguously, e.g., if there | 5888 does not specify the function unambiguously, e.g., if there |
| 5628 are several functions with identical names in different | 5889 are several functions with identical names in different |
| 5629 source files. | 5890 source files. |
| 5630 | 5891 |
| 5892 `-pstap|-probe-stap [OBJFILE:[PROVIDER:]]NAME' |
| 5893 The GNU/Linux tool `SystemTap' provides a way for applications to |
| 5894 embed static probes. *Note Static Probe Points::, for more |
| 5895 information on finding and using static probes. This form of |
| 5896 linespec specifies the location of such a static probe. |
| 5897 |
| 5898 If OBJFILE is given, only probes coming from that shared library |
| 5899 or executable matching OBJFILE as a regular expression are |
| 5900 considered. If PROVIDER is given, then only probes from that |
| 5901 provider are considered. If several probes match the spec, GDB |
| 5902 will insert a breakpoint at each one of those probes. |
| 5903 |
| 5631 | 5904 |
| 5632 | 5905 |
| 5633 File: gdb.info, Node: Edit, Next: Search, Prev: Specify Location, Up: Source | 5906 File: gdb.info, Node: Edit, Next: Search, Prev: Specify Location, Up: Source |
| 5634 | 5907 |
| 5635 9.3 Editing Source Files | 5908 9.3 Editing Source Files |
| 5636 ======================== | 5909 ======================== |
| 5637 | 5910 |
| 5638 To edit the lines in a source file, use the `edit' command. The | 5911 To edit the lines in a source file, use the `edit' command. The |
| 5639 editing program of your choice is invoked with the current line set to | 5912 editing program of your choice is invoked with the current line set to |
| 5640 the active line in the program. Alternatively, there are several ways | 5913 the active line in the program. Alternatively, there are several ways |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6068 alternative format. | 6341 alternative format. |
| 6069 | 6342 |
| 6070 A more low-level way of examining data is with the `x' command. It | 6343 A more low-level way of examining data is with the `x' command. It |
| 6071 examines data in memory at a specified address and prints it in a | 6344 examines data in memory at a specified address and prints it in a |
| 6072 specified format. *Note Examining Memory: Memory. | 6345 specified format. *Note Examining Memory: Memory. |
| 6073 | 6346 |
| 6074 If you are interested in information about types, or about how the | 6347 If you are interested in information about types, or about how the |
| 6075 fields of a struct or a class are declared, use the `ptype EXP' command | 6348 fields of a struct or a class are declared, use the `ptype EXP' command |
| 6076 rather than `print'. *Note Examining the Symbol Table: Symbols. | 6349 rather than `print'. *Note Examining the Symbol Table: Symbols. |
| 6077 | 6350 |
| 6351 Another way of examining values of expressions and type information |
| 6352 is through the Python extension command `explore' (available only if |
| 6353 the GDB build is configured with `--with-python'). It offers an |
| 6354 interactive way to start at the highest level (or, the most abstract |
| 6355 level) of the data type of an expression (or, the data type itself) and |
| 6356 explore all the way down to leaf scalar values/fields embedded in the |
| 6357 higher level data types. |
| 6358 |
| 6359 `explore ARG' |
| 6360 ARG is either an expression (in the source language), or a type |
| 6361 visible in the current context of the program being debugged. |
| 6362 |
| 6363 The working of the `explore' command can be illustrated with an |
| 6364 example. If a data type `struct ComplexStruct' is defined in your C |
| 6365 program as |
| 6366 |
| 6367 struct SimpleStruct |
| 6368 { |
| 6369 int i; |
| 6370 double d; |
| 6371 }; |
| 6372 |
| 6373 struct ComplexStruct |
| 6374 { |
| 6375 struct SimpleStruct *ss_p; |
| 6376 int arr[10]; |
| 6377 }; |
| 6378 |
| 6379 followed by variable declarations as |
| 6380 |
| 6381 struct SimpleStruct ss = { 10, 1.11 }; |
| 6382 struct ComplexStruct cs = { &ss, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; |
| 6383 |
| 6384 then, the value of the variable `cs' can be explored using the |
| 6385 `explore' command as follows. |
| 6386 |
| 6387 (gdb) explore cs |
| 6388 The value of `cs' is a struct/class of type `struct ComplexStruct' with |
| 6389 the following fields: |
| 6390 |
| 6391 ss_p = <Enter 0 to explore this field of type `struct SimpleStruct *'> |
| 6392 arr = <Enter 1 to explore this field of type `int [10]'> |
| 6393 |
| 6394 Enter the field number of choice: |
| 6395 |
| 6396 Since the fields of `cs' are not scalar values, you are being prompted |
| 6397 to chose the field you want to explore. Let's say you choose the field |
| 6398 `ss_p' by entering `0'. Then, since this field is a pointer, you will |
| 6399 be asked if it is pointing to a single value. From the declaration of |
| 6400 `cs' above, it is indeed pointing to a single value, hence you enter |
| 6401 `y'. If you enter `n', then you will be asked if it were pointing to |
| 6402 an array of values, in which case this field will be explored as if it |
| 6403 were an array. |
| 6404 |
| 6405 `cs.ss_p' is a pointer to a value of type `struct SimpleStruct' |
| 6406 Continue exploring it as a pointer to a single value [y/n]: y |
| 6407 The value of `*(cs.ss_p)' is a struct/class of type `struct |
| 6408 SimpleStruct' with the following fields: |
| 6409 |
| 6410 i = 10 .. (Value of type `int') |
| 6411 d = 1.1100000000000001 .. (Value of type `double') |
| 6412 |
| 6413 Press enter to return to parent value: |
| 6414 |
| 6415 If the field `arr' of `cs' was chosen for exploration by entering `1' |
| 6416 earlier, then since it is as array, you will be prompted to enter the |
| 6417 index of the element in the array that you want to explore. |
| 6418 |
| 6419 `cs.arr' is an array of `int'. |
| 6420 Enter the index of the element you want to explore in `cs.arr': 5 |
| 6421 |
| 6422 `(cs.arr)[5]' is a scalar value of type `int'. |
| 6423 |
| 6424 (cs.arr)[5] = 4 |
| 6425 |
| 6426 Press enter to return to parent value: |
| 6427 |
| 6428 In general, at any stage of exploration, you can go deeper towards |
| 6429 the leaf values by responding to the prompts appropriately, or hit the |
| 6430 return key to return to the enclosing data structure (the higher level |
| 6431 data structure). |
| 6432 |
| 6433 Similar to exploring values, you can use the `explore' command to |
| 6434 explore types. Instead of specifying a value (which is typically a |
| 6435 variable name or an expression valid in the current context of the |
| 6436 program being debugged), you specify a type name. If you consider the |
| 6437 same example as above, your can explore the type `struct ComplexStruct' |
| 6438 by passing the argument `struct ComplexStruct' to the `explore' command. |
| 6439 |
| 6440 (gdb) explore struct ComplexStruct |
| 6441 |
| 6442 By responding to the prompts appropriately in the subsequent interactive |
| 6443 session, you can explore the type `struct ComplexStruct' in a manner |
| 6444 similar to how the value `cs' was explored in the above example. |
| 6445 |
| 6446 The `explore' command also has two sub-commands, `explore value' and |
| 6447 `explore type'. The former sub-command is a way to explicitly specify |
| 6448 that value exploration of the argument is being invoked, while the |
| 6449 latter is a way to explicitly specify that type exploration of the |
| 6450 argument is being invoked. |
| 6451 |
| 6452 `explore value EXPR' |
| 6453 This sub-command of `explore' explores the value of the expression |
| 6454 EXPR (if EXPR is an expression valid in the current context of the |
| 6455 program being debugged). The behavior of this command is |
| 6456 identical to that of the behavior of the `explore' command being |
| 6457 passed the argument EXPR. |
| 6458 |
| 6459 `explore type ARG' |
| 6460 This sub-command of `explore' explores the type of ARG (if ARG is |
| 6461 a type visible in the current context of program being debugged), |
| 6462 or the type of the value/expression ARG (if ARG is an expression |
| 6463 valid in the current context of the program being debugged). If |
| 6464 ARG is a type, then the behavior of this command is identical to |
| 6465 that of the `explore' command being passed the argument ARG. If |
| 6466 ARG is an expression, then the behavior of this command will be |
| 6467 identical to that of the `explore' command being passed the type |
| 6468 of ARG as the argument. |
| 6469 |
| 6078 * Menu: | 6470 * Menu: |
| 6079 | 6471 |
| 6080 * Expressions:: Expressions | 6472 * Expressions:: Expressions |
| 6081 * Ambiguous Expressions:: Ambiguous Expressions | 6473 * Ambiguous Expressions:: Ambiguous Expressions |
| 6082 * Variables:: Program variables | 6474 * Variables:: Program variables |
| 6083 * Arrays:: Artificial arrays | 6475 * Arrays:: Artificial arrays |
| 6084 * Output Formats:: Output formats | 6476 * Output Formats:: Output formats |
| 6085 * Memory:: Examining memory | 6477 * Memory:: Examining memory |
| 6086 * Auto Display:: Automatic display | 6478 * Auto Display:: Automatic display |
| 6087 * Print Settings:: Print settings | 6479 * Print Settings:: Print settings |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6257 you can examine and use the variable `a' whenever your program is | 6649 you can examine and use the variable `a' whenever your program is |
| 6258 executing within the function `foo', but you can only use or examine | 6650 executing within the function `foo', but you can only use or examine |
| 6259 the variable `b' while your program is executing inside the block where | 6651 the variable `b' while your program is executing inside the block where |
| 6260 `b' is declared. | 6652 `b' is declared. |
| 6261 | 6653 |
| 6262 There is an exception: you can refer to a variable or function whose | 6654 There is an exception: you can refer to a variable or function whose |
| 6263 scope is a single source file even if the current execution point is not | 6655 scope is a single source file even if the current execution point is not |
| 6264 in this file. But it is possible to have more than one such variable or | 6656 in this file. But it is possible to have more than one such variable or |
| 6265 function with the same name (in different source files). If that | 6657 function with the same name (in different source files). If that |
| 6266 happens, referring to that name has unpredictable effects. If you wish, | 6658 happens, referring to that name has unpredictable effects. If you wish, |
| 6267 you can specify a static variable in a particular function or file, | 6659 you can specify a static variable in a particular function or file by |
| 6268 using the colon-colon (`::') notation: | 6660 using the colon-colon (`::') notation: |
| 6269 | 6661 |
| 6270 FILE::VARIABLE | 6662 FILE::VARIABLE |
| 6271 FUNCTION::VARIABLE | 6663 FUNCTION::VARIABLE |
| 6272 | 6664 |
| 6273 Here FILE or FUNCTION is the name of the context for the static | 6665 Here FILE or FUNCTION is the name of the context for the static |
| 6274 VARIABLE. In the case of file names, you can use quotes to make sure | 6666 VARIABLE. In the case of file names, you can use quotes to make sure |
| 6275 GDB parses the file name as a single word--for example, to print a | 6667 GDB parses the file name as a single word--for example, to print a |
| 6276 global value of `x' defined in `f2.c': | 6668 global value of `x' defined in `f2.c': |
| 6277 | 6669 |
| 6278 (gdb) p 'f2.c'::x | 6670 (gdb) p 'f2.c'::x |
| 6279 | 6671 |
| 6280 This use of `::' is very rarely in conflict with the very similar | 6672 The `::' notation is normally used for referring to static |
| 6673 variables, since you typically disambiguate uses of local variables in |
| 6674 functions by selecting the appropriate frame and using the simple name |
| 6675 of the variable. However, you may also use this notation to refer to |
| 6676 local variables in frames enclosing the selected frame: |
| 6677 |
| 6678 void |
| 6679 foo (int a) |
| 6680 { |
| 6681 if (a < 10) |
| 6682 bar (a); |
| 6683 else |
| 6684 process (a); /* Stop here */ |
| 6685 } |
| 6686 |
| 6687 int |
| 6688 bar (int a) |
| 6689 { |
| 6690 foo (a + 5); |
| 6691 } |
| 6692 |
| 6693 For example, if there is a breakpoint at the commented line, here is |
| 6694 what you might see when the program stops after executing the call |
| 6695 `bar(0)': |
| 6696 |
| 6697 (gdb) p a |
| 6698 $1 = 10 |
| 6699 (gdb) p bar::a |
| 6700 $2 = 5 |
| 6701 (gdb) up 2 |
| 6702 #2 0x080483d0 in foo (a=5) at foobar.c:12 |
| 6703 (gdb) p a |
| 6704 $3 = 5 |
| 6705 (gdb) p bar::a |
| 6706 $4 = 0 |
| 6707 |
| 6708 These uses of `::' are very rarely in conflict with the very similar |
| 6281 use of the same notation in C++. GDB also supports use of the C++ | 6709 use of the same notation in C++. GDB also supports use of the C++ |
| 6282 scope resolution operator in GDB expressions. | 6710 scope resolution operator in GDB expressions. |
| 6283 | 6711 |
| 6284 _Warning:_ Occasionally, a local variable may appear to have the | 6712 _Warning:_ Occasionally, a local variable may appear to have the |
| 6285 wrong value at certain points in a function--just after entry to a | 6713 wrong value at certain points in a function--just after entry to a |
| 6286 new scope, and just before exit. | 6714 new scope, and just before exit. |
| 6287 You may see this problem when you are stepping by machine | 6715 You may see this problem when you are stepping by machine |
| 6288 instructions. This is because, on most machines, it takes more than | 6716 instructions. This is because, on most machines, it takes more than |
| 6289 one instruction to set up a stack frame (including local variable | 6717 one instruction to set up a stack frame (including local variable |
| 6290 definitions); if you are stepping by machine instructions, variables | 6718 definitions); if you are stepping by machine instructions, variables |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6632 for such situations. | 7060 for such situations. |
| 6633 | 7061 |
| 6634 `compare-sections [SECTION-NAME]' | 7062 `compare-sections [SECTION-NAME]' |
| 6635 Compare the data of a loadable section SECTION-NAME in the | 7063 Compare the data of a loadable section SECTION-NAME in the |
| 6636 executable file of the program being debugged with the same | 7064 executable file of the program being debugged with the same |
| 6637 section in the remote machine's memory, and report any mismatches. | 7065 section in the remote machine's memory, and report any mismatches. |
| 6638 With no arguments, compares all loadable sections. This command's | 7066 With no arguments, compares all loadable sections. This command's |
| 6639 availability depends on the target's support for the `"qCRC"' | 7067 availability depends on the target's support for the `"qCRC"' |
| 6640 remote request. | 7068 remote request. |
| 6641 | 7069 |
| 6642 | |
| 6643 File: gdb.info, Node: Auto Display, Next: Print Settings, Prev: Memory, Up:
Data | |
| 6644 | |
| 6645 10.7 Automatic Display | |
| 6646 ====================== | |
| 6647 | |
| 6648 If you find that you want to print the value of an expression frequently | |
| 6649 (to see how it changes), you might want to add it to the "automatic | |
| 6650 display list" so that GDB prints its value each time your program stops. | |
| 6651 Each expression added to the list is given a number to identify it; to | |
| 6652 remove an expression from the list, you specify that number. The | |
| 6653 automatic display looks like this: | |
| 6654 | |
| 6655 2: foo = 38 | |
| 6656 3: bar[5] = (struct hack *) 0x3804 | |
| 6657 | |
| 6658 This display shows item numbers, expressions and their current values. | |
| 6659 As with displays you request manually using `x' or `print', you can | |
| 6660 specify the output format you prefer; in fact, `display' decides | |
| 6661 whether to use `print' or `x' depending your format specification--it | |
| 6662 uses `x' if you specify either the `i' or `s' format, or a unit size; | |
| 6663 otherwise it uses `print'. | |
| 6664 | |
| 6665 `display EXPR' | |
| 6666 Add the expression EXPR to the list of expressions to display each | |
| 6667 time your program stops. *Note Expressions: Expressions. | |
| 6668 | |
| 6669 `display' does not repeat if you press <RET> again after using it. | |
| 6670 | |
| 6671 `display/FMT EXPR' | |
| 6672 For FMT specifying only a display format and not a size or count, | |
| 6673 add the expression EXPR to the auto-display list but arrange to | |
| 6674 display it each time in the specified format FMT. *Note Output | |
| 6675 Formats: Output Formats. | |
| 6676 | |
| 6677 `display/FMT ADDR' | |
| 6678 For FMT `i' or `s', or including a unit-size or a number of units, | |
| 6679 add the expression ADDR as a memory address to be examined each | |
| 6680 time your program stops. Examining means in effect doing `x/FMT | |
| 6681 ADDR'. *Note Examining Memory: Memory. | |
| 6682 | |
| 6683 For example, `display/i $pc' can be helpful, to see the machine | |
| 6684 instruction about to be executed each time execution stops (`$pc' is a | |
| 6685 common name for the program counter; *note Registers: Registers.). | |
| 6686 | |
| 6687 `undisplay DNUMS...' | |
| 6688 `delete display DNUMS...' | |
| 6689 Remove items from the list of expressions to display. Specify the | |
| 6690 numbers of the displays that you want affected with the command | |
| 6691 argument DNUMS. It can be a single display number, one of the | |
| 6692 numbers shown in the first field of the `info display' display; or | |
| 6693 it could be a range of display numbers, as in `2-4'. | |
| 6694 | |
| 6695 `undisplay' does not repeat if you press <RET> after using it. | |
| 6696 (Otherwise you would just get the error `No display number ...'.) | |
| 6697 | |
| 6698 `disable display DNUMS...' | |
| 6699 Disable the display of item numbers DNUMS. A disabled display | |
| 6700 item is not printed automatically, but is not forgotten. It may be | |
| 6701 enabled again later. Specify the numbers of the displays that you | |
| 6702 want affected with the command argument DNUMS. It can be a single | |
| 6703 display number, one of the numbers shown in the first field of the | |
| 6704 `info display' display; or it could be a range of display numbers, | |
| 6705 as in `2-4'. | |
| 6706 | |
| 6707 `enable display DNUMS...' | |
| 6708 Enable display of item numbers DNUMS. It becomes effective once | |
| 6709 again in auto display of its expression, until you specify | |
| 6710 otherwise. Specify the numbers of the displays that you want | |
| 6711 affected with the command argument DNUMS. It can be a single | |
| 6712 display number, one of the numbers shown in the first field of the | |
| 6713 `info display' display; or it could be a range of display numbers, | |
| 6714 as in `2-4'. | |
| 6715 | |
| 6716 `display' | |
| 6717 Display the current values of the expressions on the list, just as | |
| 6718 is done when your program stops. | |
| 6719 | |
| 6720 `info display' | |
| 6721 Print the list of expressions previously set up to display | |
| 6722 automatically, each one with its item number, but without showing | |
| 6723 the values. This includes disabled expressions, which are marked | |
| 6724 as such. It also includes expressions which would not be | |
| 6725 displayed right now because they refer to automatic variables not | |
| 6726 currently available. | |
| 6727 | |
| 6728 If a display expression refers to local variables, then it does not | |
| 6729 make sense outside the lexical context for which it was set up. Such an | |
| 6730 expression is disabled when execution enters a context where one of its | |
| 6731 variables is not defined. For example, if you give the command | |
| 6732 `display last_char' while inside a function with an argument | |
| 6733 `last_char', GDB displays this argument while your program continues to | |
| 6734 stop inside that function. When it stops elsewhere--where there is no | |
| 6735 variable `last_char'--the display is disabled automatically. The next | |
| 6736 time your program stops where `last_char' is meaningful, you can enable | |
| 6737 the display expression once again. | |
| 6738 | |
| 6739 | |
| 6740 File: gdb.info, Node: Print Settings, Next: Pretty Printing, Prev: Auto Displ
ay, Up: Data | |
| 6741 | |
| 6742 10.8 Print Settings | |
| 6743 =================== | |
| 6744 | |
| 6745 GDB provides the following ways to control how arrays, structures, and | |
| 6746 symbols are printed. | |
| 6747 | |
| 6748 These settings are useful for debugging programs in any language: | |
| 6749 | |
| 6750 `set print address' | |
| 6751 `set print address on' | |
| 6752 GDB prints memory addresses showing the location of stack traces, | |
| 6753 structure values, pointer values, breakpoints, and so forth, even | |
| 6754 when it also displays the contents of those addresses. The default | |
| 6755 is `on'. For example, this is what a stack frame display looks | |
| 6756 like with `set print address on': | |
| 6757 | |
| 6758 (gdb) f | |
| 6759 #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") | |
| 6760 at input.c:530 | |
| 6761 530 if (lquote != def_lquote) | |
| 6762 | |
| 6763 `set print address off' | |
| 6764 Do not print addresses when displaying their contents. For | |
| 6765 example, this is the same stack frame displayed with `set print | |
| 6766 address off': | |
| 6767 | |
| 6768 (gdb) set print addr off | |
| 6769 (gdb) f | |
| 6770 #0 set_quotes (lq="<<", rq=">>") at input.c:530 | |
| 6771 530 if (lquote != def_lquote) | |
| 6772 | |
| 6773 You can use `set print address off' to eliminate all machine | |
| 6774 dependent displays from the GDB interface. For example, with | |
| 6775 `print address off', you should get the same text for backtraces on | |
| 6776 all machines--whether or not they involve pointer arguments. | |
| 6777 | |
| 6778 `show print address' | |
| 6779 Show whether or not addresses are to be printed. | |
| 6780 | |
| 6781 When GDB prints a symbolic address, it normally prints the closest | |
| 6782 earlier symbol plus an offset. If that symbol does not uniquely | |
| 6783 identify the address (for example, it is a name whose scope is a single | |
| 6784 source file), you may need to clarify. One way to do this is with | |
| 6785 `info line', for example `info line *0x4537'. Alternately, you can set | |
| 6786 GDB to print the source file and line number when it prints a symbolic | |
| 6787 address: | |
| 6788 | |
| 6789 `set print symbol-filename on' | |
| 6790 Tell GDB to print the source file name and line number of a symbol | |
| 6791 in the symbolic form of an address. | |
| 6792 | |
| 6793 `set print symbol-filename off' | |
| 6794 Do not print source file name and line number of a symbol. This | |
| 6795 is the default. | |
| 6796 | |
| 6797 `show print symbol-filename' | |
| 6798 Show whether or not GDB will print the source file name and line | |
| 6799 number of a symbol in the symbolic form of an address. | |
| 6800 | |
| 6801 Another situation where it is helpful to show symbol filenames and | |
| 6802 line numbers is when disassembling code; GDB shows you the line number | |
| 6803 and source file that corresponds to each instruction. | |
| 6804 | |
| 6805 Also, you may wish to see the symbolic form only if the address being | |
| 6806 printed is reasonably close to the closest earlier symbol: | |
| 6807 | |
| 6808 `set print max-symbolic-offset MAX-OFFSET' | |
| 6809 Tell GDB to only display the symbolic form of an address if the | |
| 6810 offset between the closest earlier symbol and the address is less | |
| 6811 than MAX-OFFSET. The default is 0, which tells GDB to always | |
| 6812 print the symbolic form of an address if any symbol precedes it. | |
| 6813 | |
| 6814 `show print max-symbolic-offset' | |
| 6815 Ask how large the maximum offset is that GDB prints in a symbolic | |
| 6816 address. | |
| 6817 | |
| 6818 If you have a pointer and you are not sure where it points, try `set | |
| 6819 print symbol-filename on'. Then you can determine the name and source | |
| 6820 file location of the variable where it points, using `p/a POINTER'. | |
| 6821 This interprets the address in symbolic form. For example, here GDB | |
| 6822 shows that a variable `ptt' points at another variable `t', defined in | |
| 6823 `hi2.c': | |
| 6824 | |
| 6825 (gdb) set print symbol-filename on | |
| 6826 (gdb) p/a ptt | |
| 6827 $4 = 0xe008 <t in hi2.c> | |
| 6828 | |
| 6829 _Warning:_ For pointers that point to a local variable, `p/a' does | |
| 6830 not show the symbol name and filename of the referent, even with | |
| 6831 the appropriate `set print' options turned on. | |
| 6832 | |
| 6833 Other settings control how different kinds of objects are printed: | |
| 6834 | |
| 6835 `set print array' | |
| 6836 `set print array on' | |
| 6837 Pretty print arrays. This format is more convenient to read, but | |
| 6838 uses more space. The default is off. | |
| 6839 | |
| 6840 `set print array off' | |
| 6841 Return to compressed format for arrays. | |
| 6842 | |
| 6843 `show print array' | |
| 6844 Show whether compressed or pretty format is selected for displaying | |
| 6845 arrays. | |
| 6846 | |
| 6847 `set print array-indexes' | |
| 6848 `set print array-indexes on' | |
| 6849 Print the index of each element when displaying arrays. May be | |
| 6850 more convenient to locate a given element in the array or quickly | |
| 6851 find the index of a given element in that printed array. The | |
| 6852 default is off. | |
| 6853 | |
| 6854 `set print array-indexes off' | |
| 6855 Stop printing element indexes when displaying arrays. | |
| 6856 | |
| 6857 `show print array-indexes' | |
| 6858 Show whether the index of each element is printed when displaying | |
| 6859 arrays. | |
| 6860 | |
| 6861 `set print elements NUMBER-OF-ELEMENTS' | |
| 6862 Set a limit on how many elements of an array GDB will print. If | |
| 6863 GDB is printing a large array, it stops printing after it has | |
| 6864 printed the number of elements set by the `set print elements' | |
| 6865 command. This limit also applies to the display of strings. When | |
| 6866 GDB starts, this limit is set to 200. Setting NUMBER-OF-ELEMENTS | |
| 6867 to zero means that the printing is unlimited. | |
| 6868 | |
| 6869 `show print elements' | |
| 6870 Display the number of elements of a large array that GDB will | |
| 6871 print. If the number is 0, then the printing is unlimited. | |
| 6872 | |
| 6873 `set print frame-arguments VALUE' | |
| 6874 This command allows to control how the values of arguments are | |
| 6875 printed when the debugger prints a frame (*note Frames::). The | |
| 6876 possible values are: | |
| 6877 | |
| 6878 `all' | |
| 6879 The values of all arguments are printed. | |
| 6880 | |
| 6881 `scalars' | |
| 6882 Print the value of an argument only if it is a scalar. The | |
| 6883 value of more complex arguments such as arrays, structures, | |
| 6884 unions, etc, is replaced by `...'. This is the default. | |
| 6885 Here is an example where only scalar arguments are shown: | |
| 6886 | |
| 6887 #1 0x08048361 in call_me (i=3, s=..., ss=0xbf8d508c, u=..., e=gr
een) | |
| 6888 at frame-args.c:23 | |
| 6889 | |
| 6890 `none' | |
| 6891 None of the argument values are printed. Instead, the value | |
| 6892 of each argument is replaced by `...'. In this case, the | |
| 6893 example above now becomes: | |
| 6894 | |
| 6895 #1 0x08048361 in call_me (i=..., s=..., ss=..., u=..., e=...) | |
| 6896 at frame-args.c:23 | |
| 6897 | |
| 6898 By default, only scalar arguments are printed. This command can | |
| 6899 be used to configure the debugger to print the value of all | |
| 6900 arguments, regardless of their type. However, it is often | |
| 6901 advantageous to not print the value of more complex parameters. | |
| 6902 For instance, it reduces the amount of information printed in each | |
| 6903 frame, making the backtrace more readable. Also, it improves | |
| 6904 performance when displaying Ada frames, because the computation of | |
| 6905 large arguments can sometimes be CPU-intensive, especially in | |
| 6906 large applications. Setting `print frame-arguments' to `scalars' | |
| 6907 (the default) or `none' avoids this computation, thus speeding up | |
| 6908 the display of each Ada frame. | |
| 6909 | |
| 6910 `show print frame-arguments' | |
| 6911 Show how the value of arguments should be displayed when printing | |
| 6912 a frame. | |
| 6913 | |
| 6914 `set print entry-values VALUE' | |
| 6915 Set printing of frame argument values at function entry. In some | |
| 6916 cases GDB can determine the value of function argument which was | |
| 6917 passed by the function caller, even if the value was modified | |
| 6918 inside the called function and therefore is different. With | |
| 6919 optimized code, the current value could be unavailable, but the | |
| 6920 entry value may still be known. | |
| 6921 | |
| 6922 The default value is `default' (see below for its description). | |
| 6923 Older GDB behaved as with the setting `no'. Compilers not | |
| 6924 supporting this feature will behave in the `default' setting the | |
| 6925 same way as with the `no' setting. | |
| 6926 | |
| 6927 This functionality is currently supported only by DWARF 2 | |
| 6928 debugging format and the compiler has to produce | |
| 6929 `DW_TAG_GNU_call_site' tags. With GCC, you need to specify `-O | |
| 6930 -g' during compilation, to get this information. | |
| 6931 | |
| 6932 The VALUE parameter can be one of the following: | |
| 6933 | |
| 6934 `no' | |
| 6935 Print only actual parameter values, never print values from | |
| 6936 function entry point. | |
| 6937 #0 equal (val=5) | |
| 6938 #0 different (val=6) | |
| 6939 #0 lost (val=<optimized out>) | |
| 6940 #0 born (val=10) | |
| 6941 #0 invalid (val=<optimized out>) | |
| 6942 | |
| 6943 `only' | |
| 6944 Print only parameter values from function entry point. The | |
| 6945 actual parameter values are never printed. | |
| 6946 #0 equal (val@entry=5) | |
| 6947 #0 different (val@entry=5) | |
| 6948 #0 lost (val@entry=5) | |
| 6949 #0 born (val@entry=<optimized out>) | |
| 6950 #0 invalid (val@entry=<optimized out>) | |
| 6951 | |
| 6952 `preferred' | |
| 6953 Print only parameter values from function entry point. If | |
| 6954 value from function entry point is not known while the actual | |
| 6955 value is known, print the actual value for such parameter. | |
| 6956 #0 equal (val@entry=5) | |
| 6957 #0 different (val@entry=5) | |
| 6958 #0 lost (val@entry=5) | |
| 6959 #0 born (val=10) | |
| 6960 #0 invalid (val@entry=<optimized out>) | |
| 6961 | |
| 6962 `if-needed' | |
| 6963 Print actual parameter values. If actual parameter value is | |
| 6964 not known while value from function entry point is known, | |
| 6965 print the entry point value for such parameter. | |
| 6966 #0 equal (val=5) | |
| 6967 #0 different (val=6) | |
| 6968 #0 lost (val@entry=5) | |
| 6969 #0 born (val=10) | |
| 6970 #0 invalid (val=<optimized out>) | |
| 6971 | |
| 6972 `both' | |
| 6973 Always print both the actual parameter value and its value | |
| 6974 from function entry point, even if values of one or both are | |
| 6975 not available due to compiler optimizations. | |
| 6976 #0 equal (val=5, val@entry=5) | |
| 6977 #0 different (val=6, val@entry=5) | |
| 6978 #0 lost (val=<optimized out>, val@entry=5) | |
| 6979 #0 born (val=10, val@entry=<optimized out>) | |
| 6980 #0 invalid (val=<optimized out>, val@entry=<optimized out>) | |
| 6981 | |
| 6982 `compact' | |
| 6983 Print the actual parameter value if it is known and also its | |
| 6984 value from function entry point if it is known. If neither | |
| 6985 is known, print for the actual value `<optimized out>'. If | |
| 6986 not in MI mode (*note GDB/MI::) and if both values are known | |
| 6987 and identical, print the shortened `param=param@entry=VALUE' | |
| 6988 notation. | |
| 6989 #0 equal (val=val@entry=5) | |
| 6990 #0 different (val=6, val@entry=5) | |
| 6991 #0 lost (val@entry=5) | |
| 6992 #0 born (val=10) | |
| 6993 #0 invalid (val=<optimized out>) | |
| 6994 | |
| 6995 `default' | |
| 6996 Always print the actual parameter value. Print also its | |
| 6997 value from function entry point, but only if it is known. If | |
| 6998 not in MI mode (*note GDB/MI::) and if both values are known | |
| 6999 and identical, print the shortened `param=param@entry=VALUE' | |
| 7000 notation. | |
| 7001 #0 equal (val=val@entry=5) | |
| 7002 #0 different (val=6, val@entry=5) | |
| 7003 #0 lost (val=<optimized out>, val@entry=5) | |
| 7004 #0 born (val=10) | |
| 7005 #0 invalid (val=<optimized out>) | |
| 7006 | |
| 7007 For analysis messages on possible failures of frame argument | |
| 7008 values at function entry resolution see *Note set debug | |
| 7009 entry-values::. | |
| 7010 | |
| 7011 `show print entry-values' | |
| 7012 Show the method being used for printing of frame argument values | |
| 7013 at function entry. | |
| 7014 | |
| 7015 `set print repeats' | |
| 7016 Set the threshold for suppressing display of repeated array | |
| 7017 elements. When the number of consecutive identical elements of an | |
| 7018 array exceeds the threshold, GDB prints the string `"<repeats N | |
| 7019 times>"', where N is the number of identical repetitions, instead | |
| 7020 of displaying the identical elements themselves. Setting the | |
| 7021 threshold to zero will cause all elements to be individually | |
| 7022 printed. The default threshold is 10. | |
| 7023 | |
| 7024 `show print repeats' | |
| 7025 Display the current threshold for printing repeated identical | |
| 7026 elements. | |
| 7027 | |
| 7028 `set print null-stop' | |
| 7029 Cause GDB to stop printing the characters of an array when the | |
| 7030 first NULL is encountered. This is useful when large arrays | |
| 7031 actually contain only short strings. The default is off. | |
| 7032 | |
| 7033 `show print null-stop' | |
| 7034 Show whether GDB stops printing an array on the first NULL | |
| 7035 character. | |
| 7036 | |
| 7037 `set print pretty on' | |
| 7038 Cause GDB to print structures in an indented format with one member | |
| 7039 per line, like this: | |
| 7040 | |
| 7041 $1 = { | |
| 7042 next = 0x0, | |
| 7043 flags = { | |
| 7044 sweet = 1, | |
| 7045 sour = 1 | |
| 7046 }, | |
| 7047 meat = 0x54 "Pork" | |
| 7048 } | |
| 7049 | |
| 7050 `set print pretty off' | |
| 7051 Cause GDB to print structures in a compact format, like this: | |
| 7052 | |
| 7053 $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \ | |
| 7054 meat = 0x54 "Pork"} | |
| 7055 | |
| 7056 This is the default format. | |
| 7057 | |
| 7058 `show print pretty' | |
| 7059 Show which format GDB is using to print structures. | |
| 7060 | |
| 7061 `set print sevenbit-strings on' | |
| 7062 Print using only seven-bit characters; if this option is set, GDB | |
| 7063 displays any eight-bit characters (in strings or character values) | |
| 7064 using the notation `\'NNN. This setting is best if you are | |
| 7065 working in English (ASCII) and you use the high-order bit of | |
| 7066 characters as a marker or "meta" bit. | |
| 7067 | |
| 7068 `set print sevenbit-strings off' | |
| 7069 Print full eight-bit characters. This allows the use of more | |
| 7070 international character sets, and is the default. | |
| 7071 | |
| 7072 `show print sevenbit-strings' | |
| 7073 Show whether or not GDB is printing only seven-bit characters. | |
| 7074 | |
| 7075 `set print union on' | |
| 7076 Tell GDB to print unions which are contained in structures and | |
| 7077 other unions. This is the default setting. | |
| 7078 | |
| 7079 `set print union off' | |
| 7080 Tell GDB not to print unions which are contained in structures and | |
| 7081 other unions. GDB will print `"{...}"' instead. | |
| 7082 | |
| 7083 `show print union' | |
| 7084 Ask GDB whether or not it will print unions which are contained in | |
| 7085 structures and other unions. | |
| 7086 | |
| 7087 For example, given the declarations | |
| 7088 | |
| 7089 typedef enum {Tree, Bug} Species; | |
| 7090 typedef enum {Big_tree, Acorn, Seedling} Tree_forms; | |
| 7091 typedef enum {Caterpillar, Cocoon, Butterfly} | |
| 7092 Bug_forms; | |
| 7093 | |
| 7094 struct thing { | |
| 7095 Species it; | |
| 7096 union { | |
| 7097 Tree_forms tree; | |
| 7098 Bug_forms bug; | |
| 7099 } form; | |
| 7100 }; | |
| 7101 | |
| 7102 struct thing foo = {Tree, {Acorn}}; | |
| 7103 | |
| 7104 with `set print union on' in effect `p foo' would print | |
| 7105 | |
| 7106 $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}} | |
| 7107 | |
| 7108 and with `set print union off' in effect it would print | |
| 7109 | |
| 7110 $1 = {it = Tree, form = {...}} | |
| 7111 | |
| 7112 `set print union' affects programs written in C-like languages and | |
| 7113 in Pascal. | |
| 7114 | |
| 7115 These settings are of interest when debugging C++ programs: | |
| 7116 | |
| 7117 `set print demangle' | |
| 7118 `set print demangle on' | |
| 7119 Print C++ names in their source form rather than in the encoded | |
| 7120 ("mangled") form passed to the assembler and linker for type-safe | |
| 7121 linkage. The default is on. | |
| 7122 | |
| 7123 `show print demangle' | |
| 7124 Show whether C++ names are printed in mangled or demangled form. | |
| 7125 | |
| 7126 `set print asm-demangle' | |
| 7127 `set print asm-demangle on' | |
| 7128 Print C++ names in their source form rather than their mangled | |
| 7129 form, even in assembler code printouts such as instruction | |
| 7130 disassemblies. The default is off. | |
| 7131 | |
| 7132 `show print asm-demangle' | |
| 7133 Show whether C++ names in assembly listings are printed in mangled | |
| 7134 or demangled form. | |
| 7135 | |
| 7136 `set demangle-style STYLE' | |
| 7137 Choose among several encoding schemes used by different compilers | |
| 7138 to represent C++ names. The choices for STYLE are currently: | |
| 7139 | |
| 7140 `auto' | |
| 7141 Allow GDB to choose a decoding style by inspecting your | |
| 7142 program. | |
| 7143 | |
| 7144 `gnu' | |
| 7145 Decode based on the GNU C++ compiler (`g++') encoding | |
| 7146 algorithm. This is the default. | |
| 7147 | |
| 7148 `hp' | |
| 7149 Decode based on the HP ANSI C++ (`aCC') encoding algorithm. | |
| 7150 | |
| 7151 `lucid' | |
| 7152 Decode based on the Lucid C++ compiler (`lcc') encoding | |
| 7153 algorithm. | |
| 7154 | |
| 7155 `arm' | |
| 7156 Decode using the algorithm in the `C++ Annotated Reference | |
| 7157 Manual'. *Warning:* this setting alone is not sufficient to | |
| 7158 allow debugging `cfront'-generated executables. GDB would | |
| 7159 require further enhancement to permit that. | |
| 7160 | |
| 7161 If you omit STYLE, you will see a list of possible formats. | |
| 7162 | |
| 7163 `show demangle-style' | |
| 7164 Display the encoding style currently in use for decoding C++ | |
| 7165 symbols. | |
| 7166 | |
| 7167 `set print object' | |
| 7168 `set print object on' | |
| 7169 When displaying a pointer to an object, identify the _actual_ | |
| 7170 (derived) type of the object rather than the _declared_ type, using | |
| 7171 the virtual function table. Note that the virtual function table | |
| 7172 is required--this feature can only work for objects that have | |
| 7173 run-time type identification; a single virtual method in the | |
| 7174 object's declared type is sufficient. | |
| 7175 | |
| 7176 `set print object off' | |
| 7177 Display only the declared type of objects, without reference to the | |
| 7178 virtual function table. This is the default setting. | |
| 7179 | |
| 7180 `show print object' | |
| 7181 Show whether actual, or declared, object types are displayed. | |
| 7182 | |
| 7183 `set print static-members' | |
| 7184 `set print static-members on' | |
| 7185 Print static members when displaying a C++ object. The default is | |
| 7186 on. | |
| 7187 | |
| 7188 `set print static-members off' | |
| 7189 Do not print static members when displaying a C++ object. | |
| 7190 | |
| 7191 `show print static-members' | |
| 7192 Show whether C++ static members are printed or not. | |
| 7193 | |
| 7194 `set print pascal_static-members' | |
| 7195 `set print pascal_static-members on' | |
| 7196 Print static members when displaying a Pascal object. The default | |
| 7197 is on. | |
| 7198 | |
| 7199 `set print pascal_static-members off' | |
| 7200 Do not print static members when displaying a Pascal object. | |
| 7201 | |
| 7202 `show print pascal_static-members' | |
| 7203 Show whether Pascal static members are printed or not. | |
| 7204 | |
| 7205 `set print vtbl' | |
| 7206 `set print vtbl on' | |
| 7207 Pretty print C++ virtual function tables. The default is off. | |
| 7208 (The `vtbl' commands do not work on programs compiled with the HP | |
| 7209 ANSI C++ compiler (`aCC').) | |
| 7210 | |
| 7211 `set print vtbl off' | |
| 7212 Do not pretty print C++ virtual function tables. | |
| 7213 | |
| 7214 `show print vtbl' | |
| 7215 Show whether C++ virtual function tables are pretty printed, or | |
| 7216 not. | |
| 7217 | |
| OLD | NEW |