Changeset 12768


Ignore:
Timestamp:
Sep 6, 2009, 5:43:06 PM (10 years ago)
Author:
palter
Message:

Flush buffers before asking for input in kernel debugger to keep Windows happy.
Also, make sure streams are setup before trying to display register contents
when called from an exception on the foreign stack.

File:
1 edited

Legend:

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

    r12713 r12768  
    111111  stdIn = GetStdHandle(STD_INPUT_HANDLE);
    112112  return (stdIn == NULL);
     113}
     114#endif
     115
     116
     117#ifdef WINDOWS
     118Boolean first_debugger_call = TRUE;
     119
     120void
     121setup_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;
    113155}
    114156#endif
     
    708750{
    709751
     752#ifdef WINDOWS
     753  setup_debugger_streams();
     754#endif
     755
    710756#ifdef PPC
    711757#ifdef PPC64
     
    11221168#endif
    11231169
    1124 #ifdef WINDOWS
    1125 Boolean first_debugger_call = TRUE;
    1126 #endif
    1127 
    11281170
    11291171OSStatus
     
    11391181
    11401182#ifdef WINDOWS
    1141   HANDLE h;
    1142   int fd;
    1143   FILE *f;
    1144 
    1145   if (first_debugger_call) {
    1146     first_debugger_call = FALSE;
    1147     if (stdin_is_dev_null())
    1148       AllocConsole();
    1149     // Reassociate C's stdin with Windows' stdin
    1150     h = GetStdHandle(STD_INPUT_HANDLE);
    1151     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    1152     if (fd >= 0) {
    1153       f = _fdopen(fd, "r");
    1154       *stdin = *f;
    1155     }
    1156     // Reassociate C's stdout with Windows' stdout
    1157     h = GetStdHandle(STD_OUTPUT_HANDLE);
    1158     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    1159     if (fd >= 0) {
    1160       f = _fdopen(fd, "w");
    1161       *stdout = *f;
    1162     }
    1163     // Reassociate C's stderr with Windows' stderr
    1164     h = GetStdHandle(STD_ERROR_HANDLE);
    1165     fd = _open_osfhandle((intptr_t)h, _O_TEXT);
    1166     if (fd >= 0) {
    1167       f = _fdopen(fd, "w");
    1168       *stderr = *f;
    1169     }
    1170     dbgout = stderr;
    1171   }
     1183  setup_debugger_streams();
    11721184#endif
    11731185
     
    12251237    fprintf(dbgout, "[%d] Clozure CL kernel debugger: ", main_thread_pid);
    12261238#endif
     1239    fflush(dbgout);
    12271240    state = apply_debug_command(xp, readc(), info, why);
    12281241  }
Note: See TracChangeset for help on using the changeset viewer.