Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
3.4 KiB

  1. ; declare a simple interface to control debugging messages
  2. BegData macro
  3. _DATA SEGMENT PARA PUBLIC 'DATA'
  4. endm
  5. EndData macro
  6. _DATA ENDS
  7. endm
  8. DEB_ERROR = 1
  9. DEB_WARN = 2
  10. DEB_TRACE = 4
  11. DEB_FERROR = 8 ;; fatal error - terminate app
  12. DEB_IERROR = 10h
  13. DEB_IWARN = 20h
  14. DEB_ITRACE = 40h
  15. DEB_IFERROR = 80h ;; fatal error - terminate app
  16. DEB_FERRORS = DEB_FERROR or DEB_IFERROR
  17. DEB_ERRORS = DEB_ERROR OR DEB_IERROR OR DEB_FERRORS
  18. DEB_WARNS = DEB_WARN OR DEB_IWARN
  19. DEB_TRACES = DEB_TRACE OR DEB_ITRACE
  20. DEB_NOCRLF = 8000h ;; No CR/LF in string
  21. DEB_BREAKLEVEL = DEB_ERRORS or 0ff00h
  22. DEB_INFOLEVEL = DEB_BREAKLEVEL or DEB_WARNS
  23. DECLARE_DEBUG macro comp
  24. ifdef Win3DebData
  25. else
  26. extrn _Win3InfoLevel:word, _Win3BreakLevel:word
  27. ; BegData
  28. extrn _&comp&InfoLevel:word, _&comp&BreakLevel:word
  29. ; EndData
  30. endif
  31. ifdef Win3Deb
  32. else
  33. extrn _&comp&DebugTest:far
  34. endif
  35. &comp&DebugOut macro flag, string, vals
  36. local sloc, cnt
  37. BegData
  38. sloc label byte
  39. db string
  40. ife (flag) and DEB_NOCRLF
  41. db 13, 10
  42. endif
  43. db 0
  44. EndData
  45. cnt = 0
  46. irp foo, <vals>
  47. push foo
  48. cnt = cnt + 1
  49. endm
  50. push offset sloc
  51. push flag AND NOT DEB_NOCRLF
  52. call _&comp&DebugTest
  53. add sp, 4+(2*cnt)
  54. endm
  55. endm
  56. declare_areas macro name, comp, list
  57. deb_loc = 100h
  58. deb_areas equ <list>
  59. irp val, <list>
  60. DEB_&comp&&val = deb_loc
  61. deb_loc = deb_loc + deb_loc
  62. ifdef Win3Deb
  63. BegData
  64. STR_&comp&&val label byte
  65. db "&name &val: ", 0
  66. EndData
  67. endif
  68. endm
  69. ifdef Win3Deb
  70. BegData
  71. STR_&comp&Trace db "Trace: ", 0
  72. STR_&comp&Warn db "Warning: ", 0
  73. STR_&comp&Error db "Error: ", 0
  74. STR_&comp db "&name: ", 0
  75. STR_&comp&table dw dataoffset STR_&comp
  76. irp val, <list>
  77. dw dataoffset STR_&comp&&val
  78. endm
  79. EndData
  80. endif
  81. endm
  82. declare_infolevel macro comp
  83. local skip
  84. BegData
  85. ; public _&comp&InfoLevel, _&comp&BreakLevel
  86. ; _&comp&InfoLevel dw DEB_INFOLEVEL ;; component can override
  87. ; _&comp&BreakLevel dw DEB_BREAKLEVEL
  88. EndData
  89. _&comp&DebugTest proc far ;; Per-component - check right flags
  90. public _&comp&DebugTest
  91. push bp
  92. mov bp, sp
  93. push ds
  94. push ax
  95. mov ax, _DATA
  96. cmp ax, 1000h ;; DATA should be selector, not addr
  97. jnc skip
  98. mov ds, ax
  99. assume ds:_DATA
  100. mov ax, [bp+6] ;; See if component enabled
  101. and ax, [_&comp&InfoLevel]
  102. cmp ax, [bp+6]
  103. jnz skip
  104. push es ;; See if system enabled
  105. push seg _Win3InfoLevel
  106. pop es
  107. and al, byte ptr es:[_Win3InfoLevel] ;; test low 8 bits for system-wide
  108. pop es
  109. cmp ax, [bp+6]
  110. jnz skip
  111. ;; Print it, so format message
  112. push bx
  113. test al, DEB_ERRORS
  114. mov bx, dataoffset STR_&comp&Error
  115. jnz @F
  116. test al, DEB_WARNS
  117. mov bx, dataoffset STR_&comp&Warn
  118. jnz @F
  119. test al, DEB_TRACES
  120. mov bx, dataoffset STR_&comp&Trace
  121. jnz @F
  122. jmp short deb_no_msg_type
  123. @@:
  124. push bx
  125. call KOutDSStr
  126. deb_no_msg_type:
  127. mov bx, dataoffset STR_&comp&Table
  128. or ah, ah
  129. jz deb_show_it
  130. @@:
  131. add bx, 2
  132. shr ah, 1
  133. jnz @B
  134. deb_show_it:
  135. push [bx] ;; push parameter
  136. call KOutDSStr
  137. pop bx ;; restore reg
  138. pop ax
  139. push [bp+8]
  140. call KOutDSStr
  141. push ax
  142. mov ax, [bp+6]
  143. and ax, [_&comp&BreakLevel]
  144. jz skip
  145. push es
  146. push seg _Win3BreakLevel
  147. pop es
  148. and ax, es:_Win3BreakLevel
  149. pop es
  150. jz skip
  151. int 3
  152. skip:
  153. test byte ptr [bp+6], DEB_FERRORS
  154. jz @F
  155. push 0
  156. push DGROUP
  157. push word ptr [bp+8]
  158. cCall FatalAppExit ;,<0,DGROUP,[bp+8]>
  159. @@:
  160. pop ax
  161. pop ds
  162. pop bp
  163. retf
  164. _&comp&DebugTest endp
  165. endm