GDB View Source Program

Source: Internet
Author: User
Keywords source program nbsp; source code GDB view
Tags *.h file code compile compiling course display displays file

Show source code

GDB can print out the source code of the program being debugged, and of course, when compiling the program, it must add-g parameter to compile the source program information into the execution file. Otherwise you will not see the source program. When the program stops, GDB reports that the program is parked on the first line of that file. You can use the List command to print the source code of the program. Let's take a look at the GDB command to view the source code.

List <linenum>

Displays the source program around the LineNum line.

List <function>

Displays the source program for the function named function.

List

Displays the source program after the current line.

List-

Displays the source program before the current line.

Generally print the current line of the top 5 lines and the next 5 lines, if the display function is 2 lines under 8 lines, the default is 10 lines, of course, you can also customize the scope of the display, use the following command to set the number of lines to display the source program.

Set Listsize <count>

Sets the number of lines to display the source code at once.

Show Listsize

View the settings for the current listsize.

The list command also has the following usage:

List <first> <last>

Displays the source code from the beginning to the last row.

List, <last>

Displays the source code from the current line to the last row.

List +

Display the source code later.

In general, the following parameters can be followed in the list:

<linenum>&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; Line number.
<+offset> the positive offset of the current line number.
<-offset> negative offset of current line number.
<filename:linenum> which row of which file.
<function> function name.
<filename:function> which function in which file.
The address of the statement in memory at the time the <*address> program runs.

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.