GDB debugging under "Go" Linux

Source: Internet
Author: User

This article is written to programmers who work mainly in Windows operating systems and who need to develop some cross-platform software, as well as program enthusiasts.

GDB is a lot of commands, but we only need to grasp the 10 or so of the commands, you can generally complete the routine basic program debugging work.

Command Explain Example
File < file name > Loads the executable program files that are being debugged.
Because GDB is typically executed in the same directory as the debugger, the text name does not need to have a path.
(gdb) file Gdb-sample
R Run the shorthand for running the program that is being debugged.
If the breakpoint has not been previously, the entire program is executed, and if there is a breakpoint, the program pauses at the first available breakpoint.
(GDB) R
c continue, continue executing the debugged program until the next breakpoint or program ends. (GDB) c
b < line;
b < function name;
b *< function name;
b *< code address;

d [number]

b:breakpoint shorthand, set breakpoints. You can specify the breakpoint location by using the line number function name "Execute address" and so on.

d:delete breakpoint, deletes a breakpoint of the specified number, or removes all breakpoints. The breakpoint number increments from 1 onwards.

(GDB) b 8
Span style= "FONT-SIZE:14PX;" > (GDB) b main

(GDB ) b *0x804835c

(GDB) d

s, n s: Executes a line of source code and enters the function if there is a function call in this line of code;
n: Executes a line of source code, and the function calls in this line of code are executed in conjunction.

s equivalent to "Step into (Single Step Into)" in other debuggers;
n equals "step Over" in other debuggers.

(GDB) s
Span style= "FONT-SIZE:14PX;" > (GDB) n
Si, ni The SI command resembles the S command, and the NI command resembles the n command. The difference is that the two commands (Si/ni) are for assembly instructions, and S/n is for the source code. (GDB) Si
(gdb) NI
P < variable name > A shorthand for print that displays the value of the specified variable (temporary or global variable). (GDB) P I
(GDB) P Nglobalvar
display ...

undisplay < numbering;

display, sets the data to be displayed after the program is interrupted and its format.
For example, if you want to see the next assembly instruction that will be executed each time the program breaks, you can use the command
"display/i $pc"

undispaly, cancels the previous display settings, incrementing the numbering starting from 1.

I For info, please refer to "Help me" for details. (GDB) I R
Q Quit, exit the GDB debugging environment. (GDB) Q
Help [command name] GDB Help command that provides an explanation of the GDB name commands.
If the command name argument is specified, a detailed description of the command is displayed, and if no parameters are specified, the category displays all GDB commands for further browsing and querying by the user.
(GDB) Help display

GDB debugging under "Go" Linux

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.