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.