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