Android system Development (2)--GDB Debugging Tools

Source: Internet
Author: User

The process of debugging

Let's take a look at the general debugging process in eclipse:

1. Debug Mode Compilation


2, hit the breakpoint


3. Running and commissioning


4. Single Step debugging

Step into: Jumps inside the function body

Step over: Do not jump into the function body

Step return: Run out of current function

5. Continue running

Continue

6. Printing and Monitoring values

GDB debugging

Write a C + + code First, the following code:

Compile using debug mode:

Enter Debug Debug mode:

1, break point, the way to break the point is as follows (GDB commands can be replaced with the first letter, such as the effect of the same as the "B")

Break function Number Name

Break line number

Break file name: line number

Break line number if condition

With info break You can view breakpoints, delete to remove breakpoints, we use the List command to view the source file, and then break the point

viewing breakpoints

You can see that there is currently a breakpoint, his number is 1, in line fourth; Use the method name to hit a breakpoint

2. Start running (run), you can use continue to continue running down, use quit to exit the running state

You can see that you stopped at the breakpoint at run time.

3, single-step debugging, but step debugging corresponding to the following three commands

Next------Step Over

Step-----Step Into

Finish-----Step return

Here we will debug a program code, the code content and output results are as follows:

The output is:

This code before the output results some friends may think the correct result should be 50.5, the following we will debug to see where the problem

We can see that we hit a breakpoint on line fifth, and when we execute to line fifth, the line is not executed, so the value of I is an invalid value at this point.

In the above we use watch to observe the variable i when I change will show I change the value, you can see our next after the value of the variable I to 0.01, below we use conditional breakpoints to debug

It can be seen that the actual value is not 0.98 but larger than 0.98 when I loop to 98 times, we can see next to the 100th cycle

At this point the condition does not satisfy the i==1, so only 99 cycles can be executed, the result is 49.5 instead of 50.5

Input WI can be convenient for us to debug



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.