GDB debugging in Linux

Source: Internet
Author: User

1. Introduction to GDB:

The GNU Debugger, called GDB, is an interactive tool that works in character mode. Many programmers are used to program development with graphical interfaces, such as integrated development environments such as Vc and VB. However, GDB is more powerful in Unix/Linux environments.

As a powerful debugging tool, GDB can complete the following debugging tasks:

(1) set the breakpoint.

(2) value of the monitoring program variable.

(3) One-step execution of the program.

(4) modify the value of a variable.

 

2. Use of GDB

 

Common gdb commands:

A) load the application:

 

GDB test (load application)

 

GDB + file test (program in the path)

 

GDB + attach 6678 (load a process PID)
B) run the program:
R (un) c) continue to run the program: C (ontinue) d) set the breakpoint:

• B 100 -- set a breakpoint in row 100 of the current file • B/mnt/HGFS/anycore/src/newcore/schedule/backupschedule/fileschedule/ncfilepushstreamevent. cpp: 104
-Set a breakpoint on the specified row of the specified file. e) cancel the breakpoint. D 1 -- Cancel the first breakpoint. d -- Cancel all breakpoints. f) display the current breakpoint information. • info breakg) display the code.
• L (IST) • List 10 h) one step
• Do not enter the function's internal step: n (EXT) -- do not enter the function's internal step (F10) • track the function's internal step: S (TEP) -- enter the function's internal step (F11) i) jump out of the current function
Fini (SH) J) display the variable value
• P a • P Str. c_str • P Vec. Size () k) Set the variable value

Set a = 10

M) Use the shell command • Shell PS-A • Shell pwd

CTRL + D Exit shell command

N) print stack information • Bt (backtrace) O) List threads • info threadsp) Jump to thread • thread n
Address: http://www.cnblogs.com/CodeSu/archive/2012/11/07/2758675.html

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.