Changeset 12828


Ignore:
Timestamp:
Sep 12, 2009, 7:35:33 PM (10 years ago)
Author:
gb
Message:

Any I/O redirection that needs to be done to enable debugging in a GUI
application should be done (mostly) on the lisp side (among other things,
this allows the lisp to choose how to do it) and by having lisp code call
open_debug_output().

On Windows, open_debug_output() tries to ensure that stdin has a valid
fd (0); it may not in a GUI application.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/lisp-debug.c

    r12768 r12828  
    5353  if (f) {
    5454    if (setvbuf(f, NULL, _IONBF, 0) == 0) {
     55#ifdef WINDOWS
     56      if (fileno(stdin) < 0) {
     57        fileno(stdin) = 0;
     58      }
     59#endif
    5560      dbgout = f;
    5661      return true;
     
    115120
    116121
    117 #ifdef WINDOWS
    118 Boolean first_debugger_call = TRUE;
    119 
    120 void
    121 setup_debugger_streams()
    122 {
    123   HANDLE h;
    124   int fd;
    125   FILE *f;
    126 
    127   if (first_debugger_call) {
    128     first_debugger_call = FALSE;
    129     if (stdin_is_dev_null())
    130       AllocConsole();
    131     // Reassociate C's stdin with Windows' stdin
    132     h = GetStdHandle(STD_INPUT_HANDLE);
    133     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    134     if (fd >= 0) {
    135       f = _fdopen(fd, "r");
    136       *stdin = *f;
    137     }
    138     // Reassociate C's stdout with Windows' stdout
    139     h = GetStdHandle(STD_OUTPUT_HANDLE);
    140     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    141     if (fd >= 0) {
    142       f = _fdopen(fd, "w");
    143       *stdout = *f;
    144     }
    145     // Reassociate C's stderr with Windows' stderr
    146     h = GetStdHandle(STD_ERROR_HANDLE);
    147     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    148     if (fd >= 0) {
    149       f = _fdopen(fd, "w");
    150       *stderr = *f;
    151     }
    152     dbgout = stderr;
    153   }
    154   return;
    155 }
    156 #endif
    157122
    158123
     
    750715{
    751716
    752 #ifdef WINDOWS
    753   setup_debugger_streams();
    754 #endif
    755717
    756718#ifdef PPC
     
    11801142  debug_command_return state = debug_continue;
    11811143
    1182 #ifdef WINDOWS
    1183   setup_debugger_streams();
    1184 #endif
    11851144
    11861145  if (stdin_is_dev_null()) {
     
    12371196    fprintf(dbgout, "[%d] Clozure CL kernel debugger: ", main_thread_pid);
    12381197#endif
    1239     fflush(dbgout);
     1198    fflush(dbgout);             /* dbgout should be unbuffered, so this shouldn't be necessary.  But it can't hurt ... */
    12401199    state = apply_debug_command(xp, readc(), info, why);
    12411200  }
Note: See TracChangeset for help on using the changeset viewer.