Errors of using GDB to debug the ncurses Program

Source: Internet
Author: User

Because the curses program usually occupies a shell for output, it cannot be debugged using the previous GDB method.

One solution on the Internet is to redirect the program debugged by GDB to another tty for output. The procedure is as follows:

Method 1: First open two tty, GDB filename in tty1, and then tty tty2. At this time, GDB directs the output of the debugging program to tty2, and tty1 is only used to write gdb commands.

However, in actual operation, there is getch () in the program. I always need to enter two characters, and the second character will be returned by getch.

I have not studied the causes of the above exceptions in depth, but the following methods won't cause this problem. The method is as follows:

Method 2: Enable two tty machines, one running the program under test and the other PS-Aux using GDB and attach PID.

However, the limitation of this method is that the Code executed before the program is blocked cannot be tested in a single step. However, the first method can be fully tested.

Therefore, the code before the test program is blocked is summarized as follows. The first method is used, and the second method is used after the test program is blocked.

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.