debug.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 1,471 行 · 第 1/3 页
H
1,471 行
endif
if DEBLEVEL GE myDebLevel
??_fDoit = VMM_TRUE
endif
endif
if ??_fDoit
ife ?_DBOCODE
VxD_DEBUG_ONLY_DATA_SEG
fmtlab db fmt, 0
VxD_DEBUG_ONLY_DATA_ENDS
else
ifdef VMMSYS
VMM_LOCKED_DATA_SEG
fmtlab db fmt, 0
VMM_LOCKED_DATA_ENDS
else
VxD_LOCKED_DATA_SEG
fmtlab db fmt, 0
VxD_LOCKED_DATA_ENDS
endif ; VMMSYS
endif ; ?_DBOCODE
ifb <args>
VMMCall _Debug_Printf_Service, <(OFFSET32 fmtlab), esp>
else
VMMCall _Debug_Printf_Service, <(OFFSET32 fmtlab), esp, args>
endif
endif ; ??_fDoit
endm
;******************************************************************************
;
; Trace_Out / Debug_Out common code
;
;------------------------------------------------------------------------------
CHECK_EOL MACRO f, x, ln
ifdifi <x>,<noeol>
ifdifi <x>,<no_eol>
ifdifi <x>,<nocrlf>
ifdifi <x>,</noeol>
%OUT Line ln: Unknown symbol (x) in f, taken as NOEOL
endif
endif
endif
endif
ENDM
??_Gen_String macro lbl:req, str:req
ife ?_ICODE
??_segName textequ <_IDATA>
elseife ?_PCODE
??_segName textequ <_PDATA>
elseife ?_SCODE
??_segName textequ <_SDATA>
elseife ?_DBOCODE
??_segName textequ <_DB2DATA>
else
??_segName textequ <_LDATA> ; Default is locked data
endif
??_segName segment
lbl db str
ife ??_nocrlf
db 0dh,0ah
endif
db 0
??_segName ends
endm
??Trace_Debug_Helper macro typ, str, arg1, arg2
local string
ife ?_DBOCODE
??_fDoit = VMM_TRUE
else
??_fDoit = 0
endif
if (DEBLEVEL GT DEBLEVELRETAIL) OR ??_fDoit
??_nocrlf = 0
??_debLevel = DEBLEVELNORMAL
irp x, <arg1, arg2>
ifnb <x>
if ((.TYPE x) AND 20h) GT 0 ;; symbol defined
??_debLevel = x
else
Check_EOL <typ>, <x>, %(@Line)
??_nocrlf = 1
endif
endif
endm
if DEBLEVEL GE ??_debLevel
??_fDoit = VMM_TRUE
endif
endif
if ??_fDoit
irpc c, str
ifidn <c>, <">
??_is_string = 1
else
ifidni <c>, <'>
??_is_string = 1
else
??_is_string = 0
endif
endif
exitm
endm
if ??_is_string ; Put the string in the approp segment
??_Gen_String string, <str>
??_debug_out_str textequ <OFFSET32 string>
else
??_debug_out_str textequ <str>
endif
ifdef WIN31COMPAT
pushfd
pushad
mov esi, ??_debug_out_str
VMMCall Out_Debug_String
ifidni <typ>, <Debug_Out>
VMMCall Test_Debug_Installed
jz SHORT $+4
int 1
endif
popad
popfd
else
push ??_debug_out_str
ifidni <typ>, <Debug_Out>
VMMCall _Debug_Out_Service
else
VMMCall _Trace_Out_Service
endif
endif ; WIN31COMPAT
endif ; ??_fDoit
endm
;******************************************************************************
;
; Trace_Out
;
;------------------------------------------------------------------------------
; Create the following macros:
;
; Trace_OutS, Trace_OutNS, Trace_OutC, Trace_OutNC, Trace_OutA,
; Trace_OutNA, Trace_OutAE, Trace_OutNAE, Trace_OutB, Trace_OutNB,
; Trace_OutBE, Trace_OutNBE, Trace_OutE, Trace_OutNE, Trace_OutZ,
; Trace_OutNZ, Trace_OutG, Trace_OutNG, Trace_OutGE, Trace_OutNGE,
; Trace_OutL, Trace_OutNL, Trace_OutLE, Trace_OutNLE, Trace_OutO,
; Trace_OutNO
irp cond,<S,C,A,AE,B,BE,E,Z,G,GE,L,LE,O>
Trace_Out&cond macro str, arg1, arg2
?trace_out <str>,jn&cond, <arg1>, <arg2>
endm
Trace_OutN&cond macro str, arg1, arg2
?trace_out <str>,j&cond, <arg1>, <arg2>
endm
endm
Trace_Out MACRO str, arg1, arg2
??Trace_Debug_Helper <Trace_Out>, <str>, <arg1>, <arg2>
endm
Trace_OutECXZ macro str, arg1, arg2
local l1,l2
if (DEBLEVEL GT DEBLEVELRETAIL) or (?_DBOCODE eq 0)
jecxz l1
jmp short l2
l1: Trace_Out <str>, <arg1>, <arg2>
l2:
endif
endm
Trace_OutECXNZ macro str, arg1, arg2
?trace_out <str>,jecxz, <arg1>, <arg2>
endm
Trace_OutEAXz macro str, arg1, arg2
local l1
if (DEBLEVEL GT DEBLEVELRETAIL) or (?_DBOCODE eq 0)
or eax,eax
jnz short l1
Trace_Out <str>, <arg1>, <arg2>
l1:
endif
endm
Trace_OutEAXnz macro str, arg1, arg2
local l1
if (DEBLEVEL GT DEBLEVELRETAIL) or (?_DBOCODE eq 0)
or eax,eax
jz short l1
Trace_Out <str>, <arg1>, <arg2>
l1:
endif
endm
?trace_out macro str, jmpop, arg1, arg2
Local nomsg
if (DEBLEVEL GT DEBLEVELRETAIL) or (?_DBOCODE eq 0)
jmpop short nomsg
Trace_Out <str>,<arg1>,<arg2>
nomsg:
endif
endm
;******************************************************************************
;
; Debug_Out
;
;------------------------------------------------------------------------------
; Create the following macros:
;
; Debug_OutS, Debug_OutNS, Debug_OutC, Debug_OutNC, Debug_OutA,
; Debug_OutNA, Debug_OutAE, Debug_OutNAE, Debug_OutB, Debug_OutNB,
; Debug_OutBE, Debug_OutNBE, Debug_OutE, Debug_OutNE, Debug_OutZ,
; Debug_OutNZ, Debug_OutG, Debug_OutNG, Debug_OutGE, Debug_OutNGE,
; Debug_OutL, Debug_OutNL, Debug_OutLE, Debug_OutNLE, Debug_OutO,
; Debug_OutNO
irp cond,<S,C,A,AE,B,BE,E,Z,G,GE,L,LE,O>
Debug_Out&cond ¯o str, arg1
?debug_out <str>,jn&cond,<arg1>
&endm
Debug_OutN&cond ¯o str, arg1
?debug_out <str>,j&cond,<arg1>
&endm
endm
Debug_Out MACRO str, arg1, arg2
??Trace_Debug_Helper <Debug_Out>, <str>, <arg1>, <arg2>
endm
Debug_OutECXZ macro str, arg1
local l1,l2
if DEBLEVEL GT DEBLEVELRETAIL
jecxz l1
jmp short l2
l1: Debug_Out <str>, <arg1>
l2:
endif
endm
Debug_OutECXNZ macro str, arg1
?debug_out <str>,jecxz, <arg1>
endm
Debug_OutEAXz macro str, arg1
local l1
if DEBLEVEL GT DEBLEVELRETAIL
or eax,eax
jnz short l1
Debug_Out <str>, <arg1>
l1:
endif
endm
Debug_OutEAXnz macro str, arg1
local l1
if DEBLEVEL GT DEBLEVELRETAIL
or eax,eax
jz short l1
Debug_Out <str>, <arg1>
l1:
endif
endm
?debug_out macro str,jmpop, arg1
Local nomsg
if DEBLEVEL GT DEBLEVELRETAIL
jmpop short nomsg
Debug_Out <str>, <arg1>
nomsg:
endif
endm
;******************************************************************************
;
; Queue_Out
;
;------------------------------------------------------------------------------
Queue_Out MACRO S, V1, V2, DL
LOCAL Str_Off
LOCAL MyDebLevel
IF DEBLEVEL GT DEBLEVELRETAIL
IFB <DL>
myDebLevel = DEBLEVELNORMAL
ELSE
myDebLevel = DL
ENDIF
IF DEBLEVEL GE myDebLevel
_LDATA SEGMENT
Str_Off db S, 0dh,0ah, 0
_LDATA ENDS
push esi
IFNB <V1>
IF TYPE V1 GT 0
push dword ptr V1
ELSE
push V1
ENDIF
ELSE
push eax ; dummy value1
ENDIF
IFNB <V2>
IF TYPE V2 GT 0
push dword ptr V2
ELSE
push V2
ENDIF
ELSE
push ebx ; dummy value2
ENDIF
mov esi, OFFSET32 Str_Off
VMMCall Queue_Debug_String
pop esi
ENDIF
ENDIF
ENDM
;******************************************************************************
;
; Mono_Out
;
;------------------------------------------------------------------------------
Mono_Out MACRO S, nocrlf
LOCAL Str_Off
IF DEBLEVEL GT DEBLEVELRETAIL
_LDATA SEGMENT
Str_Off db S
IFB <nocrlf>
db 0dh,0ah
ENDIF
db 0
_LDATA ENDS
pushfd
pushad
mov esi, OFFSET32 Str_Off
VMMCall Out_Mono_String
popad
popfd
ENDIF
ENDM
;******************************************************************************
;
; Mono_Out_At
;
;------------------------------------------------------------------------------
Mono_Out_At MACRO Row, Col, S, nocrlf
LOCAL Str_Off
IF DEBLEVEL GT DEBLEVELRETAIL
_LDATA SEGMENT
Str_Off db S
IFB <nocrlf>
db 0dh,0ah
ENDIF
db 0
_LDATA ENDS
pushfd
pushad
mov dx, (Row SHL 8)+Col
VMMCall Set_Mono_Cur_Pos
mov esi, OFFSET32 Str_Off
VMMCall Out_Mono_String
popad
popfd
ENDIF
ENDM
;******************************************************************************
;
; Assert_Ints_Disabled
;
;------------------------------------------------------------------------------
Assert_Ints_Disabled MACRO DL
IFB <DL>
??_debLevel = DEBLEVELNORMAL
ELSE
??_debLevel = DL
ENDIF
IF DEBLEVEL GE ??_debLevel
ifndef ??_aidMessage
_LDATA segment
??_aidMessage db "ERROR: Ints enabled at Assert_Ints_Disabled"
db 0Dh, 0Ah, 0
_LDATA ends
endif
pushfd
test byte ptr [esp+1], IF_Mask SHR 8
.if !ZERO?
push OFFSET32 ??_aidMessage
VMMCall _Debug_Out_Service
.endif
popfd
ENDIF
ENDM
;******************************************************************************
;
; Assert_Ints_Enabled
;
;------------------------------------------------------------------------------
Assert_Ints_Enabled MACRO DL
IFB <DL>
??_debLevel = DEBLEVELNORMAL
ELSE
??_debLevel = DL
ENDIF
IF DEBLEVEL GE ??_debLevel
ifndef ??_aieMessage
_LDATA segment
??_aieMessage db "ERROR: Ints disabled at Assert_Ints_Enabled"
db 0Dh, 0Ah, 0
_LDATA ends
endif
pushfd
test byte ptr [esp+1], IF_Mask SHR 8
.if ZERO?
push OFFSET32 ??_aieMessage
VMMCall _Debug_Out_Service
.endif
popfd
ENDIF
ENDM
;******************************************************************************
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?