CodeView May Appear to Hang on gets() If Screen Swap Is Off

ID Number: Q62663

3.00 3.10 3.11 3.14 | 3.00 3.10 3.11 3.12 3.50

MS-DOS | OS/2

Summary:

The Microsoft CodeView Debugger will appear to hang when you step or

execute past a call to the gets() run-time routine if the Screen Swap

option is turned off.

The apparent lock-up results because the gets() call causes focus to

shift to the debuggee's screen and there is no way for CodeView to get

to that screen with Screen Swap off. To get past this deadlock with

CVP under OS/2, manually switch screen groups to the one labeled "CVP

app appname.EXE". Once there, you can provide a response to the

waiting gets() call. After entering a string, you can switch back to

the screen group running CVP and continue debugging. Under DOS, you

must break execution with CTRL+C so that you may turn swapping back

on.

The sample code below illustrates this situation. Compile the code as

indicated and bring up the .EXE in CodeView. Select the Option menu

and turn off Screen Swap if it is on. Next, step past the gets() call.

Under DOS, you will need to press CTRL+C to regain control. Under

OS/2, you will need to switch screen groups to provide the necessary

input to the program.

Sample Code

-----------

/* Compile options needed: /Zi /Od

*/

#include <stdio.h>

char string[256];

void main (void)

{

printf ( "Enter a string: ") ;

gets ( string ) ;

printf ( "Echoing : %s\n", string) ;

}

Additional reference words: 3.00 3.10 3.50