Android system development (2) -- GDB debugging tool, androidgdb

Source: Internet
Author: User

Android system development (2) -- GDB debugging tool, androidgdb
Debugging process

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

1. debug mode Compilation


2. Hitting a breakpoint


3. Run debugging


4. Single-step debugging

Step into: Jump to the function body

Step over: Do not jump to the function body

Step return: run the current function

5. Continue running

Continue

6. Print and monitor values

GDB debugging

First, write a piece of C ++ Code. The Code content is as follows:

Compile in debug mode:

Enter the Debug debugging mode:

1. The method for hitting a breakpoint is as follows (commands in gdb can be replaced by the first letter, for example, break and B play the same role)

Break function name

Break row number

Break file name: row number

Break row number if condition

You can use info break to view breakpoints and delete to delete breakpoints. Next we use the list command to view the source files and then click breakpoint.

View breakpoints

We can see that there is currently a breakpoint with the ID 1 and in the fourth line. Use the method name below to open a breakpoint.

2. run. You can use continue to continue running and quit running with quit.

We can see that it stops at the breakpoint during running.

3. One-Step debugging, but the subsequent debugging corresponds to the following three commands:

Next ------ step over

Step ----- step

Finish ----- step return

Next we will debug a piece of Program Code. The Code content and output results are as follows:

Output result:

Before this code is output, some friends may think that the correct result should be 50.5. Next, let's look at the problem through debugging.

We can see that we have made a breakpoint on the fifth line. When the execution reaches the fifth line, the row is not actually executed, so the I value is invalid at this time.

We used watch above to observe variable I. When I changes, it will display the value after I changes. We can see that the value of variable I changes to 0.01 after next, next we use the conditional breakpoint for debugging.

We can see that the actual value from I loop to 98 times is not 0.98, but greater than 0.98. We can see from next to 100th cycles

At this time, the condition does not meet I = 1, so only 99 cycles can be executed, and the result is 49.5 instead of 50.5.

Input wi for debugging




In linux, how does one install the gdb debugging tool?

How can I use sudo apt-get install gdb to view my:




Without gdb, how can I implement one-step debugging of C/C ++ code in JNI of android in eclipse ??

ADT (Android Development Template)
Is the development plug-in of Eclipse and supports single-step debugging.
 

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.