Platform migration-5 (Introduction to GDB)

Source: Internet
Author: User

Preface:

I used to use the convenient ide debugging function in windows. It was quite inconvenient to use in the early stage. Here is a small record for getting started.

 

GDB can be regarded as a debug tool attached to the Linux-GCC compiler.

To debug a program using GDB, you only need to input a program similar to GDB xxx.exe under shell-command.

(Here, we emphasize that the-G parameter must be added during compilation to support debugging, for example, GCC-g xxx. C-o xxx.exe)

 

After the gdb prompt appears, you can first use "L" (list) to view SRC, and then add the breakpoint "B 21" (break at line 21) to a line)

Next, run the program "R" (run), then the program will automatically stay at the breakpoint,

If you want to continue running, type "C" (continue)

Use P (P var1) to view the variable)

Set the variable with set (set var1 = "ABC ")

Jump to a row and use Jump (jump 21)

Enter a function and use S (step)

For step-by-step operation, n (next) is used)

 

For more details about GDB command, refer to Google. Here is a brief introduction :)~

 

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.