1 | #include "../BasicCompiler_Common/common.h"
|
---|
2 |
|
---|
3 | #ifdef _AMD64_
|
---|
4 | #include "../BasicCompiler64/opcode.h"
|
---|
5 | #else
|
---|
6 | #include "../BasicCompiler32/opcode.h"
|
---|
7 | #endif
|
---|
8 |
|
---|
9 | #define MDLFILE_VER 0x70000003
|
---|
10 |
|
---|
11 |
|
---|
12 | void SetLpIndex_DebugFile(char *buffer,int *p,int type,LONG_PTR lpIndex){
|
---|
13 | if(NATURAL_TYPE(type)==DEF_OBJECT){
|
---|
14 | lstrcpy(buffer+(*p),((CClass *)lpIndex)->name);
|
---|
15 | (*p)+=lstrlen(buffer+(*p))+1;
|
---|
16 | }
|
---|
17 | else{
|
---|
18 | *(LONG_PTR *)(buffer+(*p))=lpIndex;
|
---|
19 | (*p)+=sizeof(LONG_PTR);
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 |
|
---|
24 | void GetLpIndex_DebugFile(char *buffer,int *p,int type,LONG_PTR *plpIndex){
|
---|
25 | if(NATURAL_TYPE(type)==DEF_OBJECT){
|
---|
26 | char szClassName[VN_SIZE];
|
---|
27 | lstrcpy(szClassName,buffer+(*p));
|
---|
28 | (*p)+=lstrlen(buffer+(*p))+1;
|
---|
29 |
|
---|
30 | *plpIndex=(LONG_PTR)pobj_DBClass->check(szClassName);
|
---|
31 | }
|
---|
32 | else{
|
---|
33 | *plpIndex=*(LONG_PTR *)(buffer+(*p));
|
---|
34 | (*p)+=sizeof(LONG_PTR);
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | CDebugSection::CDebugSection(){
|
---|
41 | memset(this,0,sizeof(CDebugSection));
|
---|
42 | }
|
---|
43 | CDebugSection::~CDebugSection(){
|
---|
44 | if(pobj_DBClass) DeleteDebugInfo();
|
---|
45 | if(buffer){
|
---|
46 | HeapDefaultFree(buffer);
|
---|
47 | buffer=0;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | void CDebugSection::make(void){
|
---|
51 | extern VARIABLE *GlobalVar;
|
---|
52 | extern int MaxGlobalVarNum;
|
---|
53 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
54 | int i2,i3,i4,i5,BufferSize;
|
---|
55 |
|
---|
56 | if(buffer){
|
---|
57 | HeapDefaultFree(buffer);
|
---|
58 | buffer=0;
|
---|
59 | }
|
---|
60 |
|
---|
61 | i2=0;
|
---|
62 |
|
---|
63 | extern char *basbuf;
|
---|
64 | i3=lstrlen(basbuf);
|
---|
65 |
|
---|
66 | BufferSize=lstrlen(basbuf)+65535;
|
---|
67 | buffer=(char *)HeapAlloc(hHeap,0,BufferSize);
|
---|
68 |
|
---|
69 | //デバッグ用ファイルのバージョン
|
---|
70 | *(long *)(buffer+i2)=MDLFILE_VER;
|
---|
71 | i2+=sizeof(long);
|
---|
72 |
|
---|
73 | //プラットフォームのビット数
|
---|
74 | *(long *)(buffer+i2)=PLATFORM;
|
---|
75 | i2+=sizeof(long);
|
---|
76 |
|
---|
77 | //インクルード情報
|
---|
78 | *(long *)(buffer+i2)=IncludeFileInfo.FilesNum;
|
---|
79 | i2+=sizeof(long);
|
---|
80 | for(i3=0;i3<IncludeFileInfo.FilesNum;i3++){
|
---|
81 | lstrcpy(buffer+i2,IncludeFileInfo.ppFileNames[i3]);
|
---|
82 | i2+=lstrlen(buffer+i2)+1;
|
---|
83 | }
|
---|
84 | buffer[i2++]=0;
|
---|
85 | for(i3=0;;i3++){
|
---|
86 | buffer[i2++]=(char)IncludeFileInfo.LineOfFile[i3];
|
---|
87 | if(IncludeFileInfo.LineOfFile[i3]==-1) break;
|
---|
88 | }
|
---|
89 |
|
---|
90 | //ソースコード
|
---|
91 | lstrcpy(buffer+i2,basbuf);
|
---|
92 | i2+=lstrlen(buffer+i2)+1;
|
---|
93 |
|
---|
94 |
|
---|
95 | ////////////////////////
|
---|
96 | // コードと行番号の関係
|
---|
97 | ////////////////////////
|
---|
98 | extern int MaxLineInfoNum;
|
---|
99 | extern LINEINFO *pLineInfo;
|
---|
100 |
|
---|
101 | //バッファが足りない場合は再確保
|
---|
102 | if(MaxLineInfoNum*sizeof(LINEINFO)<32768) i3=32768;
|
---|
103 | else i3=MaxLineInfoNum*sizeof(LINEINFO)+32768;
|
---|
104 | if(BufferSize<i2+i3){
|
---|
105 | BufferSize+=i3;
|
---|
106 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
107 | }
|
---|
108 |
|
---|
109 | *(long *)(buffer+i2)=MaxLineInfoNum;
|
---|
110 | i2+=sizeof(long);
|
---|
111 | memcpy(buffer+i2,pLineInfo,MaxLineInfoNum*sizeof(LINEINFO));
|
---|
112 | i2+=MaxLineInfoNum*sizeof(LINEINFO);
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 | ////////////////////////////////////////////
|
---|
117 | // クラス情報(名前のみ。詳細は後で保存)
|
---|
118 | ////////////////////////////////////////////
|
---|
119 |
|
---|
120 | //イテレータをリセット
|
---|
121 | extern CDBClass *pobj_DBClass;
|
---|
122 | pobj_DBClass->Iterator_Reset();
|
---|
123 |
|
---|
124 | //個数
|
---|
125 | *(long *)(buffer+i2)=pobj_DBClass->Iterator_GetMaxCount();
|
---|
126 | i2+=sizeof(long);
|
---|
127 |
|
---|
128 | while(pobj_DBClass->Iterator_HasNext()){
|
---|
129 | CClass *pobj_c;
|
---|
130 | pobj_c=pobj_DBClass->Iterator_GetNext();
|
---|
131 |
|
---|
132 | //クラス名
|
---|
133 | lstrcpy(buffer+i2,pobj_c->name);
|
---|
134 | i2+=lstrlen(buffer+i2)+1;
|
---|
135 | }
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 | //////////////////
|
---|
140 | // TypeDef情報
|
---|
141 | //////////////////
|
---|
142 |
|
---|
143 | extern CDBTypeDef *pobj_DBTypeDef;
|
---|
144 | *(long *)(buffer+i2)=pobj_DBTypeDef->iNum;
|
---|
145 | i2+=sizeof(long);
|
---|
146 | for(i3=0;i3<pobj_DBTypeDef->iNum;i3++){
|
---|
147 | lstrcpy(buffer+i2,pobj_DBTypeDef->ppobj_TypeDef[i3]->lpszName);
|
---|
148 | i2+=lstrlen(buffer+i2)+1;
|
---|
149 |
|
---|
150 | lstrcpy(buffer+i2,pobj_DBTypeDef->ppobj_TypeDef[i3]->lpszBaseName);
|
---|
151 | i2+=lstrlen(buffer+i2)+1;
|
---|
152 |
|
---|
153 | //バッファが足りない場合は再確保
|
---|
154 | if(BufferSize<i2+32768){
|
---|
155 | BufferSize+=32768;
|
---|
156 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | //グローバル変数情報
|
---|
162 | *(long *)(buffer+i2)=MaxGlobalVarNum;
|
---|
163 | i2+=sizeof(long);
|
---|
164 | for(i3=0;i3<MaxGlobalVarNum;i3++){
|
---|
165 | VARIABLE *pVar=&GlobalVar[i3];
|
---|
166 |
|
---|
167 | //変数名
|
---|
168 | lstrcpy(buffer+i2,pVar->name);
|
---|
169 | i2+=lstrlen(buffer+i2)+1;
|
---|
170 |
|
---|
171 | //型
|
---|
172 | *(long *)(buffer+i2)=pVar->type;
|
---|
173 | i2+=sizeof(long);
|
---|
174 |
|
---|
175 | //型の拡張情報
|
---|
176 | SetLpIndex_DebugFile(buffer,&i2,pVar->type,pVar->u.index);
|
---|
177 |
|
---|
178 | buffer[i2++]=(char)pVar->fRef;
|
---|
179 |
|
---|
180 | buffer[i2++]=(char)pVar->bArray;
|
---|
181 |
|
---|
182 | if(pVar->bArray){
|
---|
183 | for(i4=0;;i4++){
|
---|
184 | *(long *)(buffer+i2)=pVar->SubScripts[i4];
|
---|
185 | i2+=sizeof(long);
|
---|
186 | if(pVar->SubScripts[i4]==-1) break;
|
---|
187 | }
|
---|
188 | }
|
---|
189 |
|
---|
190 | //レキシカルスコープ情報
|
---|
191 | *(long *)(buffer+i2)=pVar->ScopeStartAddress;
|
---|
192 | i2+=sizeof(long);
|
---|
193 | *(long *)(buffer+i2)=pVar->ScopeEndAddress;
|
---|
194 | i2+=sizeof(long);
|
---|
195 | *(long *)(buffer+i2)=pVar->ScopeLevel;
|
---|
196 | i2+=sizeof(long);
|
---|
197 |
|
---|
198 | //メモリ位置
|
---|
199 | *(long *)(buffer+i2)=pVar->offset;
|
---|
200 | i2+=sizeof(long);
|
---|
201 |
|
---|
202 | //バッファが足りない場合は再確保
|
---|
203 | if(BufferSize<i2+32768){
|
---|
204 | BufferSize+=32768;
|
---|
205 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | //グローバル実行領域のサイズ
|
---|
210 | extern int GlobalOpBufferSize;
|
---|
211 | *(long *)(buffer+i2)=GlobalOpBufferSize;
|
---|
212 | i2+=sizeof(long);
|
---|
213 |
|
---|
214 | //プロシージャ情報
|
---|
215 | extern SUBINFO **ppSubHash;
|
---|
216 | extern int SubNum;
|
---|
217 | SUBINFO *psi;
|
---|
218 | *(long *)(buffer+i2)=SubNum;
|
---|
219 | i2+=sizeof(long);
|
---|
220 | for(i3=0;i3<MAX_HASH;i3++){
|
---|
221 | psi=ppSubHash[i3];
|
---|
222 | while(psi){
|
---|
223 | if(psi->pobj_ParentClass){
|
---|
224 | lstrcpy(buffer+i2,psi->pobj_ParentClass->name);
|
---|
225 | i2+=lstrlen(buffer+i2)+1;
|
---|
226 | }
|
---|
227 | else{
|
---|
228 | lstrcpy(buffer+i2,"");
|
---|
229 | i2+=lstrlen(buffer+i2)+1;
|
---|
230 | }
|
---|
231 |
|
---|
232 | //ID
|
---|
233 | *(long *)(buffer+i2)=psi->id;
|
---|
234 | i2+=sizeof(long);
|
---|
235 |
|
---|
236 | //関数名
|
---|
237 | lstrcpy(buffer+i2,psi->name);
|
---|
238 | i2+=lstrlen(buffer+i2)+1;
|
---|
239 |
|
---|
240 | *(long *)(buffer+i2)=psi->CompileAddress;
|
---|
241 | i2+=sizeof(long);
|
---|
242 | *(long *)(buffer+i2)=psi->EndOpAddr;
|
---|
243 | i2+=sizeof(long);
|
---|
244 |
|
---|
245 | *(long *)(buffer+i2)=psi->bVirtual;
|
---|
246 | i2+=sizeof(long);
|
---|
247 |
|
---|
248 | //ローカル変数情報
|
---|
249 | *(long *)(buffer+i2)=psi->VarNum;
|
---|
250 | i2+=sizeof(long);
|
---|
251 |
|
---|
252 | //バッファが足りない場合は再確保
|
---|
253 | if(BufferSize<i2+32768){
|
---|
254 | BufferSize+=32768;
|
---|
255 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
256 | }
|
---|
257 |
|
---|
258 | for(i4=0;i4<psi->VarNum;i4++){
|
---|
259 | VARIABLE *pVar=&psi->pVar[i4];
|
---|
260 | lstrcpy(buffer+i2,pVar->name);
|
---|
261 | i2+=lstrlen(buffer+i2)+1;
|
---|
262 |
|
---|
263 | //型
|
---|
264 | *(long *)(buffer+i2)=pVar->type;
|
---|
265 | i2+=sizeof(long);
|
---|
266 |
|
---|
267 | //型の拡張情報
|
---|
268 | SetLpIndex_DebugFile(buffer,&i2,pVar->type,pVar->u.index);
|
---|
269 |
|
---|
270 | //参照型パラメータかどうか
|
---|
271 | buffer[i2++]=(char)pVar->fRef;
|
---|
272 |
|
---|
273 | //配列かどうか
|
---|
274 | buffer[i2++]=(char)pVar->bArray;
|
---|
275 |
|
---|
276 | //配列要素
|
---|
277 | if(pVar->bArray){
|
---|
278 | for(i5=0;;i5++){
|
---|
279 | *(long *)(buffer+i2)=pVar->SubScripts[i5];
|
---|
280 | i2+=sizeof(long);
|
---|
281 | if(pVar->SubScripts[i5]==-1) break;
|
---|
282 | }
|
---|
283 | }
|
---|
284 | else pVar->SubScripts[0]=-1;
|
---|
285 |
|
---|
286 | //レキシカルスコープ情報
|
---|
287 | *(long *)(buffer+i2)=pVar->ScopeStartAddress;
|
---|
288 | i2+=sizeof(long);
|
---|
289 | *(long *)(buffer+i2)=pVar->ScopeEndAddress;
|
---|
290 | i2+=sizeof(long);
|
---|
291 | *(long *)(buffer+i2)=pVar->ScopeLevel;
|
---|
292 | i2+=sizeof(long);
|
---|
293 |
|
---|
294 | //メモリ位置
|
---|
295 | *(long *)(buffer+i2)=pVar->offset;
|
---|
296 | i2+=sizeof(long);
|
---|
297 |
|
---|
298 |
|
---|
299 |
|
---|
300 |
|
---|
301 | //バッファが足りない場合は再確保
|
---|
302 | if(BufferSize<i2+32768){
|
---|
303 | BufferSize+=32768;
|
---|
304 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
305 | }
|
---|
306 | }
|
---|
307 |
|
---|
308 | psi=psi->pNextData;
|
---|
309 | }
|
---|
310 | }
|
---|
311 |
|
---|
312 |
|
---|
313 |
|
---|
314 | ///////////////////
|
---|
315 | // クラス情報
|
---|
316 | ///////////////////
|
---|
317 |
|
---|
318 | //イテレータをリセット
|
---|
319 | pobj_DBClass->Iterator_Reset();
|
---|
320 |
|
---|
321 | while(pobj_DBClass->Iterator_HasNext()){
|
---|
322 | CClass *pobj_c;
|
---|
323 | pobj_c=pobj_DBClass->Iterator_GetNext();
|
---|
324 |
|
---|
325 |
|
---|
326 | //クラス名
|
---|
327 | lstrcpy(buffer+i2,pobj_c->name);
|
---|
328 | i2+=lstrlen(buffer+i2)+1;
|
---|
329 |
|
---|
330 | //仮想関数の数
|
---|
331 | *(long *)(buffer+i2)=pobj_c->vtbl_num;
|
---|
332 | i2+=sizeof(long);
|
---|
333 |
|
---|
334 | //アラインメント
|
---|
335 | *(long *)(buffer+i2)=pobj_c->iAlign;
|
---|
336 | i2+=sizeof(long);
|
---|
337 |
|
---|
338 | //メンバ
|
---|
339 | *(long *)(buffer+i2)=pobj_c->iMemberNum;
|
---|
340 | i2+=sizeof(long);
|
---|
341 | for(i4=0;i4<pobj_c->iMemberNum;i4++){
|
---|
342 | lstrcpy(buffer+i2,pobj_c->ppobj_Member[i4]->name);
|
---|
343 | i2+=lstrlen(buffer+i2)+1;
|
---|
344 |
|
---|
345 | memcpy(buffer+i2,pobj_c->ppobj_Member[i4]->SubScripts,sizeof(int)*MAX_ARRAYDIM);
|
---|
346 | i2+=sizeof(int)*MAX_ARRAYDIM;
|
---|
347 |
|
---|
348 | //型
|
---|
349 | *(long *)(buffer+i2)=pobj_c->ppobj_Member[i4]->TypeInfo.type;
|
---|
350 | i2+=sizeof(long);
|
---|
351 |
|
---|
352 | //型の拡張情報
|
---|
353 | SetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_Member[i4]->TypeInfo.type,pobj_c->ppobj_Member[i4]->TypeInfo.u.lpIndex);
|
---|
354 |
|
---|
355 | *(long *)(buffer+i2)=pobj_c->ppobj_Member[i4]->dwAccess;
|
---|
356 | i2+=sizeof(long);
|
---|
357 |
|
---|
358 | //バッファが足りない場合は再確保
|
---|
359 | if(BufferSize<i2+32768){
|
---|
360 | BufferSize+=32768;
|
---|
361 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
362 | }
|
---|
363 | }
|
---|
364 |
|
---|
365 | //メソッド
|
---|
366 | *(long *)(buffer+i2)=pobj_c->iMethodNum;
|
---|
367 | i2+=sizeof(long);
|
---|
368 | for(i4=0;i4<pobj_c->iMethodNum;i4++){
|
---|
369 | *(long *)(buffer+i2)=pobj_c->ppobj_Method[i4]->dwAccess;
|
---|
370 | i2+=sizeof(long);
|
---|
371 | if(pobj_c->ppobj_Method[i4]->pobj_InheritsClass){
|
---|
372 | lstrcpy(buffer+i2,pobj_c->ppobj_Method[i4]->pobj_InheritsClass->name);
|
---|
373 | i2+=lstrlen(buffer+i2)+1;
|
---|
374 | }
|
---|
375 | else{
|
---|
376 | lstrcpy(buffer+i2,"");
|
---|
377 | i2+=lstrlen(buffer+i2)+1;
|
---|
378 | }
|
---|
379 | lstrcpy(buffer+i2,pobj_c->ppobj_Method[i4]->psi->name);
|
---|
380 | i2+=lstrlen(buffer+i2)+1;
|
---|
381 | }
|
---|
382 |
|
---|
383 | //静的メンバ
|
---|
384 | *(long *)(buffer+i2)=pobj_c->iStaticMemberNum;
|
---|
385 | i2+=sizeof(long);
|
---|
386 | for(i4=0;i4<pobj_c->iStaticMemberNum;i4++){
|
---|
387 | lstrcpy(buffer+i2,pobj_c->ppobj_StaticMember[i4]->name);
|
---|
388 | i2+=lstrlen(buffer+i2)+1;
|
---|
389 |
|
---|
390 | memcpy(buffer+i2,pobj_c->ppobj_StaticMember[i4]->SubScripts,sizeof(int)*MAX_ARRAYDIM);
|
---|
391 | i2+=sizeof(int)*MAX_ARRAYDIM;
|
---|
392 |
|
---|
393 | //型
|
---|
394 | *(long *)(buffer+i2)=pobj_c->ppobj_StaticMember[i4]->TypeInfo.type;
|
---|
395 | i2+=sizeof(long);
|
---|
396 |
|
---|
397 | //型の拡張情報
|
---|
398 | SetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_StaticMember[i4]->TypeInfo.type,pobj_c->ppobj_StaticMember[i4]->TypeInfo.u.lpIndex);
|
---|
399 |
|
---|
400 | *(long *)(buffer+i2)=pobj_c->ppobj_StaticMember[i4]->dwAccess;
|
---|
401 | i2+=sizeof(long);
|
---|
402 |
|
---|
403 | //バッファが足りない場合は再確保
|
---|
404 | if(BufferSize<i2+32768){
|
---|
405 | BufferSize+=32768;
|
---|
406 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
407 | }
|
---|
408 | }
|
---|
409 |
|
---|
410 | //バッファが足りない場合は再確保
|
---|
411 | if(BufferSize<i2+32768){
|
---|
412 | BufferSize+=32768;
|
---|
413 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 | length=i2;
|
---|
418 | }
|
---|
419 |
|
---|
420 | char *CDebugSection::MakeSingleStepCode(void){
|
---|
421 | char *buffer;
|
---|
422 | buffer=(char *)HeapAlloc(hHeap,0,SizeOf_CodeSection);
|
---|
423 |
|
---|
424 | memcpy(buffer,OpBuffer,SizeOf_CodeSection);
|
---|
425 |
|
---|
426 | int i2;
|
---|
427 | for(i2=0;i2<MaxLineInfoNum;i2++){
|
---|
428 | if(!(
|
---|
429 | pLineInfo[i2].dwCodeType&CODETYPE_SYSTEMPROC||
|
---|
430 | pLineInfo[i2].dwCodeType&CODETYPE_DEBUGPROC
|
---|
431 | )){
|
---|
432 | //int 3
|
---|
433 | buffer[pLineInfo[i2].TopObp]=(char)0xCC;
|
---|
434 | }
|
---|
435 | }
|
---|
436 |
|
---|
437 | return buffer;
|
---|
438 | }
|
---|
439 | BOOL CDebugSection::__load(void){
|
---|
440 | int i2,i3,i4,i5,num;
|
---|
441 | char temp2[MAX_PATH],*temp5;
|
---|
442 |
|
---|
443 | i2=0;
|
---|
444 |
|
---|
445 | //デバッグ用ファイルのバージョンをチェック
|
---|
446 | if(*(long *)(buffer+i2)<MDLFILE_VER){
|
---|
447 | HeapDefaultFree(buffer);
|
---|
448 | return 0;
|
---|
449 | }
|
---|
450 | i2+=sizeof(long);
|
---|
451 |
|
---|
452 | //プラットフォームのビット数をチェック
|
---|
453 | if(*(long *)(buffer+i2)!=PLATFORM){
|
---|
454 | HeapDefaultFree(buffer);
|
---|
455 | return 0;
|
---|
456 | }
|
---|
457 | i2+=sizeof(long);
|
---|
458 |
|
---|
459 | //インクルード情報
|
---|
460 | IncludeFileInfo.FilesNum=*(long *)(buffer+i2);
|
---|
461 | i2+=sizeof(long);
|
---|
462 | IncludeFileInfo.ppFileNames=(char **)HeapAlloc(hHeap,0,IncludeFileInfo.FilesNum*sizeof(char *));
|
---|
463 | for(i3=0;i3<IncludeFileInfo.FilesNum;i3++){
|
---|
464 | if(buffer[i2]=='\0') break;
|
---|
465 | IncludeFileInfo.ppFileNames[i3]=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
|
---|
466 | lstrcpy(IncludeFileInfo.ppFileNames[i3],buffer+i2);
|
---|
467 | i2+=lstrlen(buffer+i2)+1;
|
---|
468 | }
|
---|
469 | for(i2++,i3=0;;i2++,i3++){
|
---|
470 | IncludeFileInfo.LineOfFile[i3]=(long)buffer[i2];
|
---|
471 | if(IncludeFileInfo.LineOfFile[i3]==-1) break;
|
---|
472 | }
|
---|
473 |
|
---|
474 | //ソースコード
|
---|
475 | i2++;
|
---|
476 | pBaseBuffer=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+3);
|
---|
477 | basbuf=pBaseBuffer+2;
|
---|
478 | lstrcpy(basbuf,buffer+i2);
|
---|
479 | i2+=lstrlen(buffer+i2)+1;
|
---|
480 | extern char *basbuf;
|
---|
481 | basbuf=this->basbuf;
|
---|
482 |
|
---|
483 | //コードと行番号の関係
|
---|
484 | MaxLineInfoNum=*(long *)(buffer+i2);
|
---|
485 | i2+=sizeof(long);
|
---|
486 | pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)+1);
|
---|
487 | memcpy(pLineInfo,buffer+i2,MaxLineInfoNum*sizeof(LINEINFO));
|
---|
488 | i2+=MaxLineInfoNum*sizeof(LINEINFO);
|
---|
489 |
|
---|
490 |
|
---|
491 | ///////////////////////////////////////////
|
---|
492 | // クラス情報(名前のみ。詳細は後で取得)
|
---|
493 | ///////////////////////////////////////////
|
---|
494 |
|
---|
495 | this->pobj_DBClass=new CDBClass();
|
---|
496 |
|
---|
497 | int iMaxClassCount;
|
---|
498 | iMaxClassCount=*(long *)(buffer+i2);
|
---|
499 | i2+=sizeof(long);
|
---|
500 | for(i3=0;i3<iMaxClassCount;i3++){
|
---|
501 | //クラス名
|
---|
502 | pobj_DBClass->AddClass(buffer+i2,0);
|
---|
503 | i2+=lstrlen(buffer+i2)+1;
|
---|
504 | }
|
---|
505 |
|
---|
506 | extern CDBClass *pobj_DBClass;
|
---|
507 | pobj_DBClass=this->pobj_DBClass;
|
---|
508 |
|
---|
509 |
|
---|
510 | //////////////////
|
---|
511 | // TypeDef情報
|
---|
512 | //////////////////
|
---|
513 |
|
---|
514 | //初期化
|
---|
515 | pobj_DBTypeDef=new CDBTypeDef;
|
---|
516 |
|
---|
517 | //個数を取得
|
---|
518 | num=*(long *)(buffer+i2);
|
---|
519 | i2+=sizeof(long);
|
---|
520 | for(i3=0;i3<num;i3++){
|
---|
521 | temp5=buffer+i2;
|
---|
522 | i2+=lstrlen(buffer+i2)+1;
|
---|
523 |
|
---|
524 | pobj_DBTypeDef->add(temp5,buffer+i2);
|
---|
525 |
|
---|
526 | i2+=lstrlen(buffer+i2)+1;
|
---|
527 | }
|
---|
528 |
|
---|
529 | extern CDBTypeDef *pobj_DBTypeDef;
|
---|
530 | pobj_DBTypeDef=this->pobj_DBTypeDef;
|
---|
531 |
|
---|
532 | //定数を取得
|
---|
533 | GetConstInfo();
|
---|
534 | extern CONSTINFO **ppConstHash;
|
---|
535 | this->ppConstHash=ppConstHash;
|
---|
536 |
|
---|
537 |
|
---|
538 | //グローバル変数情報
|
---|
539 | MaxGlobalVarNum=*(long *)(buffer+i2);
|
---|
540 | i2+=sizeof(long);
|
---|
541 | GlobalVar=(VARIABLE *)HeapAlloc(hHeap,0,MaxGlobalVarNum*sizeof(VARIABLE)+1);
|
---|
542 | for(i3=0;i3<MaxGlobalVarNum;i3++){
|
---|
543 | VARIABLE *pVar=&GlobalVar[i3];
|
---|
544 |
|
---|
545 | //変数名
|
---|
546 | lstrcpy(pVar->name,buffer+i2);
|
---|
547 | i2+=lstrlen(buffer+i2)+1;
|
---|
548 |
|
---|
549 | pVar->type=*(long *)(buffer+i2);
|
---|
550 | i2+=sizeof(long);
|
---|
551 |
|
---|
552 | GetLpIndex_DebugFile(buffer,&i2,pVar->type,&pVar->u.index);
|
---|
553 |
|
---|
554 | pVar->fRef=(long)buffer[i2++];
|
---|
555 |
|
---|
556 | pVar->bArray=(long)buffer[i2++];
|
---|
557 | if(pVar->bArray){
|
---|
558 | for(i4=0;;i4++){
|
---|
559 | pVar->SubScripts[i4]=*(long *)(buffer+i2);
|
---|
560 | i2+=sizeof(long);
|
---|
561 |
|
---|
562 | if(pVar->SubScripts[i4]==-1) break;
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | //レキシカルスコープ情報
|
---|
567 | pVar->ScopeStartAddress=*(long *)(buffer+i2);
|
---|
568 | i2+=sizeof(long);
|
---|
569 | pVar->ScopeEndAddress=*(long *)(buffer+i2);
|
---|
570 | i2+=sizeof(long);
|
---|
571 | pVar->ScopeLevel=*(long *)(buffer+i2);
|
---|
572 | i2+=sizeof(long);
|
---|
573 |
|
---|
574 | //メモリ位置
|
---|
575 | pVar->offset=*(long *)(buffer+i2);
|
---|
576 | i2+=sizeof(long);
|
---|
577 | }
|
---|
578 |
|
---|
579 | //グローバル実行領域のサイズ
|
---|
580 | GlobalOpBufferSize=*(long *)(buffer+i2);
|
---|
581 | i2+=sizeof(long);
|
---|
582 |
|
---|
583 | //プロシージャ情報
|
---|
584 | SUBINFO *psi;
|
---|
585 | SubNum=*(long *)(buffer+i2);
|
---|
586 | i2+=sizeof(long);
|
---|
587 | ppSubHash=(SUBINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SUBINFO *));
|
---|
588 | for(i3=0;i3<SubNum;i3++){
|
---|
589 | psi=(SUBINFO *)HeapAlloc(hHeap,0,sizeof(SUBINFO));
|
---|
590 | psi->pNextData=0;
|
---|
591 |
|
---|
592 | char szParentClassName[VN_SIZE];
|
---|
593 | lstrcpy(szParentClassName,buffer+i2);
|
---|
594 | i2+=lstrlen(buffer+i2)+1;
|
---|
595 |
|
---|
596 | if(szParentClassName[0])
|
---|
597 | psi->pobj_ParentClass=pobj_DBClass->check(szParentClassName);
|
---|
598 | else psi->pobj_ParentClass=0;
|
---|
599 |
|
---|
600 | //ID
|
---|
601 | psi->id=*(long *)(buffer+i2);
|
---|
602 | i2+=sizeof(long);
|
---|
603 |
|
---|
604 | //名前
|
---|
605 | psi->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
|
---|
606 | lstrcpy(psi->name,buffer+i2);
|
---|
607 | i2+=lstrlen(buffer+i2)+1;
|
---|
608 |
|
---|
609 | psi->CompileAddress=*(long *)(buffer+i2);
|
---|
610 | i2+=sizeof(long);
|
---|
611 | psi->EndOpAddr=*(long *)(buffer+i2);
|
---|
612 | i2+=sizeof(long);
|
---|
613 |
|
---|
614 | psi->bVirtual=*(long *)(buffer+i2);
|
---|
615 | i2+=sizeof(long);
|
---|
616 |
|
---|
617 | psi->ParmNum=0;
|
---|
618 | psi->pParmInfo=0;
|
---|
619 | psi->RealParmNum=0;
|
---|
620 | psi->pRealParmInfo=0;
|
---|
621 | psi->bCompile=1;
|
---|
622 |
|
---|
623 | //ローカル変数情報
|
---|
624 | psi->VarNum=*(long *)(buffer+i2);
|
---|
625 | i2+=sizeof(long);
|
---|
626 | psi->pVar=(VARIABLE *)HeapAlloc(hHeap,0,psi->VarNum*sizeof(VARIABLE)+1);
|
---|
627 | for(i4=0;i4<psi->VarNum;i4++){
|
---|
628 | VARIABLE *pVar=&psi->pVar[i4];
|
---|
629 |
|
---|
630 | //ローカル変数名
|
---|
631 | lstrcpy(pVar->name,buffer+i2);
|
---|
632 | i2+=lstrlen(buffer+i2)+1;
|
---|
633 |
|
---|
634 | //型
|
---|
635 | pVar->type=*(long *)(buffer+i2);
|
---|
636 | i2+=sizeof(long);
|
---|
637 |
|
---|
638 | //型の拡張情報
|
---|
639 | GetLpIndex_DebugFile(buffer,&i2,pVar->type,&pVar->u.index);
|
---|
640 |
|
---|
641 | //参照型パラメータかどうか
|
---|
642 | pVar->fRef=(long)buffer[i2++];
|
---|
643 |
|
---|
644 | //配列かどうか
|
---|
645 | pVar->bArray=(long)buffer[i2++];
|
---|
646 | if(pVar->bArray){
|
---|
647 | for(i5=0;;i5++){
|
---|
648 | //配列要素
|
---|
649 | pVar->SubScripts[i5]=*(long *)(buffer+i2);
|
---|
650 | i2+=sizeof(long);
|
---|
651 |
|
---|
652 | if(pVar->SubScripts[i5]==-1) break;
|
---|
653 | }
|
---|
654 | }
|
---|
655 |
|
---|
656 | //レキシカルスコープ情報
|
---|
657 | pVar->ScopeStartAddress=*(long *)(buffer+i2);
|
---|
658 | i2+=sizeof(long);
|
---|
659 | pVar->ScopeEndAddress=*(long *)(buffer+i2);
|
---|
660 | i2+=sizeof(long);
|
---|
661 | pVar->ScopeLevel=*(long *)(buffer+i2);
|
---|
662 | i2+=sizeof(long);
|
---|
663 |
|
---|
664 | //メモリ上の位置
|
---|
665 | pVar->offset=*(long *)(buffer+i2);
|
---|
666 | i2+=sizeof(long);
|
---|
667 | }
|
---|
668 |
|
---|
669 |
|
---|
670 | /////////////////////////////////
|
---|
671 | // 格納位置を計算してpsiをセット
|
---|
672 | /////////////////////////////////
|
---|
673 |
|
---|
674 | i4=hash_default(psi->name);
|
---|
675 |
|
---|
676 | SUBINFO *psi2;
|
---|
677 | if(ppSubHash[i4]){
|
---|
678 | psi2=ppSubHash[i4];
|
---|
679 | while(1){
|
---|
680 | if(psi2->pNextData==0){
|
---|
681 | psi2->pNextData=psi;
|
---|
682 | break;
|
---|
683 | }
|
---|
684 | psi2=psi2->pNextData;
|
---|
685 | }
|
---|
686 | }
|
---|
687 | else{
|
---|
688 | ppSubHash[i4]=psi;
|
---|
689 | }
|
---|
690 | }
|
---|
691 |
|
---|
692 | //クラス情報
|
---|
693 | CClass *pobj_c;
|
---|
694 | for(i3=0;i3<iMaxClassCount;i3++){
|
---|
695 | //クラス名
|
---|
696 | char szClassName[VN_SIZE];
|
---|
697 | lstrcpy(szClassName,buffer+i2);
|
---|
698 | i2+=lstrlen(buffer+i2)+1;
|
---|
699 |
|
---|
700 | pobj_c=pobj_DBClass->check(szClassName);
|
---|
701 |
|
---|
702 | //仮想関数の数
|
---|
703 | pobj_c->vtbl_num=*(long *)(buffer+i2);
|
---|
704 | i2+=sizeof(long);
|
---|
705 |
|
---|
706 | //アラインメント
|
---|
707 | pobj_c->iAlign=*(long *)(buffer+i2);
|
---|
708 | i2+=sizeof(long);
|
---|
709 |
|
---|
710 | //メンバ
|
---|
711 | pobj_c->iMemberNum=*(long *)(buffer+i2);
|
---|
712 | i2+=sizeof(long);
|
---|
713 | pobj_c->ppobj_Member=
|
---|
714 | (CMember **)HeapAlloc(hHeap,0,pobj_c->iMemberNum*sizeof(CMember *));
|
---|
715 | for(i4=0;i4<pobj_c->iMemberNum;i4++){
|
---|
716 | pobj_c->ppobj_Member[i4]=new CMember();
|
---|
717 |
|
---|
718 | pobj_c->ppobj_Member[i4]->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
|
---|
719 | lstrcpy(pobj_c->ppobj_Member[i4]->name,buffer+i2);
|
---|
720 | i2+=lstrlen(buffer+i2)+1;
|
---|
721 |
|
---|
722 | memcpy(pobj_c->ppobj_Member[i4]->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
|
---|
723 | i2+=sizeof(int)*MAX_ARRAYDIM;
|
---|
724 |
|
---|
725 | //型
|
---|
726 | pobj_c->ppobj_Member[i4]->TypeInfo.type=*(long *)(buffer+i2);
|
---|
727 | i2+=sizeof(long);
|
---|
728 |
|
---|
729 | //型の拡張情報
|
---|
730 | GetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_Member[i4]->TypeInfo.type,&pobj_c->ppobj_Member[i4]->TypeInfo.u.lpIndex);
|
---|
731 |
|
---|
732 | pobj_c->ppobj_Member[i4]->dwAccess=*(long *)(buffer+i2);
|
---|
733 | i2+=sizeof(long);
|
---|
734 | }
|
---|
735 |
|
---|
736 | //メソッド
|
---|
737 | pobj_c->iMethodNum=*(long *)(buffer+i2);
|
---|
738 | i2+=sizeof(long);
|
---|
739 | pobj_c->ppobj_Method=
|
---|
740 | (CMethod **)HeapAlloc(hHeap,0,pobj_c->iMethodNum*sizeof(CMethod *));
|
---|
741 | for(i4=0;i4<pobj_c->iMethodNum;i4++){
|
---|
742 | pobj_c->ppobj_Method[i4]=new CMethod();
|
---|
743 |
|
---|
744 | pobj_c->ppobj_Method[i4]->dwAccess=*(long *)(buffer+i2);
|
---|
745 | i2+=sizeof(long);
|
---|
746 |
|
---|
747 | char szInherits[VN_SIZE];
|
---|
748 | lstrcpy(szInherits,buffer+i2);
|
---|
749 | i2+=lstrlen(buffer+i2)+1;
|
---|
750 |
|
---|
751 | if(szInherits[0])
|
---|
752 | pobj_c->ppobj_Method[i4]->pobj_InheritsClass=pobj_DBClass->check(szInherits);
|
---|
753 | else pobj_c->ppobj_Method[i4]->pobj_InheritsClass=0;
|
---|
754 |
|
---|
755 | lstrcpy(temp2,buffer+i2);
|
---|
756 | i2+=lstrlen(buffer+i2)+1;
|
---|
757 |
|
---|
758 | CClass *pobj_temp_c;
|
---|
759 | pobj_temp_c=pobj_c->ppobj_Method[i4]->pobj_InheritsClass;
|
---|
760 | if(pobj_temp_c==0) pobj_temp_c=pobj_c;
|
---|
761 | i5=hash_default(temp2);
|
---|
762 | psi=ppSubHash[i5];
|
---|
763 | while(1){
|
---|
764 | if(lstrcmp(psi->name,temp2)==0&&psi->pobj_ParentClass==pobj_temp_c) break;
|
---|
765 | psi=psi->pNextData;
|
---|
766 | }
|
---|
767 | pobj_c->ppobj_Method[i4]->psi=psi;
|
---|
768 | }
|
---|
769 |
|
---|
770 | //静的メンバ
|
---|
771 | pobj_c->iStaticMemberNum=*(long *)(buffer+i2);
|
---|
772 | i2+=sizeof(long);
|
---|
773 | pobj_c->ppobj_StaticMember=
|
---|
774 | (CMember **)HeapAlloc(hHeap,0,pobj_c->iStaticMemberNum*sizeof(CMember *));
|
---|
775 | for(i4=0;i4<pobj_c->iStaticMemberNum;i4++){
|
---|
776 | pobj_c->ppobj_StaticMember[i4]=new CMember();
|
---|
777 |
|
---|
778 | pobj_c->ppobj_StaticMember[i4]->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1);
|
---|
779 | lstrcpy(pobj_c->ppobj_StaticMember[i4]->name,buffer+i2);
|
---|
780 | i2+=lstrlen(buffer+i2)+1;
|
---|
781 |
|
---|
782 | memcpy(pobj_c->ppobj_StaticMember[i4]->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);
|
---|
783 | i2+=sizeof(int)*MAX_ARRAYDIM;
|
---|
784 |
|
---|
785 | //型
|
---|
786 | pobj_c->ppobj_StaticMember[i4]->TypeInfo.type=*(long *)(buffer+i2);
|
---|
787 | i2+=sizeof(long);
|
---|
788 |
|
---|
789 | //型の拡張情報
|
---|
790 | GetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_StaticMember[i4]->TypeInfo.type,&pobj_c->ppobj_StaticMember[i4]->TypeInfo.u.lpIndex);
|
---|
791 |
|
---|
792 | pobj_c->ppobj_StaticMember[i4]->dwAccess=*(long *)(buffer+i2);
|
---|
793 | i2+=sizeof(long);
|
---|
794 | }
|
---|
795 | }
|
---|
796 |
|
---|
797 | HeapDefaultFree(buffer);
|
---|
798 | buffer=0;
|
---|
799 |
|
---|
800 |
|
---|
801 |
|
---|
802 |
|
---|
803 | extern SUBINFO **ppSubHash;
|
---|
804 | ppSubHash=this->ppSubHash;
|
---|
805 | pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc");
|
---|
806 |
|
---|
807 |
|
---|
808 | SingleStepCodeBuffer=MakeSingleStepCode();
|
---|
809 |
|
---|
810 |
|
---|
811 | /////////////////////////////
|
---|
812 | // ブレークポイントを適用
|
---|
813 | /////////////////////////////
|
---|
814 |
|
---|
815 | //インクルード情報
|
---|
816 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
817 | IncludeFileInfo=this->IncludeFileInfo;
|
---|
818 |
|
---|
819 | //コードと行番号の関係
|
---|
820 | extern int MaxLineInfoNum;
|
---|
821 | extern LINEINFO *pLineInfo;
|
---|
822 | MaxLineInfoNum=this->MaxLineInfoNum;
|
---|
823 | pLineInfo=this->pLineInfo;
|
---|
824 |
|
---|
825 | BreakStepCodeBuffer=pobj_DBBreakPoint->update(OpBuffer,SizeOf_CodeSection);
|
---|
826 |
|
---|
827 | //プロセスメモリにコピー
|
---|
828 | extern HANDLE hDebugProcess;
|
---|
829 | SIZE_T stAccBytes;
|
---|
830 | WriteProcessMemory(hDebugProcess,(void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection),
|
---|
831 | BreakStepCodeBuffer,
|
---|
832 | SizeOf_CodeSection,&stAccBytes);
|
---|
833 |
|
---|
834 |
|
---|
835 | return 1;
|
---|
836 | }
|
---|
837 |
|
---|
838 | BOOL CDebugSection::load(HMODULE hModule){
|
---|
839 | if(buffer){
|
---|
840 | HeapDefaultFree(buffer);
|
---|
841 | buffer=0;
|
---|
842 | }
|
---|
843 |
|
---|
844 |
|
---|
845 | extern HANDLE hDebugProcess;
|
---|
846 | SIZE_T stAccBytes;
|
---|
847 | IMAGE_DOS_HEADER ImageDosHeader;
|
---|
848 | ReadProcessMemory(hDebugProcess,hModule,&ImageDosHeader,sizeof(IMAGE_DOS_HEADER),&stAccBytes);
|
---|
849 |
|
---|
850 | int pe_size;
|
---|
851 | #ifdef _AMD64_
|
---|
852 | IMAGE_NT_HEADERS64 pe_hdr;
|
---|
853 | pe_size=sizeof(IMAGE_NT_HEADERS64);
|
---|
854 | #else
|
---|
855 | IMAGE_NT_HEADERS pe_hdr;
|
---|
856 | pe_size=sizeof(IMAGE_NT_HEADERS);
|
---|
857 | #endif
|
---|
858 | ReadProcessMemory(hDebugProcess,(void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew),&pe_hdr,pe_size,&stAccBytes);
|
---|
859 |
|
---|
860 | IMAGE_SECTION_HEADER *pSectionHdr;
|
---|
861 | pSectionHdr=(IMAGE_SECTION_HEADER *)HeapAlloc(hHeap,0,pe_hdr.FileHeader.NumberOfSections*sizeof(IMAGE_SECTION_HEADER));
|
---|
862 | ReadProcessMemory(hDebugProcess,
|
---|
863 | (void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew+pe_size),
|
---|
864 | pSectionHdr,
|
---|
865 | pe_hdr.FileHeader.NumberOfSections*sizeof(IMAGE_SECTION_HEADER),
|
---|
866 | &stAccBytes);
|
---|
867 |
|
---|
868 | int i;
|
---|
869 | for(i=0;i<pe_hdr.FileHeader.NumberOfSections;i++){
|
---|
870 |
|
---|
871 | //リライタブルセクション内の情報
|
---|
872 | if(lstrcmp((char *)pSectionHdr[i].Name,".data")==0){
|
---|
873 | dwRVA_RWSection=pSectionHdr[i].VirtualAddress;
|
---|
874 | }
|
---|
875 |
|
---|
876 | //コードセクション内の情報
|
---|
877 | if(lstrcmp((char *)pSectionHdr[i].Name,".text")==0){
|
---|
878 | dwRVA_CodeSection=pSectionHdr[i].VirtualAddress;
|
---|
879 | SizeOf_CodeSection=pSectionHdr[i].SizeOfRawData;
|
---|
880 | }
|
---|
881 |
|
---|
882 | //デバッグセクション内の情報
|
---|
883 | if(lstrcmp((char *)pSectionHdr[i].Name,".debug")==0){
|
---|
884 | length=pSectionHdr[i].Misc.VirtualSize;
|
---|
885 | buffer=(char *)HeapAlloc(hHeap,0,length+1);
|
---|
886 |
|
---|
887 | ReadProcessMemory(hDebugProcess,
|
---|
888 | (void *)(((ULONG_PTR)hModule)+pSectionHdr[i].VirtualAddress),
|
---|
889 | buffer,
|
---|
890 | length,
|
---|
891 | &stAccBytes);
|
---|
892 | buffer[length]=0;
|
---|
893 | }
|
---|
894 |
|
---|
895 | }
|
---|
896 | HeapDefaultFree(pSectionHdr);
|
---|
897 |
|
---|
898 | if(!buffer) return 0;
|
---|
899 |
|
---|
900 |
|
---|
901 | dwImageBase=(DWORD)(ULONG_PTR)hModule;
|
---|
902 |
|
---|
903 |
|
---|
904 |
|
---|
905 | if(OpBuffer) HeapDefaultFree(OpBuffer);
|
---|
906 | OpBuffer=(char *)HeapAlloc(hHeap,0,SizeOf_CodeSection);
|
---|
907 |
|
---|
908 | ReadProcessMemory(hDebugProcess,
|
---|
909 | (void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection),OpBuffer,
|
---|
910 | SizeOf_CodeSection,&stAccBytes);
|
---|
911 |
|
---|
912 |
|
---|
913 | return __load();
|
---|
914 | }
|
---|
915 |
|
---|
916 | void CDebugSection::choice(void){
|
---|
917 | //イメージベース
|
---|
918 | extern DWORD ImageBase;
|
---|
919 | ImageBase=this->dwImageBase;
|
---|
920 |
|
---|
921 | //リライタブルセクションのRVA
|
---|
922 | extern int MemPos_RWSection;
|
---|
923 | MemPos_RWSection=this->dwRVA_RWSection;
|
---|
924 |
|
---|
925 | //コードセクションのRVAとサイズ
|
---|
926 | extern int MemPos_CodeSection;
|
---|
927 | extern int FileSize_CodeSection;
|
---|
928 | MemPos_CodeSection=this->dwRVA_CodeSection;
|
---|
929 | FileSize_CodeSection=this->SizeOf_CodeSection;
|
---|
930 |
|
---|
931 | //インクルード情報
|
---|
932 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
933 | IncludeFileInfo=this->IncludeFileInfo;
|
---|
934 |
|
---|
935 | //ソースコード
|
---|
936 | extern char *pBaseBuffer;
|
---|
937 | extern char *basbuf;
|
---|
938 | pBaseBuffer=this->pBaseBuffer;
|
---|
939 | basbuf=this->basbuf;
|
---|
940 |
|
---|
941 | //コードと行番号の関係
|
---|
942 | extern int MaxLineInfoNum;
|
---|
943 | extern LINEINFO *pLineInfo;
|
---|
944 | MaxLineInfoNum=this->MaxLineInfoNum;
|
---|
945 | pLineInfo=this->pLineInfo;
|
---|
946 |
|
---|
947 | // クラス情報
|
---|
948 | extern CDBClass *pobj_DBClass;
|
---|
949 | pobj_DBClass=this->pobj_DBClass;
|
---|
950 |
|
---|
951 | // TypeDef情報
|
---|
952 | extern CDBTypeDef *pobj_DBTypeDef;
|
---|
953 | pobj_DBTypeDef=this->pobj_DBTypeDef;
|
---|
954 |
|
---|
955 | //定数を取得
|
---|
956 | extern CONSTINFO **ppConstHash;
|
---|
957 | ppConstHash=this->ppConstHash;
|
---|
958 |
|
---|
959 | //グローバル変数に関する情報
|
---|
960 | extern VARIABLE *GlobalVar;
|
---|
961 | extern int MaxGlobalVarNum;
|
---|
962 | GlobalVar=this->GlobalVar;
|
---|
963 | MaxGlobalVarNum=this->MaxGlobalVarNum;
|
---|
964 |
|
---|
965 | //グローバル実行領域のサイズ
|
---|
966 | extern int GlobalOpBufferSize;
|
---|
967 | GlobalOpBufferSize=this->GlobalOpBufferSize;
|
---|
968 |
|
---|
969 | //プロシージャ
|
---|
970 | extern char **ppMacroNames;
|
---|
971 | ppMacroNames=0;
|
---|
972 | extern SUBINFO **ppSubHash;
|
---|
973 | extern int SubNum;
|
---|
974 | ppSubHash=this->ppSubHash;
|
---|
975 | SubNum=this->SubNum;
|
---|
976 |
|
---|
977 | extern SUBINFO *pSub_DebugSys_EndProc;
|
---|
978 | pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc;
|
---|
979 |
|
---|
980 | //ネイティブコードバッファ
|
---|
981 | extern char *OpBuffer;
|
---|
982 | OpBuffer=this->OpBuffer;
|
---|
983 | }
|
---|
984 |
|
---|
985 | void CDebugSection::DeleteDebugInfo(void){
|
---|
986 | int i2;
|
---|
987 |
|
---|
988 | //インクルード情報を解放
|
---|
989 | for(i2=0;i2<IncludeFileInfo.FilesNum;i2++)
|
---|
990 | HeapDefaultFree(IncludeFileInfo.ppFileNames[i2]);
|
---|
991 | HeapDefaultFree(IncludeFileInfo.ppFileNames);
|
---|
992 |
|
---|
993 | //グローバル変数に関する情報を解放
|
---|
994 | HeapDefaultFree(GlobalVar);
|
---|
995 |
|
---|
996 | //ローカル変数に関する情報を解放
|
---|
997 | SUBINFO *psi;
|
---|
998 | for(i2=0;i2<MAX_HASH;i2++){
|
---|
999 | psi=ppSubHash[i2];
|
---|
1000 | while(psi){
|
---|
1001 | if(psi->bCompile)
|
---|
1002 | HeapDefaultFree(psi->pVar);
|
---|
1003 |
|
---|
1004 | psi=psi->pNextData;
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | //クラスに関するメモリを解放
|
---|
1009 | delete pobj_DBClass;
|
---|
1010 | pobj_DBClass=0;
|
---|
1011 |
|
---|
1012 | //サブルーチン情報のメモリ解放
|
---|
1013 | DeleteSubInfo(ppSubHash,0,0);
|
---|
1014 |
|
---|
1015 | //定数に関する情報を解放
|
---|
1016 | DeleteConstInfo(ppConstHash);
|
---|
1017 |
|
---|
1018 | //ソースコードを解放
|
---|
1019 | HeapDefaultFree(pBaseBuffer);
|
---|
1020 |
|
---|
1021 | //コードと行番号の関係を解放
|
---|
1022 | HeapDefaultFree(pLineInfo);
|
---|
1023 |
|
---|
1024 | //コードバッファを解放
|
---|
1025 | HeapDefaultFree(OpBuffer);
|
---|
1026 | OpBuffer=0;
|
---|
1027 |
|
---|
1028 | HeapDefaultFree(SingleStepCodeBuffer);
|
---|
1029 | SingleStepCodeBuffer=0;
|
---|
1030 |
|
---|
1031 | HeapDefaultFree(BreakStepCodeBuffer);
|
---|
1032 | BreakStepCodeBuffer=0;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | CDBDebugSection::CDBDebugSection(){
|
---|
1038 | ppobj_ds=(CDebugSection **)HeapAlloc(hHeap,0,1);
|
---|
1039 | num=0;
|
---|
1040 | }
|
---|
1041 | CDBDebugSection::~CDBDebugSection(){
|
---|
1042 | int i;
|
---|
1043 | for(i=0;i<num;i++){
|
---|
1044 | delete ppobj_ds[i];
|
---|
1045 | }
|
---|
1046 | HeapDefaultFree(ppobj_ds);
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | BOOL CDBDebugSection::add(HMODULE hModule){
|
---|
1050 | CDebugSection *pobj_d;
|
---|
1051 | pobj_d=new CDebugSection();
|
---|
1052 | if(!pobj_d->load(hModule)){
|
---|
1053 | //デバッグ情報が存在しないとき
|
---|
1054 | delete pobj_d;
|
---|
1055 | return 0;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | ppobj_ds=(CDebugSection **)HeapReAlloc(hHeap,0,ppobj_ds,(num+1)*sizeof(CDebugSection *));
|
---|
1059 | ppobj_ds[num]=pobj_d;
|
---|
1060 | num++;
|
---|
1061 |
|
---|
1062 | return 1;
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | void CDBDebugSection::del(HMODULE hModule){
|
---|
1066 | int i;
|
---|
1067 | for(i=0;i<num;i++){
|
---|
1068 | if((HMODULE)(ULONG_PTR)ppobj_ds[i]->dwImageBase==hModule){
|
---|
1069 | delete ppobj_ds[i];
|
---|
1070 |
|
---|
1071 | num--;
|
---|
1072 | for(;i<num;i++){
|
---|
1073 | ppobj_ds[i]=ppobj_ds[i+1];
|
---|
1074 | }
|
---|
1075 | break;
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | void CDBDebugSection::choice(int index){
|
---|
1081 | pobj_now=ppobj_ds[index];
|
---|
1082 | pobj_now->choice();
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | CDBDebugSection *pobj_DBDebugSection;
|
---|