Add conditionalized code to generate a trace file showing message
authorChris Hanson <org/chris-hanson/cph>
Thu, 3 Apr 1997 04:41:15 +0000 (04:41 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 3 Apr 1997 04:41:15 +0000 (04:41 +0000)
receipt, waiting, and event fetching.  This was used to track down a
busy-wait loop in Edwin.

v7/src/microcode/ntscreen.c
v7/src/microcode/ntscreen.h
v7/src/microcode/prntio.c

index f5bcc68b4bf1f50a61046587f16ed9014a9bf468..0e5a7ccfce94eb8e8fde137ad2fc3c09d21425f7 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: ntscreen.c,v 1.27 1996/11/18 21:12:50 cph Exp $
+$Id: ntscreen.c,v 1.28 1997/04/03 04:41:04 cph Exp $
 
-Copyright (c) 1993-96 Massachusetts Institute of Technology
+Copyright (c) 1993-97 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -202,6 +202,10 @@ extern LRESULT FAR CALLBACK ScreenWndProc (HWND, UINT, WPARAM, LPARAM);
 static VOID RegisterScreen (SCREEN);
 static VOID UnregisterScreen (SCREEN);
 
+#ifdef TRACE_SCREEN_MSGS
+static const char * translate_message_code (UINT);
+#endif
+
 //
 //  FILE GLOBAL VARIABLES
 //
@@ -210,6 +214,10 @@ static  HANDLE  ghInstance;
 static  HICON   ghDefaultIcon;
 
 static  LOGFONT lfDefaultLogFont;
+
+#ifdef TRACE_SCREEN_MSGS
+FILE * trace_file;
+#endif
 \f
 static long
 screen_x_extra (SCREEN screen)
@@ -363,6 +371,10 @@ Screen_InitApplication (HANDLE hInstance)
    if (font_name)
      ScreenSetDefaultFont (font_name);
 
+#ifdef TRACE_SCREEN_MSGS
+   trace_file = (fopen (TRACE_SCREEN_FILENAME, "w"));
+#endif
+
 #ifdef WINDOWSLOSES
    init_MIT_Keyboard ();
 #endif /* WINDOWSLOSES */
@@ -504,6 +516,19 @@ ScreenWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
    SCREEN  screen = GETSCREEN (hWnd);
 
+#ifdef TRACE_SCREEN_MSGS
+   if (trace_file)
+     {
+       const char * name = (translate_message_code (uMsg));
+       fprintf (trace_file, "hWnd=0x%x, ", hWnd);
+       if (name)
+        fprintf (trace_file, "uMsg=%s, ", name);
+       else
+        fprintf (trace_file, "uMsg=0x%x, ", uMsg);
+       fprintf (trace_file, "wParam=0x%x, lParam=0x%x\n", wParam, lParam);
+       fflush (trace_file);
+     }
+#endif
    switch (uMsg)
    {
       case WM_CREATE:
@@ -515,6 +540,9 @@ ScreenWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
         return  result;
       }
 
+      case WM_SCHEME_INTERRUPT:
+        return (0);
+
       case SCREEN_SETPOSITION:
         return  (LRESULT)Screen_SetPosition
                               (screen, HIWORD(lParam), LOWORD(lParam));
@@ -3200,8 +3228,18 @@ Screen_GetEvent (HANDLE hwnd, SCREEN_EVENT * event)
   SCREEN_EVENT_LINK * new_event;
   SCREEN screen = GETSCREEN (hwnd);
 
+#ifdef TRACE_SCREEN_MSGS
+  fprintf (trace_file, "Screen_GetEvent: hwnd=0x%x\n", hwnd);
+  fflush (trace_file);
+#endif
   if ((screen == ((SCREEN) NULL)) || (screen->n_events == 0))
-    return  FALSE;
+    {
+#ifdef TRACE_SCREEN_MSGS
+      fprintf (trace_file, "Screen_GetEvent: result=FALSE\n");
+      fflush (trace_file);
+#endif
+      return  FALSE;
+    }
   screen->n_events -= 1;
   new_event = screen->queue_head;
   *event = new_event->event;
@@ -3210,6 +3248,10 @@ Screen_GetEvent (HANDLE hwnd, SCREEN_EVENT * event)
     screen->queue_tail = ((SCREEN_EVENT_LINK *) NULL);
   new_event->next = screen->free_events;
   screen->free_events = new_event;
+#ifdef TRACE_SCREEN_MSGS
+  fprintf (trace_file, "Screen_GetEvent: result=TRUE\n");
+  fflush (trace_file);
+#endif
   return  TRUE;
 }
 
@@ -3556,3 +3598,220 @@ ScreenSetBackgroundColour (SCREEN screen, DWORD colour)
 {
   return  change_colour (screen, colour, &screen->rgbBGColour);
 }
+\f
+#ifdef TRACE_SCREEN_MSGS
+static const char *
+translate_message_code (UINT uMsg)
+{
+  switch (uMsg)
+    {
+    case WM_NULL: return ("WM_NULL");
+    case WM_CREATE: return ("WM_CREATE");
+    case WM_DESTROY: return ("WM_DESTROY");
+    case WM_MOVE: return ("WM_MOVE");
+    case WM_SIZE: return ("WM_SIZE");
+    case WM_ACTIVATE: return ("WM_ACTIVATE");
+    case WM_SETFOCUS: return ("WM_SETFOCUS");
+    case WM_KILLFOCUS: return ("WM_KILLFOCUS");
+    case WM_ENABLE: return ("WM_ENABLE");
+    case WM_SETREDRAW: return ("WM_SETREDRAW");
+    case WM_SETTEXT: return ("WM_SETTEXT");
+    case WM_GETTEXT: return ("WM_GETTEXT");
+    case WM_GETTEXTLENGTH: return ("WM_GETTEXTLENGTH");
+    case WM_PAINT: return ("WM_PAINT");
+    case WM_CLOSE: return ("WM_CLOSE");
+    case WM_QUERYENDSESSION: return ("WM_QUERYENDSESSION");
+    case WM_QUIT: return ("WM_QUIT");
+    case WM_QUERYOPEN: return ("WM_QUERYOPEN");
+    case WM_ERASEBKGND: return ("WM_ERASEBKGND");
+    case WM_SYSCOLORCHANGE: return ("WM_SYSCOLORCHANGE");
+    case WM_ENDSESSION: return ("WM_ENDSESSION");
+    case WM_SHOWWINDOW: return ("WM_SHOWWINDOW");
+    case WM_WININICHANGE: return ("WM_WININICHANGE");
+    case WM_DEVMODECHANGE: return ("WM_DEVMODECHANGE");
+    case WM_ACTIVATEAPP: return ("WM_ACTIVATEAPP");
+    case WM_FONTCHANGE: return ("WM_FONTCHANGE");
+    case WM_TIMECHANGE: return ("WM_TIMECHANGE");
+    case WM_CANCELMODE: return ("WM_CANCELMODE");
+    case WM_SETCURSOR: return ("WM_SETCURSOR");
+    case WM_MOUSEACTIVATE: return ("WM_MOUSEACTIVATE");
+    case WM_CHILDACTIVATE: return ("WM_CHILDACTIVATE");
+    case WM_QUEUESYNC: return ("WM_QUEUESYNC");
+    case WM_GETMINMAXINFO: return ("WM_GETMINMAXINFO");
+    case WM_PAINTICON: return ("WM_PAINTICON");
+    case WM_ICONERASEBKGND: return ("WM_ICONERASEBKGND");
+    case WM_NEXTDLGCTL: return ("WM_NEXTDLGCTL");
+    case WM_SPOOLERSTATUS: return ("WM_SPOOLERSTATUS");
+    case WM_DRAWITEM: return ("WM_DRAWITEM");
+    case WM_MEASUREITEM: return ("WM_MEASUREITEM");
+    case WM_DELETEITEM: return ("WM_DELETEITEM");
+    case WM_VKEYTOITEM: return ("WM_VKEYTOITEM");
+    case WM_CHARTOITEM: return ("WM_CHARTOITEM");
+    case WM_SETFONT: return ("WM_SETFONT");
+    case WM_GETFONT: return ("WM_GETFONT");
+    case WM_SETHOTKEY: return ("WM_SETHOTKEY");
+    case WM_GETHOTKEY: return ("WM_GETHOTKEY");
+    case WM_QUERYDRAGICON: return ("WM_QUERYDRAGICON");
+    case WM_COMPAREITEM: return ("WM_COMPAREITEM");
+    case WM_COMPACTING: return ("WM_COMPACTING");
+    case WM_COMMNOTIFY: return ("WM_COMMNOTIFY");
+    case WM_WINDOWPOSCHANGING: return ("WM_WINDOWPOSCHANGING");
+    case WM_WINDOWPOSCHANGED: return ("WM_WINDOWPOSCHANGED");
+    case WM_POWER: return ("WM_POWER");
+    case WM_COPYDATA: return ("WM_COPYDATA");
+    case WM_CANCELJOURNAL: return ("WM_CANCELJOURNAL");
+    case WM_NCCREATE: return ("WM_NCCREATE");
+    case WM_NCDESTROY: return ("WM_NCDESTROY");
+    case WM_NCCALCSIZE: return ("WM_NCCALCSIZE");
+    case WM_NCHITTEST: return ("WM_NCHITTEST");
+    case WM_NCPAINT: return ("WM_NCPAINT");
+    case WM_NCACTIVATE: return ("WM_NCACTIVATE");
+    case WM_GETDLGCODE: return ("WM_GETDLGCODE");
+    case WM_NCMOUSEMOVE: return ("WM_NCMOUSEMOVE");
+    case WM_NCLBUTTONDOWN: return ("WM_NCLBUTTONDOWN");
+    case WM_NCLBUTTONUP: return ("WM_NCLBUTTONUP");
+    case WM_NCLBUTTONDBLCLK: return ("WM_NCLBUTTONDBLCLK");
+    case WM_NCRBUTTONDOWN: return ("WM_NCRBUTTONDOWN");
+    case WM_NCRBUTTONUP: return ("WM_NCRBUTTONUP");
+    case WM_NCRBUTTONDBLCLK: return ("WM_NCRBUTTONDBLCLK");
+    case WM_NCMBUTTONDOWN: return ("WM_NCMBUTTONDOWN");
+    case WM_NCMBUTTONUP: return ("WM_NCMBUTTONUP");
+    case WM_NCMBUTTONDBLCLK: return ("WM_NCMBUTTONDBLCLK");
+    case WM_KEYDOWN: return ("WM_KEYDOWN");
+    case WM_KEYUP: return ("WM_KEYUP");
+    case WM_CHAR: return ("WM_CHAR");
+    case WM_DEADCHAR: return ("WM_DEADCHAR");
+    case WM_SYSKEYDOWN: return ("WM_SYSKEYDOWN");
+    case WM_SYSKEYUP: return ("WM_SYSKEYUP");
+    case WM_SYSCHAR: return ("WM_SYSCHAR");
+    case WM_SYSDEADCHAR: return ("WM_SYSDEADCHAR");
+    case WM_KEYLAST: return ("WM_KEYLAST");
+    case WM_INITDIALOG: return ("WM_INITDIALOG");
+    case WM_COMMAND: return ("WM_COMMAND");
+    case WM_SYSCOMMAND: return ("WM_SYSCOMMAND");
+    case WM_TIMER: return ("WM_TIMER");
+    case WM_HSCROLL: return ("WM_HSCROLL");
+    case WM_VSCROLL: return ("WM_VSCROLL");
+    case WM_INITMENU: return ("WM_INITMENU");
+    case WM_INITMENUPOPUP: return ("WM_INITMENUPOPUP");
+    case WM_MENUSELECT: return ("WM_MENUSELECT");
+    case WM_MENUCHAR: return ("WM_MENUCHAR");
+    case WM_ENTERIDLE: return ("WM_ENTERIDLE");
+    case WM_CTLCOLORMSGBOX: return ("WM_CTLCOLORMSGBOX");
+    case WM_CTLCOLOREDIT: return ("WM_CTLCOLOREDIT");
+    case WM_CTLCOLORLISTBOX: return ("WM_CTLCOLORLISTBOX");
+    case WM_CTLCOLORBTN: return ("WM_CTLCOLORBTN");
+    case WM_CTLCOLORDLG: return ("WM_CTLCOLORDLG");
+    case WM_CTLCOLORSCROLLBAR: return ("WM_CTLCOLORSCROLLBAR");
+    case WM_CTLCOLORSTATIC: return ("WM_CTLCOLORSTATIC");
+    case WM_MOUSEMOVE: return ("WM_MOUSEMOVE");
+    case WM_LBUTTONDOWN: return ("WM_LBUTTONDOWN");
+    case WM_LBUTTONUP: return ("WM_LBUTTONUP");
+    case WM_LBUTTONDBLCLK: return ("WM_LBUTTONDBLCLK");
+    case WM_RBUTTONDOWN: return ("WM_RBUTTONDOWN");
+    case WM_RBUTTONUP: return ("WM_RBUTTONUP");
+    case WM_RBUTTONDBLCLK: return ("WM_RBUTTONDBLCLK");
+    case WM_MBUTTONDOWN: return ("WM_MBUTTONDOWN");
+    case WM_MBUTTONUP: return ("WM_MBUTTONUP");
+    case WM_MBUTTONDBLCLK: return ("WM_MBUTTONDBLCLK");
+    case WM_PARENTNOTIFY: return ("WM_PARENTNOTIFY");
+    case WM_ENTERMENULOOP: return ("WM_ENTERMENULOOP");
+    case WM_EXITMENULOOP: return ("WM_EXITMENULOOP");
+    case WM_MDICREATE: return ("WM_MDICREATE");
+    case WM_MDIDESTROY: return ("WM_MDIDESTROY");
+    case WM_MDIACTIVATE: return ("WM_MDIACTIVATE");
+    case WM_MDIRESTORE: return ("WM_MDIRESTORE");
+    case WM_MDINEXT: return ("WM_MDINEXT");
+    case WM_MDIMAXIMIZE: return ("WM_MDIMAXIMIZE");
+    case WM_MDITILE: return ("WM_MDITILE");
+    case WM_MDICASCADE: return ("WM_MDICASCADE");
+    case WM_MDIICONARRANGE: return ("WM_MDIICONARRANGE");
+    case WM_MDIGETACTIVE: return ("WM_MDIGETACTIVE");
+    case WM_MDISETMENU: return ("WM_MDISETMENU");
+    case WM_ENTERSIZEMOVE: return ("WM_ENTERSIZEMOVE");
+    case WM_EXITSIZEMOVE: return ("WM_EXITSIZEMOVE");
+    case WM_DROPFILES: return ("WM_DROPFILES");
+    case WM_MDIREFRESHMENU: return ("WM_MDIREFRESHMENU");
+    case WM_CUT: return ("WM_CUT");
+    case WM_COPY: return ("WM_COPY");
+    case WM_PASTE: return ("WM_PASTE");
+    case WM_CLEAR: return ("WM_CLEAR");
+    case WM_UNDO: return ("WM_UNDO");
+    case WM_RENDERFORMAT: return ("WM_RENDERFORMAT");
+    case WM_RENDERALLFORMATS: return ("WM_RENDERALLFORMATS");
+    case WM_DESTROYCLIPBOARD: return ("WM_DESTROYCLIPBOARD");
+    case WM_DRAWCLIPBOARD: return ("WM_DRAWCLIPBOARD");
+    case WM_PAINTCLIPBOARD: return ("WM_PAINTCLIPBOARD");
+    case WM_VSCROLLCLIPBOARD: return ("WM_VSCROLLCLIPBOARD");
+    case WM_SIZECLIPBOARD: return ("WM_SIZECLIPBOARD");
+    case WM_ASKCBFORMATNAME: return ("WM_ASKCBFORMATNAME");
+    case WM_CHANGECBCHAIN: return ("WM_CHANGECBCHAIN");
+    case WM_HSCROLLCLIPBOARD: return ("WM_HSCROLLCLIPBOARD");
+    case WM_QUERYNEWPALETTE: return ("WM_QUERYNEWPALETTE");
+    case WM_PALETTEISCHANGING: return ("WM_PALETTEISCHANGING");
+    case WM_PALETTECHANGED: return ("WM_PALETTECHANGED");
+    case WM_HOTKEY: return ("WM_HOTKEY");
+    case WM_PENWINFIRST: return ("WM_PENWINFIRST");
+    case WM_PENWINLAST: return ("WM_PENWINLAST");
+
+#if(WINVER >= 0x0400)
+    case WM_NOTIFY: return ("WM_NOTIFY");
+    case WM_INPUTLANGCHANGEREQUEST: return ("WM_INPUTLANGCHANGEREQUEST");
+    case WM_INPUTLANGCHANGE: return ("WM_INPUTLANGCHANGE");
+    case WM_TCARD: return ("WM_TCARD");
+    case WM_HELP: return ("WM_HELP");
+    case WM_USERCHANGED: return ("WM_USERCHANGED");
+    case WM_NOTIFYFORMAT: return ("WM_NOTIFYFORMAT");
+    case WM_CONTEXTMENU: return ("WM_CONTEXTMENU");
+    case WM_STYLECHANGING: return ("WM_STYLECHANGING");
+    case WM_STYLECHANGED: return ("WM_STYLECHANGED");
+    case WM_DISPLAYCHANGE: return ("WM_DISPLAYCHANGE");
+    case WM_GETICON: return ("WM_GETICON");
+    case WM_SETICON: return ("WM_SETICON");
+    case WM_IME_STARTCOMPOSITION: return ("WM_IME_STARTCOMPOSITION");
+    case WM_IME_ENDCOMPOSITION: return ("WM_IME_ENDCOMPOSITION");
+    case WM_IME_COMPOSITION: return ("WM_IME_COMPOSITION");
+    case WM_NEXTMENU: return ("WM_NEXTMENU");
+    case WM_SIZING: return ("WM_SIZING");
+    case WM_CAPTURECHANGED: return ("WM_CAPTURECHANGED");
+    case WM_MOVING: return ("WM_MOVING");
+    case WM_POWERBROADCAST: return ("WM_POWERBROADCAST");
+    case WM_DEVICECHANGE: return ("WM_DEVICECHANGE");
+    case WM_IME_SETCONTEXT: return ("WM_IME_SETCONTEXT");
+    case WM_IME_NOTIFY: return ("WM_IME_NOTIFY");
+    case WM_IME_CONTROL: return ("WM_IME_CONTROL");
+    case WM_IME_COMPOSITIONFULL: return ("WM_IME_COMPOSITIONFULL");
+    case WM_IME_SELECT: return ("WM_IME_SELECT");
+    case WM_IME_CHAR: return ("WM_IME_CHAR");
+    case WM_IME_KEYDOWN: return ("WM_IME_KEYDOWN");
+    case WM_IME_KEYUP: return ("WM_IME_KEYUP");
+    case WM_PRINT: return ("WM_PRINT");
+    case WM_PRINTCLIENT: return ("WM_PRINTCLIENT");
+    case WM_HANDHELDFIRST: return ("WM_HANDHELDFIRST");
+    case WM_HANDHELDLAST: return ("WM_HANDHELDLAST");
+    case WM_AFXFIRST: return ("WM_AFXFIRST");
+    case WM_AFXLAST: return ("WM_AFXLAST");
+    case WM_APP: return ("WM_APP");
+#endif /* WINVER >= 0x0400 */
+    case SCREEN_WRITE: return ("SCREEN_WRITE");
+    case SCREEN_SETPOSITION: return ("SCREEN_SETPOSITION");
+    case SCREEN_GETPOSITION: return ("SCREEN_GETPOSITION");
+    case SCREEN_SETATTRIBUTE: return ("SCREEN_SETATTRIBUTE");
+    case SCREEN_GETATTRIBUTE: return ("SCREEN_GETATTRIBUTE");
+    case SCREEN_PEEKEVENT: return ("SCREEN_PEEKEVENT");
+    case SCREEN_READEVENT: return ("SCREEN_READEVENT");
+    case SCREEN_SETMODES: return ("SCREEN_SETMODES");
+    case SCREEN_GETMODES: return ("SCREEN_GETMODES");
+    case SCREEN_SETCOMMAND: return ("SCREEN_SETCOMMAND");
+    case SCREEN_GETCOMMAND: return ("SCREEN_GETCOMMAND");
+    case SCREEN_SETBINDING: return ("SCREEN_SETBINDING");
+    case SCREEN_GETBINDING: return ("SCREEN_GETBINDING");
+    case SCREEN_SETMENU: return ("SCREEN_SETMENU");
+    case SCREEN_READ: return ("SCREEN_READ");
+    case SCREEN_CLEAR: return ("SCREEN_CLEAR");
+    case WM_CATATONIC: return ("WM_CATATONIC");
+    case WM_SCHEME_INTERRUPT: return ("WM_SCHEME_INTERRUPT");
+    default: return (0);
+    }
+}
+#endif
index 55e2a9203f4b916c0e3e4a44a769555b19e86147..7f6759895bce49e1b076c6daa0354e75a033ca38 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: ntscreen.h,v 1.13 1996/10/07 17:51:47 cph Exp $
+$Id: ntscreen.h,v 1.14 1997/04/03 04:40:53 cph Exp $
 
-Copyright (c) 1993-96 Massachusetts Institute of Technology
+Copyright (c) 1993-97 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -288,6 +288,13 @@ typedef LRESULT (*COMMAND_HANDLER)(HWND,WORD command);
 
 #define USE_WM_TIMER
 
+#ifdef TRACE_SCREEN_MSGS
+extern FILE * trace_file;
+#ifndef TRACE_SCREEN_FILENAME
+#define TRACE_SCREEN_FILENAME "nttrace.out"
+#endif
+#endif
+
 //---------------------------------------------------------------------------
 //  End of File: screen.h
 //---------------------------------------------------------------------------
index 357bb51a8db1c7dec66b05a06ad9a43c4385360c..3bdfa772d0d7a39255e98a68e42c6c44737b862d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: prntio.c,v 1.4 1997/01/01 22:57:38 cph Exp $
+$Id: prntio.c,v 1.5 1997/04/03 04:41:15 cph Exp $
 
 Copyright (c) 1993-97 Massachusetts Institute of Technology
 
@@ -130,10 +130,18 @@ wait_for_multiple_objects (DWORD nhand, HANDLE * handles, DWORD timeout,
      check the queue as late as possible before the call, in order
      to minimize the window in which we can get stuck waiting for
      a message that has already arrived.  */
+#ifdef TRACE_SCREEN_MSGS
+  fprintf (trace_file, "MsgWaitForMultipleObjects: timeout=0x%x\n", timeout);
+  fflush (trace_file);
+#endif
   if (msgp && (PeekMessage ((&m), 0, 0, 0, PM_NOREMOVE)))
     return (((m.message) == WM_SCHEME_INTERRUPT) ? (nhand + 2) : (nhand + 1));
   result =
     (MsgWaitForMultipleObjects (nhand, handles, FALSE, timeout, QS_ALLINPUT));
+#ifdef TRACE_SCREEN_MSGS
+  fprintf (trace_file, "MsgWaitForMultipleObjects: result=0x%x\n", result);
+  fflush (trace_file);
+#endif
   return
     ((result == WAIT_TIMEOUT)
      ? 0