Linux Debugger Gdb__linux

Source: Internet
Author: User

Linux Debugger GdB

First, GDB introduction

The debugger in the GNU toolset is GDB, the program is an interactive tool that works in character mode.

In addition to GDB, Linux is more well-known under the debugger and Xxgdb, DDD, kgdb, UPS.

second, the use of GDB

GDB is a powerful debugger that completes the following debugging tasks:

1. Set breakpoints

Break line number//run to a line stop

Break function name//stop when run to specified function function

Break line number/function name if condition//Match if condition statement, run to specified location stop

2, the value of the monitor variable

Print variable name/expression

Whatis variable name/function name//display data type

PType variable name/function name//display data type and definition

3. Single step execution of the program

4, Show/Modify the value of the variable

5. Display/Modify Registers

6, view the stack of the program

7. Remote Debugging



Q exit

List shows the code following the current line

Parameters:

+ Shows the code following the current line number

-Displays the code before the current line number

N shows the code around the first few lines

The function name shows the internal code of the function name

First,last shows code between the last

, last chevalier code between the current line and the last

Set Listsize count sets the number of lines of code to display at one time

Show Listsize shows the number of rows displayed at one time

first to add debugging information before use: Gcc–g test.c–o test

after: GDB test

and then you can debug it by command.

Eg:

 

Debugging Information:



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.