home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / SRC / KTRACE.MOD < prev    next >
Text File  |  1996-07-22  |  4KB  |  116 lines

  1. IMPLEMENTATION MODULE KTrace;
  2.  
  3.         (****************************************************************)
  4.         (*                                                              *)
  5.         (*      Trace routines for Modula 2 program development.        *)
  6.         (*                                                              *)
  7.         (*  This is the version which does NOT use windows.  It is      *)
  8.         (*  intended for low-level tracing of the kernel, where a       *)
  9.         (*  window-based tracing facility would be unsuitable because   *)
  10.         (*  of critical section problems.  However, it is quite         *)
  11.         (*  adequate for any application where we don't care too much   *)
  12.         (*  about a pretty screen layout.                               *)
  13.         (*                                                              *)
  14.         (*  Note, however, that this module is missing the "Press any   *)
  15.         (*  key to continue" option which my other trace modules have.  *)
  16.         (*                                                              *)
  17.         (*  Programmer:         P. Moylan                               *)
  18.         (*  Last edited:        22 July 1996                            *)
  19.         (*  Status:             Just started OS/2 port                  *)
  20.         (*                                                              *)
  21.         (****************************************************************)
  22.  
  23. FROM GlassTTY IMPORT
  24.     (* proc *)  WriteString, WriteLn, WriteHexWord;
  25.  
  26. VAR TraceEnabled: BOOLEAN;
  27.     nesting: CARDINAL;
  28.  
  29. (************************************************************************)
  30.  
  31. PROCEDURE NYI (name: ARRAY OF CHAR);
  32.  
  33.     (* Types a "not yet implemented" message.   *)
  34.  
  35.     BEGIN
  36.         WriteString (name);  WriteString (" is not yet implemented.");
  37.         WriteLn;
  38.     END NYI;
  39.  
  40. (************************************************************************)
  41.  
  42. PROCEDURE InTrace (name: ARRAY OF CHAR);
  43.  
  44.     (* To be called when entering a procedure.  *)
  45.  
  46.     VAR j: CARDINAL;
  47.  
  48.     BEGIN
  49.         IF TraceEnabled THEN
  50.             FOR j := 1 TO nesting DO
  51.                 WriteString ("   ");
  52.             END (*FOR*);
  53.             WriteString ("Entering ");  WriteString (name);
  54.             WriteLn;
  55.         END (*IF*);
  56.         INC (nesting);
  57.     END InTrace;
  58.  
  59. (************************************************************************)
  60.  
  61. PROCEDURE OutTrace (name: ARRAY OF CHAR);
  62.  
  63.     (* To be called when leaving a procedure.   *)
  64.  
  65.     VAR j: CARDINAL;
  66.  
  67.     BEGIN
  68.         DEC (nesting);
  69.         IF TraceEnabled THEN
  70.             FOR j := 1 TO nesting DO
  71.                 WriteString ("   ");
  72.             END (*FOR*);
  73.             WriteString ("Leaving ");  WriteString (name);
  74.             WriteLn;
  75.         END (*IF*);
  76.     END OutTrace;
  77.  
  78. (************************************************************************)
  79.  
  80. PROCEDURE TraceOn;
  81.  
  82.     (* Turns tracing on.                *)
  83.  
  84.     BEGIN
  85.         TraceEnabled := TRUE;
  86.     END TraceOn;
  87.  
  88. (************************************************************************)
  89.  
  90. PROCEDURE TraceOff;
  91.  
  92.     (* Turns tracing off.               *)
  93.  
  94.     BEGIN
  95.         TraceEnabled := FALSE;
  96.     END TraceOff;
  97.  
  98. (************************************************************************)
  99.  
  100. PROCEDURE TraceStatus (): BOOLEAN;
  101.  
  102.     (* Says whether tracing is currently on.            *)
  103.  
  104.     BEGIN
  105.         RETURN TraceEnabled;
  106.     END TraceStatus;
  107.  
  108. (************************************************************************)
  109. (*                              INITIALISATION                          *)
  110. (************************************************************************)
  111.  
  112. BEGIN
  113.     TraceEnabled := FALSE;  nesting := 0;
  114. END KTrace.
  115. 
  116.