GDB series of three GDB commands

Source: Internet
Author: User
Tags aliases



If the abbreviation is unambiguous, you can abbreviate a GDB command to a few letters at the beginning, or you can repeat the GDB command with the ENTER key. You can also

Use the TAP key to make gdb complete the remainder of a command (or to tell you which commands to choose, if more than one command is optional).

3.1 Command syntax
A GDB command is a separate input line. There is no length limit. The command starts with a command name, followed by the arguments supplied to the command. For example, the command step receives
A parameter that represents the step size, just like "step 5″." You can also use the step command without parameters. Some commands do not allow parameters.
GDB command names always allow truncation in the absence of ambiguity. In some cases, even ambiguous abbreviations are allowed, for example, S is an abbreviation defined specifically for step, even if there are other commands that start with S. You can test them with these abbreviations as parameters of the help command.
The input of a blank line (enter enter) is meant for GDB to repeat the previous command. Some commands, such as run, cannot be repeated in this way; These commands inadvertently repeat can cause trouble or you don't want to repeat them. User-defined commands can close these feature, see section 20.1.1 [definition], 227 pages.
The list and X commands, when you repeat them with the ENTER key, construct new instead of repeating the previously entered parameters. This feature makes it easy to scan code and memory.
GDB can also use the return key in a different way to differentiate long outputs (see section 19.4 [Screen size], 219 pages) in a similar way to common tools. Since in this case it is easy to press too many return key, GDB turns off the command repetition function when the long output is generated.
The text from # to the end of the line is a comment, and the text doesn't do anything. They are primarily in the command file to help understand the role (see 20.1.3 [command file], 229 pages).

Ctrl-o binding is useful for repeating complex command sequences. This command accepts a current line, such as a carriage return, and then edits from the command history to the next line in the current row.
3.2 Command Completion
GDB can fill the remainder of the command for you, and if there is only one possible command, it can also show you the valid possible values for the next word in a command at any time. The command completion function is valid for GDB commands, subcommands, and symbols in your program.
Whenever you want GDB to fill a word, press the TAB key. If there is only one possibility, GDB will fill the word and wait for you to complete the command (press ENTER). For example, if you typed
(GDB) Info bre <TABi>
GDB complements the remainder of ' breakpoints ' because only the INFO subcommand begins with ' bre ':
(GDB) Info breakpoints
Now you can hit the ENTER key to run the info Breakpoints command, and if ' breakpoints ' doesn't look like you expect, you can use the fallback button to delete it and then enter something else. , if ' breakpoints ' doesn't look like you expect. (If at the beginning you are sure that you want to be info breakpoints, you can use the abbreviated form to run the ' info bre ' without waiting for the command to complete and then enter).
If you have a candidate when you press the TAB key, GDB emits a ringtone. You can enter a few more characters and try again, or press TAB once more.
GDB will show you all possible completion candidates. For example, you might want to set a breakpoint in the ' Make_ ' sub-function at the beginning of a name, and when you hit B make_<tab>, GdB makes a sound. Re-typing the <TAB> key will show all functions beginning with make_, for example:
(GDB) b make_ <TAB>
GDB sounds bell; Press Htabi again, to see:
Make_a_section_from_file Make_environ
Make_abs_section Make_function_type
Make_blockvector Make_pointer_type
Make_cleanup Make_reference_type
Make_command make_symbol_completion_list
(GDB) B make_
After displaying all possible candidates, GDB will copy the input you just made (' B make_ ' in this case) so that you can complete the command.
If you just want to look at the candidate list at the beginning, you can press M--rather than press <TAB> two times. M-? is <meta> You can hold it while you're typing.
<META> (if there is a key on the keyboard), if you do not have this key, you can press <ESC> and then press? to replace.
Sometimes the string you need may contain parentheses, or gdb thinks the string is not a word. In order for the completion function to take effect in this case, you can use the '
(single brackets) to seal up.
This situation is most likely to occur when you type a C + + function name. This is because C + + allows function overloading (the same function name is defined more than once, and is distinguished by the parameter type). For example, when you set a breakpoint on a function named name, you need to distinguish between the function name on which the argument is int or the function name with the parameter float to set the breakpoint. In order to use the word completion function, a single quotation mark is typed before the function name. This allows gdb to know more about the need to consider a <TAB> or M-based comparison than usually:
(GDB) b. ˉbubble (M-?
Bubble (double,double) Bubble (int,int)
(GDB) b. ˉbubble (
In some cases where completion is required, GDB can prompt you to need quotation marks. At this point, if you do not start with the quotation marks, GDB will insert a quotation mark for you:
(GDB) B bub <TAB>
GDB will alert you with the following output and then sound:
(gdb) b ' Bubble (
Usually, in the case of overloaded symbols, when you do not start typing the parameter list with the completion function, the GDB prompt requires a quotation mark and then inserts it.
For more information about overloaded functions, see 12.4.1.3 Section [C + + expression],126 page. You can turn off the overloaded solution with the set Overload-resolution off command, see Section 12.4.1.7, [GdB C + + features], 128 pages.

3.3 Help
With the Help function, you can get GDB command information.
Help
H You can use Help (abbreviation h) to display a short list of command classifications without parameters.
(GDB) Help
List of classes of commands:
Aliases-aliases of OTHER commands
Breakpoints-making program stop at certain points
Data-examining data
Files-specifying and examining files
Internals-maintenance commands
Obscure-obscure Features
Running-running the program
Stack-examining the Stack
Status-status Inquiries
Support-support Facilities
Tracepoints-tracing of program execution without
Stopping the program
user-defined-user-defined commands
Type ' help ' followed by a class name for a list of
Commands in that class.
Type ' help ' followed by command name-for-full
Documentation.
Command name abbreviations is allowed if unambiguous.
(GDB)
Help class
Using the Help category as a parameter, you can get a list of commands in this category. For example, the following is the help display for the status category:
(GDB) Help status
Status inquiries.
List of commands:
Info-generic command for showing things
About the program being debugged
Show-generic command for showing things
About the DEBUGGER&LT;BR
/> Type ' help ' followed by command name-for-full
Documentation.
Command name abbreviations is allowed if unambiguous.
(GDB)
Help command
With the command-key parameter, GDB displays a section of information on how to use this command.
Apropos args
The apropos command searches the commands and documents for the regular expression specified by args. This command prints all the matching results. For example:
Apropos Reload
Results:
Set Symbol-reloading-set dynamic symbol table reloading
Multiple times in one run
Show symbol-reloading-show dynamic symbol table reloading
Multiple times in one run
Complete args
The complete args command lists all possible completion results. Use args to specify the beginning letter of the command you want. For example:
Complete I
Results:
If
Ignore
Info
Inspect
This was designed for GNU Emacs.
Further, you can use GDB command info and show to query the state of your program or the state of GDB itself. Both commands support multiple topic queries, and the manual will be presented at the appropriate time. The info in the index and the list under Show lists all the subcommands. See [index], page 407.
Info This command (abbreviated I) can describe the state of the program. For example, you can use info args to display arguments passed to a function, using info registers to list
Register data, use info breakpoints to list the breakpoints you set. You can use Help info to get all the subcommands for info.
Sets you can use the SET command to set an environment variable for the value of an expression. For example, you can set the GDB prompt with Set prompt $.
Unlike show and info, show describes the state of GDB itself. You can use the SET command to change most of what you can show with show. For example, you can use set
Radix to set the displayed numeric input system, or show radix to display the numerical value.
You can use the show command without parameters to display all parameters that can be set and their values; You can also use info set. The two commands are the same.
There are also the remaining 3 show subcommands, which lack the corresponding set command in the 3 command:
Show version
Displays the current GDB version. You should include the version information in the GDB bug report. If you have multiple versions of GDB on your machine, you may need to know which version
This is what you are running; as GDB develops, new commands will be introduced, and some old ones will be discarded. At the same time, many system vendors migrated different versions of the
GDB also has multiple versions of GDB in the Gnu/linux release. The version number is the same as when you started it.
Show copying
Info copying
Displays GDB copyright information.
Show warranty
Info warranty
Show the GNU disclaimer, or make sure (if your GDB version has one).

<br

<br
Reprint http://zhiwei.li/text/2010/01/gdb%E6%89%8B%E5%86%8C3gdb%E5%91%BD%E4%BB%A4/

<br
If you have copyright issues, please contact QQ 858668791

<br

<br

GDB series of three GDB commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.