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

Last change on this file since 388 was 388, checked in by イグトランス (egtra), 16 years ago

Stringなどで例外を投げるようにした。
#147の解決。
CType ASCII文字判定関数群の追加。

File size: 2.9 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_StartProc(lpSpBase As ULONG_PTR, lpObp As ULONG_PTR)
32 Dim i As Long
33
34 Dim ThreadNum As Long
35 ThreadNum=_DebugSys_GetThread()
36 If ThreadNum=-1 Then Exit Sub
37
38 If _DebugSys_lplpObp[ThreadNum] Then
39 i=(_DebugSys_ProcNum[ThreadNum]+2)*SizeOf(ULONG_PTR)
40 _DebugSys_lplpObp[ThreadNum]=HeapReAlloc(GetProcessHeap(),0,_DebugSys_lplpObp[ThreadNum],i)
41 _DebugSys_lplpSpBase[ThreadNum]=HeapReAlloc(GetProcessHeap(),0,_DebugSys_lplpSpBase[ThreadNum],i)
42 Else
43 _DebugSys_ProcNum[ThreadNum]=0
44 _DebugSys_lplpObp[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
45 _DebugSys_lplpSpBase[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
46 End If
47 Set_LONG_PTR(_DebugSys_lplpObp[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR),lpObp)
48 Set_LONG_PTR(_DebugSys_lplpSpBase[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR),lpSpBase)
49
50 _DebugSys_ProcNum[ThreadNum]=_DebugSys_ProcNum[ThreadNum]+1
51End Sub
52
53Sub _DebugSys_EndProc()
54 Dim ThreadNum As Long
55 ThreadNum=_DebugSys_GetThread()
56 If ThreadNum=-1 Then Exit Sub
57
58 _DebugSys_ProcNum[ThreadNum]=_DebugSys_ProcNum[ThreadNum]-1
59End Sub
60
61Sub _DebugSys_SaveContext(lpSpBase As ULONG_PTR, lpObp As ULONG_PTR)
62 Dim ThreadNum As Long
63 ThreadNum=_DebugSys_GetThread()
64 If ThreadNum=-1 Then Exit Sub
65
66 If _DebugSys_lplpObp[ThreadNum]=0 Then
67 _DebugSys_ProcNum[ThreadNum]=0
68 _DebugSys_lplpObp[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
69 _DebugSys_lplpSpBase[ThreadNum]=HeapAlloc(GetProcessHeap(),0,SizeOf(ULONG_PTR)*2)
70 End If
71 Set_LONG_PTR(_DebugSys_lplpObp[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR), lpObp)
72 Set_LONG_PTR(_DebugSys_lplpSpBase[ThreadNum]+_DebugSys_ProcNum[ThreadNum]*SizeOf(ULONG_PTR), lpSpBase)
73End Sub
74
75Sub _esp_error()
76 MessageBox( NULL, "esp is wrong value.", "debug check error", MB_OK or MB_ICONEXCLAMATION )
77End Sub
78
79Sub _System_DebugOnly_OutputDebugString(buffer As *Char)
80#ifdef _DEBUG
81 OutputDebugString(buffer)
82#endif
83End Sub
Note: See TracBrowser for help on using the repository browser.