There are a lot of command programs in the Linux system to help the system run normally and conveniently. Then there is a program called gdb command in the system, then let us know about the gdb command today!
First, regular debugging
gdb is a commonly used program debugging tool under Linux, of course, the premise is to use gcc/g++ to compile with -g parameter, so that the compiled executable program will add gdb Debug information.
The gdb command is quite a lot, but the commonly used commands include the following commands:
(1)list [file:]functuon
The command abbreviation is l, view the source code, do not add When the parameter is displayed, the source code is displayed downward. When the parameter -l is added, the source code is displayed upwards, and the default display is 10 lines.
It is also possible to set the source code listed in a function. Note that if it is a non-member function, use file:function. If it is a class member function, use class::functuon.
(2)edit [file:]function
The command abbreviation is e, edit the current line, or edit the source code of a function (rules with list).
(3)break [file:]function
The command abbreviation is b, set a breakpoint, can be set in a line or a function (rules with list), in addition to direct Set the breakpoint with the file name: line number.
(4)info
The command abbreviation is i, which lists information about gdb subcommands, such as info break, info variables, info stack, etc.
(5)run [arglist]
The command abbreviation is r, the program is stopped at the breakpoint, and the parameters required by the debugger can be added after the run command.
(6) next
The command abbreviation is n, single-step debugging execution statement, if a function is encountered, it is also a single-step statement without entering the function, similar to F10 in VC.
(7) step
The command abbreviation is s, single-step debugging execution statement, if you encounter a function, it will directly enter the function, similar to F11 in VC.
(8) continue
The fame and fortune is c, continue to run the program to the next breakpoint.
(9)what
View the variable type.
(10)print
The command abbreviation is p, the value of the print variable.
(11)backtrace
The command abbreviation is bt, which looks at the stack information.
(12) enter
Enter the previous debug command.
(13)help [name]
Displays help information for the specified gdb command.
(14)quit
The command abbreviation is q, exiting gdb.
When gdb debugs the running program, load the program with gdb.exe. When gdb debugs the core dump, load the program with gdb.exe .core and execute the r command to start running the program. After editing the code in gdb, you don't need to exit gdb, but you can make it directly in gdb, otherwise the information such as the breakpoints set before will be burned.
Second, multi-threaded debugging
(1) info threads
The command abbreviation is info thr, showing all threads currently debuggable, each thread will have a gdb The ID of the allocation, this ID will be used when the thread is operated later, and the thread that is currently being debugged is *.
(2)thread ID
The command abbreviation is thr, which switches the thread currently debugging to the thread with the specified ID.
(3) thread apply ID1 ID2 command
The command abbreviation rule is the same as above, let one or more threads execute the gdb command command.
(4)thread apply all command
The command abbreviation rules are the same as above, so that all debug threads execute the gdb command command.
(5)set scheduler-locking off
win7 There are a lot of tricks, if used well, can make the win7 system get no small optimization. No
Devil-Linux is a special Linux distribution for firewalls and routers. The goal of Devil-Linux is to
STM32F103VCT6 comes with two 12-bit DAC, DAC conversion speed has not been found, some people say th
Linux supports sharing open files between different processes. To illustrate file sharing, lets firs
After linux2.6.38, the kernel version calls open
Overview of the Role of the Linux Kernel
The 20 advantages of Linux and Windows
Linux device driver learning (0)-Hello, world! Module
Linux system management and maintenance - mount /umount command
Linux command introduction: VI command application highlights
ECmall how to add users in bulk
Win7 Ultimate system features three systems of
Linux system to find ways to replace non-UTF-8 encoded files
Upgrade genuine Windows 10 is very simple 10 years old can easily complete
Cool my music off today watch method tutorial
How to customize the power button
Win8 software selection: gadgets can also play a big role