source: trunk/Include/system/debug.sbp@ 351

Last change on this file since 351 was 259, checked in by dai, 18 years ago

リリースコンパイル時にGC及び動的型情報に関するデバッグ出力を行わないようにした。

File size: 3.0 KB
Line 
1'debug.sbp
2'このファイル内のコードはデバッグ コンパイル時のみ有効です(リリース コンパイルでは無視されます)。
3
4'Dim _DebugSys_dwThreadID[255] As DWord - コンパイラが自動的に定義します
5'Dim _DebugSys_ProcNum[255] As DWord - コンパイラが自動的に定義します
6'Dim _DebugSys_lplpObp[255] As *ULONG_PTR - コンパイラが自動的に定義します
7'Dim _DebugSys_lplpSpBase[255] As *ULONG_PTR - コンパイラが自動的に定義します
8
9Function _DebugSys_GetThread() As Long
10 Dim dwThreadID As DWord
11 Dim ThreadNum As Long
12
13 dwThreadID=GetCurrentThreadId()
14 ThreadNum=0
15 Do
16 If dwThreadID=_DebugSys_dwThreadID[ThreadNum] Then Exit Do
17 ThreadNum=ThreadNum+1
18 If ThreadNum>255 Then
19 ThreadNum=-1
20 Exit Do
21
22 /*debug
23 OutputDebugString(Ex"[GetThread]デバッグ情報が異常です。プロセスを終了します。\r\n")
24 ExitProcess(0)*/
25 End If
26 Loop
27
28 _DebugSys_GetThread=ThreadNum
29End Function
30
31Sub _DebugSys_Set_LONG_PTR(pPtr As VoidPtr, lpData As LONG_PTR)
32#ifdef _WIN64
33 SetQWord(pPtr,lpData)
34#else
35 SetDWord(pPtr,lpData)
36#endif
37End Sub
38
39Sub _DebugSys_StartProc(lpSpBase As ULONG_PTR, lpObp As ULONG_PTR)
40 Dim i As Long
41
42 Dim ThreadNum As Long
43 ThreadNum=_DebugSys_GetThread()
44 If ThreadNum=-1 Then Exit Sub
45
46 If _DebugSys_lplpObp[ThreadNum] Then
47 i=(_DebugSys_ProcNum[ThreadNum]+2)*SizeOf(ULONG_PTR)
48 _DebugSys_lplpObp[ThreadNum]=HeapReAlloc(GetProcessHeap(),0,_DebugSys_lplpObp[ThreadNum],i)
49 _DebugSys_lplpSpBase[ThreadNum]=HeapReAlloc(GetProcessHeap(),0,_DebugSys_lplpSpBase[ThreadNum],i)
50 Else
51 _DebugSys_ProcNum[ThreadNum]=0
52 _DebugSys_lplpObp[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
53 _DebugSys_lplpSpBase[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
54 End If
55 _DebugSys_Set_LONG_PTR(_DebugSys_lplpObp[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR),lpObp)
56 _DebugSys_Set_LONG_PTR(_DebugSys_lplpSpBase[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR),lpSpBase)
57
58 _DebugSys_ProcNum[ThreadNum]=_DebugSys_ProcNum[ThreadNum]+1
59End Sub
60
61Sub _DebugSys_EndProc()
62 Dim ThreadNum As Long
63 ThreadNum=_DebugSys_GetThread()
64 If ThreadNum=-1 Then Exit Sub
65
66 _DebugSys_ProcNum[ThreadNum]=_DebugSys_ProcNum[ThreadNum]-1
67End Sub
68
69Sub _DebugSys_SaveContext(lpSpBase As ULONG_PTR, lpObp As ULONG_PTR)
70 Dim ThreadNum As Long
71 ThreadNum=_DebugSys_GetThread()
72 If ThreadNum=-1 Then Exit Sub
73
74 If _DebugSys_lplpObp[ThreadNum]=0 Then
75 _DebugSys_ProcNum[ThreadNum]=0
76 _DebugSys_lplpObp[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
77 _DebugSys_lplpSpBase[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
78 End If
79 _DebugSys_Set_LONG_PTR(_DebugSys_lplpObp[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR), lpObp)
80 _DebugSys_Set_LONG_PTR(_DebugSys_lplpSpBase[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR), lpSpBase)
81End Sub
82
83Sub _esp_error()
84 MessageBox( NULL, "esp is wrong value.", "debug check error", MB_OK or MB_ICONEXCLAMATION )
85End Sub
86
87Sub _System_DebugOnly_OutputDebugString(buffer As *Char)
88#ifdef _DEBUG
89 OutputDebugString(buffer)
90#endif
91End Sub
Note: See TracBrowser for help on using the repository browser.