We also talk about online development of windows and Linux.

Source: Internet
Author: User
We also talk about the online development of windows and Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. During program debugging these two days, I encountered a series of very strange problems and shared them with you.

1. Lost in hell

The cause is that after I use gdb to debug a breakpoint, the program does not stop at the breakpoint, but stops at other places, such: I made a breakpoint on the 1000 line of a file, but the program stops at the 1050 line. According to previous experience, there are two reasons for this problem: first, the source file of the debugging machine is not updated, or the system date of the debugging machine is inconsistent with that of the Development Editor. That is, the latter is earlier than the former, but even so, if the make clear command is executed, no problem is required. Second, the-O optimization option is added during debugging, which may cause inconsistency between the code displayed during debugging and the actual source code, I wanted to smile and try it out. I don't want to use either of these methods.

Next, a series of strange things happened. First, the number of lines displayed by gdb does not match the number of lines actually executed by the program. (This experiment proves that: if a variable is assigned a value in row 1200, but gdb shows a garbled code when it is displayed), the code displayed by gdb becomes more and more outrageous, for example: it shows return false, but the program is still executed in sequence ......

2. Struggling in purgatory

At this moment, I found that it was indeed a bit dizzy. In order to catch up with the progress and don't want to stay in the same place, so I quickly went to the BBS, where the heroes gathered, hoping to quickly meet the experts for advice, however, most of the answers I received after posting are the same as the two methods I mentioned above. It seems that I am not as lucky as others. I can only use the above two tricks to Win KO, continue to view DEBUG information, and continue to be depressed ......

In desperation, do you think that there are not many experts in the sibling departments hanging online on RTX? As a result, I quickly found the main program of QQGame and QQPet and several brothers of the platform R & D department to discuss them together. Enthusiastic brothers are always more than cool-packed brothers, however, the study has not been discussed for a long time ......

Time is not waiting for people. I simply do not need to debug it in one step. I should try to carefully use the source code to ensure the correctness of the program logic. As long as the compilation is OK, the statistical running results will be correct. Interestingly, when I run the program directly, the program can get the correct results according to the correct logic, which makes me a little stunned ......

3. reborn in heaven

Although the progress has caught up, this problem is like a thorn stuck in the throat! At this moment, I was surprised to find out the crux of the problem. When I compile a file, I find that the number of lines in the compilation error is inconsistent with the number of lines in the source file, which forces me to carefully view the source file again, I did not find any exception after reading it several times. Just as I fell into full trouble again, a picture came into my eyes.

You can see a clear ^ M symbol. In fact, this ^ M symbol is not a new friend, because I have encountered it before, in windows, I used Source Insight for editing and then used the rz command to upload it to the development machine for compilation and debugging. In this process, some symbols in windows are disordered during conversion in linux. In view of this, I pay special attention to the use of some symbols during compilation in windows. What I did not think of was, it appears in the comment.

Alas, after a long sigh, we must replace all of them. After division of the three, two, and two, the problem finally Kill!

At this point, the problem that has been depressed for a long time has finally come to an end. ^ M, a familiar stranger, has made me suffer a dumb loss again, why didn't I check the source code?

Oh, it's just that the sleepy mood is finally stretched out, just like being in heaven!
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.