Gcc: GNUCCompiler

Source: Internet
Author: User
Tags gdb debugger
Gcc: GNUCCompiler-general Linux technology-Linux programming and kernel information. For details, refer to the following section. All extensions supported by gcc:

. A static object library

Gcc-c hellofirst. c hellosecond. c

Ar-r libhello. a hellofirst. o hellosecond. o

C language source code to be preprocessed in. c

. H header file of C language source code

. I c language source code without preprocessing. This type of file is an intermediate product of the compilation process.

Gcc-E helloworld. c-o helloworld. I

. O target file. The format is consistent with the application connection. This type of file is an intermediate product of the compilation process.

Gcc-c helloworld. c

. S assembly language code ). This type of file is an intermediate product of the compilation process.

Gcc-S helloworld. c-o helloworld. s

. So shared object library)

Gcc-c-fpic hellofirst. c hellosecond. c

Gcc-shared hellofirst. c hellosecond. c-o hello. so

Gdb debugger

1. debugging information format

To be able to debug the program, it is necessary to include program-related information in the target file. With this information, the debugger can associate the source code with executable code and provide information about the program in the format to get a definite picture of the action of the program.

The information stored in the target file can be in various formats: STABS, DWARF, COFF, and XCOFF.

2. debugging information level

To enable the debugger to connect binary executable code and source code-display understandable information-the Compilation Program must only include the information in the target code. You can set the command line option to specify the number and type of information contained ----g [level]

1. At this level, the information inserted to the target code is minimal. Although this information is sufficient to track function calls and check global variables, there is no executable code and source code information, and there is not enough information to check local variables.

2. This is the default level. This level includes all information of level 1, and also adds necessary information from the source code line to the executable code, as well as the name and location of the local variable.

3. This level includes all information of level 1 and level 2, and additional information, including pre-processing macro definition

Gdb command

When awatch sets a viewing point, the program stops running whenever the value at the specified position is read or written. See rwatch and watch

Backtrace prints the stack content to display the function calls and parameter values that take the program to the current position. This command can be abbreviated as bt

When a breakpoint is set for a break, the program is interrupted at the specified row or function name.

Clear clears the breakpoint on a line or function, which is initially set by the break command

The execution of the continue program is interrupted by the debugger.

Ctrl-C breaks the running program, just as if the breakpoint is set for the current row.

Disable: disable breakpoints listed by number

Display displays the value of the specified expression when each program is interrupted

Enable activates a breakpoint by number

Finish continues to run the program interrupted by the debugger and continues until the current function returns

Ignore sets the number of ignored breakpoints. For example, the ignore 4 23 command can be interrupted only when the breakpoint 4 is run 23 times.

Info breakpoints lists the status and description, including the number of all breakpoints

Info display lists the status and description, including the number of the display command defined earlier

Kill the running process

List to list 10 lines of code. If there are no parameters in the command, list the 10 rows after the current row. If a function is specified, 10 rows of the function are listed. If a row number is specified, the row number is in the middle of the list.

Load dynamically loads the specified executable file into gdb and prepares to debug the program.

Next, continue to run the interrupted program and run the commands in the source code in sequence, but regard the function call as a line of code and will not stop until the function returns

Nexti continues to run the interrupted program and runs an assembly instruction code. However, it regards the function call as a line of code and does not stop until the function returns

Print immediately displays the value of the specified expression

Ptype: displays the type of the specified project

Return forcibly returns immediately from the current function

Run the Startup Program and run the program from the starting position

Rwatch sets the viewing point. The operation can be interrupted as long as the specified position is read.

Set assigns the specified variable value to the expression. For example, set nval = 54 saves the value 54 to the position where nval is in the memory.

Step: continue to execute the interrupted program and run the commands in the source code in sequence. It will enter the called Function

Stepi continues executing the interrupted program and runs the Assembly Language commands in sequence. It will enter the called Function

Txbreak sets a temporary breakpoint at the current function exit (only once ). See xbreak

Undisplay: deletes the display expression specified by a number.

Watch sets the viewing point. As long as it is written to the specified position, the program can be interrupted.

Whatis prints the data type and the value of the specified expression

Xbreak sets a breakpoint at the exit of the current function.
Related Article

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.