From: Manu <ma...@wa...> - 2003-12-25 01:54:28
|
I've noticed a different behavior between MinGW's GDB 5.2.1 and GDB 6.0 when running a console program. The 5.2.1 creates a console window, the program's output goes to that console, which seems correct. The 6.0 doesn't show a console, worse, the program's output doesn't show up at the right time, but just before the program exits. 0/ Sample program: -------------------- /******************************************************** * A simple Hello World. * * The stdio header declares standard input/output routines like printf. * The main() procedure is the program entry point. * ********************************************************/ #include <stdio.h> int main(){ /* Writes a string in the DOS box. */ printf("Hello world !"); return 0; /* Program termination. */ } 1/ Sample session with gdb 5.2.1: ---------------------------------- Manu@TBIRD1000 /c/Dev/Visual-MinGW/Projects/Samples/Console/Hello $ gdb50201 -nw -q -f "C:\Dev\Visual-MinGW\Projects\Samples\Console\Hello\hello. exe" (gdb) b main.c:11 Breakpoint 1 at 0x4012fc: file main.c, line 11. (gdb) run Starting program: C:\Dev\Visual-MinGW\Projects\Samples\Console\Hello\hello.exe Breakpoint 1, main () at main.c:12 C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:12:349:beg:0x4012fc (gdb) info terminal Inferior's terminal status (currently saved by GDB): File descriptor flags = O_RDONLY ^^^^^^ GDB has saved a terminal info. (gdb) s ^^^^^^ The "Hello world!" outputs in the console window, which is correct. C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:13:376:beg:0x40130c (gdb) s C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:14:415:beg:0x401311 (gdb) s 0x0040122d in __mingw_CRTStartup () (gdb) s Single stepping until exit from function __mingw_CRTStartup, which has no line number information. Program exited normally. (gdb) q 2/ Sample session with gdb 6.0: ---------------------------------- Manu@TBIRD1000 /c/Dev/Visual-MinGW/Projects/Samples/Console/Hello $ gdb -nw -q -f "C:\Dev\Visual-MinGW\Projects\Samples\Console\Hello\hello.exe" (gdb) b main.c:11 Breakpoint 1 at 0x4012fc: file main.c, line 11. (gdb) run Starting program: C:\Dev\Visual-MinGW\Projects\Samples\Console\Hello\hello.exe Breakpoint 1, main () at main.c:12 C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:12:349:beg:0x4012fc (gdb) info terminal This GDB does not control a terminal. ^^^^^^ well, well well. (gdb) s ^^^^^^ nothing outputs after the printf() at line 12. C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:13:376:beg:0x40130c (gdb) s C:/Dev/Visual-MinGW/Projects/Samples/Console/Hello/main.c:14:415:beg:0x401311 (gdb) s 0x0040122d in __mingw_CRTStartup () (gdb) s Single stepping until exit from function __mingw_CRTStartup, which has no line number information. Hello world ! ^^^^^^ Thanks, but a bit too late!!! Program exited normally. (gdb) q The same behavior is observed within MSYS and Visual-MinGW. (redirected GDB I/O) Any information about the way GDB is supposed to process programs' I/O is greatly welcome. Thanks. Manu. |