source: dev/BasicCompiler64/varlist.cpp@ 58

Last change on this file since 58 was 55, checked in by dai_9181, 18 years ago

・コマンドラインオプション "/unicode" に対応。
・Unicode文字セットを使用する場合に "UNICODE" が自動的に#defineされるようにしました。
・SByte型(8ビット符号付き整数型)を追加。
・Char型を文字型に変更。
・プロジェクトオプションから「Unicode文字セットを使用する」チェックを選択できるようにしました。

File size: 38.3 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2
3//デバッグ用
4#include "../BasicCompiler_Common/debug.h"
5
6//変数リストのツリーハンドル
7HWND hVarTree_Global,hVarTree_Local,hVarTree_This;
8
9int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,int type,int *SubScripts,LONG_PTR lpIndex);
10void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,CClass *pobj_c,BOOL bPtr);
11void VarList_Insert(HWND hVarTree,TV_INSERTSTRUCT *lptv,char *VarName,int type,LONG_PTR offset,LONG_PTR lpIndex){
12 extern HANDLE hDebugProcess;
13 int i2;
14 char temporary[255],temp2[255];
15 LONG_PTR pData;
16 SIZE_T stAccBytes;
17 double dbl;
18 float flt;
19 WORD wData;
20 BYTE byteData;
21 HTREEITEM hParent;
22 _int64 i64data;
23
24 if(type==DEF_OBJECT){
25 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_OBJECT,(DWORD64)offset);
26 lptv->item.iImage=1;
27 lptv->item.iSelectedImage=1;
28 hParent=TreeView_InsertItem(hVarTree,lptv);
29
30 VarList_Member(hVarTree,hParent,offset,(CClass *)lpIndex,0);
31 return;
32 }
33 if(type==DEF_PTR_OBJECT){
34 i2=ReadProcessMemory(hDebugProcess,(void *)offset,&pData,sizeof(void *),&stAccBytes);
35
36 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_POINTEROFOBJECT,(DWORD64)pData);
37 lptv->item.iImage=4;
38 lptv->item.iSelectedImage=4;
39 hParent=TreeView_InsertItem(hVarTree,lptv);
40
41 if(i2) VarList_Member(hVarTree,hParent,pData,(CClass *)lpIndex,1);
42 return;
43 }
44 else{
45 if(type==DEF_PTR_BYTE){
46 if(ReadProcessMemory(hDebugProcess,(void *)offset,&pData,sizeof(void *),&stAccBytes)){
47 for(i2=0;;i2++){
48 if(!ReadProcessMemory(hDebugProcess,(void *)(pData+i2),&temporary[i2],1,&stAccBytes)){
49 i2=-1;
50 break;
51 }
52 if(temporary[i2]=='\0') break;
53 if(i2==64){
54 lstrcpy(temporary+i2,"...");
55 break;
56 }
57 }
58 if(i2==-1) sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,(DWORD64)pData,(DWORD64)pData);
59 else sprintf(lptv->item.pszText,"%s %d(&H%X) \"%s\"",VarName,(DWORD64)pData,(DWORD64)pData,temporary);
60 }
61 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
62 }
63 else if(type==DEF_DOUBLE){
64 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dbl,sizeof(double),&stAccBytes)){
65 sprintf(lptv->item.pszText,"%s %.15g",VarName,dbl);
66 }
67 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
68 }
69 else if(type==DEF_SINGLE){
70 if(ReadProcessMemory(hDebugProcess,(void *)offset,&flt,sizeof(float),&stAccBytes)){
71 sprintf(lptv->item.pszText,"%s %.6g",VarName,flt);
72 }
73 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
74 }
75 else if(type==DEF_INT64){
76 _int64 i64data;
77 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&stAccBytes)){
78 _i64toa(i64data,temporary,10);
79 _i64toa(i64data,temp2,16);
80 CharUpper(temp2);
81 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
82 }
83 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
84 }
85 else if(type==DEF_QWORD||IsPtrType(type)){
86 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&stAccBytes)){
87 _ui64toa(i64data,temporary,10);
88 _ui64toa(i64data,temp2,16);
89 CharUpper(temp2);
90 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
91 }
92 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
93 }
94 else if(type==DEF_LONG){
95 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&stAccBytes)){
96 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,i64data,i64data);
97 }
98 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
99 }
100 else if(type==DEF_DWORD){
101 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&stAccBytes)){
102 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,i64data,i64data);
103 }
104 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
105 }
106 else if(type==DEF_INTEGER || (isUnicode&&type==DEF_CHAR)){
107 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&stAccBytes)){
108 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,(short)wData,(short)wData);
109 }
110 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
111 }
112 else if(type==DEF_WORD){
113 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&stAccBytes)){
114 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,wData,wData);
115 }
116 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
117 }
118 else if(type==DEF_SBYTE || (isUnicode==false&&type==DEF_CHAR)){
119 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&stAccBytes)){
120 temporary[0]=byteData;
121 temporary[1]=0;
122 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,(char)byteData,byteData,temporary);
123 }
124 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
125 }
126 else if(type==DEF_BYTE){
127 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&stAccBytes)){
128 temporary[0]=byteData;
129 temporary[1]=0;
130 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,byteData,byteData,temporary);
131 }
132 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
133 }
134 else if(type==DEF_BOOLEAN){
135 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&stAccBytes)){
136 if( byteData ) lstrcpy( temporary, "True" );
137 else lstrcpy( temporary, "False" );
138
139 wsprintf(lptv->item.pszText,"%s %s",VarName,temporary);
140 }
141 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
142 }
143 lptv->item.iImage=2;
144 lptv->item.iSelectedImage=2;
145 }
146 TreeView_InsertItem(hVarTree,lptv);
147}
148void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,CClass *pobj_c,BOOL bPtr){
149 int i,i2;
150 char VarData[VN_SIZE],VarName[VN_SIZE];
151 TV_INSERTSTRUCT tv;
152
153 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
154 tv.hInsertAfter=TVI_LAST;
155 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
156 tv.hParent=hParent;
157 tv.item.pszText=VarData;
158
159 for(i=0;i<pobj_c->iMemberNum;i++){
160 if(bPtr){
161 lstrcpy(VarName,"->");
162 lstrcat(VarName,pobj_c->ppobj_Member[i]->name);
163 }
164 else{
165 lstrcpy(VarName,".");
166 lstrcat(VarName,pobj_c->ppobj_Member[i]->name);
167 }
168
169 LONG_PTR offset;
170 offset=GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i]->name,&i2);
171
172 if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){
173 //構造体内の配列
174 sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset);
175 tv.item.iImage=0;
176 tv.item.iSelectedImage=0;
177 hParent=TreeView_InsertItem(hVarTree,&tv);
178
179 i2=VarList_Array(hVarTree,hParent,
180 pTopOffset+offset,
181 pobj_c->ppobj_Member[i]->TypeInfo.type,
182 pobj_c->ppobj_Member[i]->SubScripts,
183 pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex);
184 }
185 else{
186 //メンバ変数
187 VarList_Insert(hVarTree,
188 &tv,
189 VarName,
190 pobj_c->ppobj_Member[i]->TypeInfo.type,
191 pTopOffset+offset,
192 pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex);
193 }
194 }
195}
196int VarList_Array(HWND hVarTree,HTREEITEM hParent,LONG_PTR offset,int type,int *SubScripts,LONG_PTR lpIndex){
197 int i,i2,i3,ElementNum,MemCounter,UseCount[255],TypeSize;
198 char temporary[VN_SIZE],temp2[DIGIT_SIZE];
199
200 TV_INSERTSTRUCT tv;
201 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
202 tv.hInsertAfter=TVI_LAST;
203 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
204 tv.hParent=hParent;
205 tv.item.pszText=temporary;
206
207 TypeSize=GetTypeSize(type,lpIndex);
208
209 for(i=0;i<255;i++){
210 if(SubScripts[i]==-1) break;
211 UseCount[i]=0;
212 }
213 UseCount[i]=-2;
214 MemCounter=0;
215 while(1){
216 UseCount[i]++;
217 for(ElementNum=0;SubScripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){
218 UseCount[i-ElementNum]=0;
219 if(i-ElementNum-1<0) return MemCounter;
220 UseCount[i-ElementNum-1]++;
221 }
222
223 if(MemCounter<50){
224 temporary[0]='[';
225 temporary[1]=0;
226 for(i2=0;i2<i;i2++){
227 sprintf(temp2,"%d",UseCount[i2]);
228 lstrcat(temporary,temp2);
229 lstrcat(temporary,",");
230 }
231 i3=lstrlen(temporary);
232 temporary[i3-1]=']';
233 temporary[i3]=0;
234
235 VarList_Insert(hVarTree,&tv,temporary,type,
236 offset+MemCounter*TypeSize,
237 lpIndex);
238 }
239
240 MemCounter++;
241 if(MemCounter==50){
242 lstrcpy(tv.item.pszText,"...");
243 TreeView_InsertItem(hVarTree,&tv);
244 }
245 }
246 return 0;
247}
248void RefreshGlobalVar(void){
249 extern DWORD ImageBase;
250 int i;
251 char temporary[VN_SIZE];
252 TV_INSERTSTRUCT tv;
253 HTREEITEM hParent;
254
255 TreeView_DeleteAllItems(hVarTree_Global);
256
257 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
258 tv.hInsertAfter=TVI_LAST;
259 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
260 tv.hParent=TVI_ROOT;
261 tv.item.pszText=temporary;
262
263 extern HANDLE hDebugProcess;
264 extern int MemPos_RWSection;
265 extern int MaxGlobalVarNum;
266 extern VARIABLE *GlobalVar;
267
268 for(i=0;i<MaxGlobalVarNum;i++){
269 VARIABLE *pVar=&GlobalVar[i];
270
271 //スコープ外の場合は無視
272 if(pVar->ScopeLevel!=0){
273 if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[0] &&
274 pobj_dti->lplpObp[0] < rva_to_real(pVar->ScopeEndAddress)){
275 //範囲内
276 }
277 else{
278 //範囲外
279 continue;
280 }
281 }
282
283
284 if(!pobj_nv->bShow_DefaultSystem_Var){
285 if(memcmp(pVar->name,"_System_",8)==0||
286 memcmp(pVar->name,"_DebugSys_",10)==0||
287 memcmp(pVar->name,"_PromptSys_",11)==0) continue;
288 }
289 if(!pobj_nv->bShow_Rad_Var){
290 if(memcmp(pVar->name,"_RadSys_",8)==0) continue;
291 }
292 if(!pobj_nv->bShow_GUID_Var){
293 if(memcmp(pVar->name,"GUID_",5)==0||
294 memcmp(pVar->name,"IID_",4)==0||
295 memcmp(pVar->name,"CLSID_",6)==0) continue;
296 }
297
298 //静的メンバ
299 if(strstr(pVar->name,".")) continue;
300
301 if(pVar->bArray){
302 sprintf(temporary,"%s %s(&H%X)",
303 pVar->name,
304 STRING_ARRAY,
305 ImageBase+MemPos_RWSection+pVar->offset);
306 tv.item.iImage=0;
307 tv.item.iSelectedImage=0;
308 hParent=TreeView_InsertItem(hVarTree_Global,&tv);
309
310 VarList_Array(hVarTree_Global,hParent,
311 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->offset),
312 pVar->type,
313 pVar->SubScripts,
314 pVar->u.index);
315 }
316 else{
317 VarList_Insert(hVarTree_Global,
318 &tv,
319 pVar->name,
320 pVar->type,
321 (LONG_PTR)(ImageBase+MemPos_RWSection+pVar->offset),
322 pVar->u.index);
323 }
324 }
325}
326void RefreshLocalVar(void){
327 int i,i2,i3,sw;
328 char temporary[VN_SIZE];
329 TV_INSERTSTRUCT tv;
330 HTREEITEM hParent;
331 LONG_PTR offset;
332 SIZE_T stAccBytes;
333 LONG_PTR lpData;
334
335 TreeView_DeleteAllItems(hVarTree_Local);
336
337 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
338 tv.hInsertAfter=TVI_LAST;
339 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
340 tv.hParent=TVI_ROOT;
341 tv.item.pszText=temporary;
342
343 extern HANDLE hDebugProcess;
344 extern HWND hDebugWnd;
345 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
346 i2=pobj_dti->iProcLevel-i2;
347
348 if(pobj_dti->lplpSpBase[i2]==0) return;
349
350 extern SUBINFO **ppSubHash;
351 SUBINFO *psi;
352 for(i3=0,sw=0;i3<MAX_HASH;i3++){
353 psi=ppSubHash[i3];
354 while(psi){
355 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
356 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
357 sw=1;
358 break;
359 }
360
361 psi=psi->pNextData;
362 }
363 if(sw) break;
364 }
365 if(!psi) return;
366
367 for(i=0;i<psi->VarNum;i++){
368 VARIABLE *pVar=&psi->pVar[i];
369
370 //スコープ外の場合は無視
371 if(pVar->ScopeLevel!=0){
372 if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[i2] &&
373 pobj_dti->lplpObp[i2] < rva_to_real(pVar->ScopeEndAddress)){
374 //範囲内
375 }
376 else{
377 //範囲外
378 continue;
379 }
380 }
381
382 if(pVar->bArray){
383 sprintf(temporary,"%s %s(&H%X)",
384 pVar->name,
385 STRING_ARRAY,
386 pobj_dti->lplpSpBase[i2]+pVar->offset);
387 tv.item.iImage=0;
388 tv.item.iSelectedImage=0;
389 hParent=TreeView_InsertItem(hVarTree_Local,&tv);
390
391 VarList_Array(hVarTree_Local,hParent,
392 pobj_dti->lplpSpBase[i2]+pVar->offset,
393 pVar->type,
394 pVar->SubScripts,
395 pVar->u.index);
396 }
397 else{
398 offset=pobj_dti->lplpSpBase[i2]+pVar->offset;
399 if(pVar->fRef){
400 ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(LONG_PTR),&stAccBytes);
401 offset=lpData;
402 }
403 VarList_Insert(hVarTree_Local,&tv,
404 pVar->name,
405 pVar->type,
406 offset,
407 pVar->u.index);
408 }
409 }
410
411
412
413 /////////////////////////////
414 // Thisオブジェクトのリスト
415 /////////////////////////////
416
417 TreeView_DeleteAllItems(hVarTree_This);
418 if(!psi->pobj_ParentClass) return;
419
420 //Thisポインタを取得
421 LONG_PTR pThis;
422 for(i=0;i<psi->VarNum;i++){
423 if(lstrcmp(psi->pVar[i].name,"_System_LocalThis")==0) break;
424 }
425 if(i==psi->VarNum) return;
426 lpData=pobj_dti->lplpSpBase[i2]+psi->pVar[i].offset;
427 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&stAccBytes);
428
429 for(i=0;i<psi->pobj_ParentClass->iMemberNum;i++){
430 offset=GetSizeOfClassMember(psi->pobj_ParentClass,psi->pobj_ParentClass->ppobj_Member[i]->name,&i2);
431
432 if(psi->pobj_ParentClass->ppobj_Member[i]->SubScripts[0]!=-1){
433 //配列
434 sprintf(temporary,"%s %s(&H%X)",
435 psi->pobj_ParentClass->ppobj_Member[i]->name,
436 STRING_ARRAY,
437 (DWORD64)offset);
438 tv.item.iImage=0;
439 tv.item.iSelectedImage=0;
440 hParent=TreeView_InsertItem(hVarTree_This,&tv);
441
442 VarList_Array(hVarTree_This,hParent,
443 pThis+offset,
444 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.type,
445 psi->pobj_ParentClass->ppobj_Member[i]->SubScripts,
446 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.u.lpIndex);
447 }
448 else{
449 VarList_Insert(hVarTree_This,&tv,
450 psi->pobj_ParentClass->ppobj_Member[i]->name,
451 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.type,
452 pThis+offset,
453 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.u.lpIndex);
454 }
455 }
456}
457void RefreshGlobalVar_with_WindowLock(void){
458 extern HWND hDebugWnd;
459
460 //処理時間を短くするため、一時的に非表示にする
461 LockWindowUpdate(hDebugWnd);
462 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
463
464 //リフレッシュ
465 RefreshGlobalVar();
466
467 LockWindowUpdate(NULL);
468 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
469}
470void RefreshLocalVar_with_WindowLock(void){
471 extern HWND hDebugWnd;
472
473 //処理時間を短くするため、一時的に非表示にする
474 LockWindowUpdate(hDebugWnd);
475 ShowWindow(GetParent(hVarTree_Local),SW_HIDE);
476
477 //リフレッシュ
478 RefreshLocalVar();
479
480 LockWindowUpdate(NULL);
481 ShowWindow(GetParent(hVarTree_Local),SW_SHOW);
482}
483
484void SetCalcToWatchList(HWND hListView,int iItem,char *buffer){
485 int i;
486 char temporary[255],temp2[255];
487
488 //エスケープシーケンスをセット
489 SetEscapeSequenceFormat(buffer);
490
491 KillStringSpaces(buffer);
492
493 //カッコを相互チェック
494 if(!CheckParenthesis2(buffer)){
495 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
496 return;
497 }
498
499 double dbl;
500 _int64 i64data;
501 i=StaticCalculation(true, buffer,0,&i64data,0,1);
502 if(IsRealNumberType(i)){
503 memcpy(&dbl,&i64data,sizeof(double));
504 }
505
506 if(i==0){
507 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
508 }
509 else if(i==-1){
510 ListView_SetItemText(hListView,iItem,1,"アクセスできません");
511 }
512 else{
513 if(IsRealNumberType(i))
514 sprintf(temporary,"%.15g (&H%08X)",dbl,(int)dbl);
515 else if(Is64Type(i)){
516 _i64toa(i64data,temporary,10);
517 _i64toa(i64data,temp2,16);
518 CharUpper(temp2);
519 sprintf(temporary+lstrlen(temporary)," (&H%s)",temp2);
520 }
521 else sprintf(temporary,"%d (&H%08X)",(long)i64data,(long)i64data);
522
523 ListView_SetItemText(hListView,iItem,1,temporary);
524 }
525}
526void RefreshWatchList(void){
527 extern HWND hDebugWnd;
528 HWND hListView;
529 int i,i2;
530 char temporary[VN_SIZE];
531
532 hListView=GetDlgItem(hDebugWnd,IDC_WATCHLIST);
533 i2=ListView_GetItemCount(hListView);
534 for(i=0;i<i2-1;i++){
535 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
536
537 //演算結果を表示
538 SetCalcToWatchList(hListView,i,temporary);
539 }
540}
541
542BOOL SetDebugProcCombo(HWND hProcCombo){
543 int i2,i3;
544 char temporary[255];
545
546 extern DWORD ImageBase;
547 extern int MemPos_CodeSection;
548
549 //行番号情報
550 extern int MaxLineInfoNum;
551 extern LINEINFO *pLineInfo;
552 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
553 for(i2=0;i2<MaxLineInfoNum-1;i2++){
554 if((DWORD64)(pLineInfo[i2].TopObp+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
555 pobj_dti->lplpObp[i3]<=(DWORD64)(pLineInfo[i2+1].TopObp+ImageBase+MemPos_CodeSection)) break;
556 }
557 if(i2==MaxLineInfoNum) pobj_dti->lpdwCp[i3]=-1;
558 else pobj_dti->lpdwCp[i3]=pLineInfo[i2].TopCp;
559 }
560 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
561 if(pobj_dti->lpdwCp[i3]==-1){
562 pobj_dti->iProcLevel--;
563 for(i2=i3;i2<(int)pobj_dti->iProcLevel+1;i2++){
564 pobj_dti->lplpObp[i2]=pobj_dti->lplpObp[i2+1];
565 pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
566 pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
567 }
568 i3--;
569 continue;
570 }
571 }
572
573 if(!GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel],&i2,temporary)){
574 extern HWND hMainDlg;
575 //"デバッグ情報の取得に失敗"
576 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
577 return 0;
578 }
579 ShowErrorLine(i2,temporary);
580
581 //プロシージャ コンボボックス
582 extern SUBINFO **ppSubHash;
583 SUBINFO *psi;
584 int sw;
585 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
586 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
587 for(i3=0,sw=0;i3<MAX_HASH;i3++){
588 psi=ppSubHash[i3];
589 while(psi){
590 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
591 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
592 lstrcpy(temporary,psi->name);
593 sw=1;
594 break;
595 }
596 psi=psi->pNextData;
597 }
598 if(sw) break;
599 }
600 if(!psi){
601 if(i2==0){
602 lstrcpy(temporary,"Global");
603 pobj_dti->lplpSpBase[i2]=0;
604 }
605 else lstrcpy(temporary,"error");
606 }
607 SendMessage(hProcCombo,CB_ADDSTRING,0,(LPARAM)temporary);
608 }
609 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
610
611 return pobj_dti->iProcLevel;
612}
613
614//IDC_THREADCOMBOプロシージャ
615LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
616 extern WNDPROC OldThreadComboProc;
617 int i2;
618 DWORD dwThreadID;
619 char temporary[255];
620
621 switch(message){
622 case WM_COMMAND:
623 if(HIWORD(wParam)==CBN_SELCHANGE){
624 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(LPARAM)temporary);
625 sscanf(temporary+2,"%X",&dwThreadID);
626
627 extern DWORD _DebugSys_dwThreadID[256];
628 i2=0;
629 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
630
631 //次回のステップ実行対象を指定
632 extern int NextStepThreadNum;
633 NextStepThreadNum=i2;
634
635 //スレッド情報をリフレッシュ
636 pobj_dti->Reflesh(i2);
637
638 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
639
640 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
641 }
642 break;
643 }
644 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
645}
646//IDC_PROCCOMBOプロシージャ
647LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
648 extern WNDPROC OldProcComboProc;
649 int i2,i3;
650 char temporary[MAX_PATH];
651
652 switch(message){
653 case WM_COMMAND:
654 if(HIWORD(wParam)==CBN_SELCHANGE){
655 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0);
656 GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2],&i3,temporary);
657 ShowErrorLine(i3,temporary);
658
659 RefreshLocalVar_with_WindowLock();
660 }
661 break;
662 }
663 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
664}
665void InitVarList(DWORD dwThreadId){
666 extern HWND hDebugWnd;
667 int i2,i3,i5;
668 char temporary[255];
669
670
671 //スレッド
672 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
673 extern DWORD _DebugSys_dwThreadID[256];
674 for(i2=0;i2<256;i2++){
675 if(_DebugSys_dwThreadID[i2]){
676 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
677 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
678 if(_DebugSys_dwThreadID[i2]==dwThreadId){
679 extern int NextStepThreadNum;
680 NextStepThreadNum=i2;
681 }
682 }
683 }
684 sprintf(temporary,"&H%08X",dwThreadId);
685 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
686 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
687
688 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
689
690
691 ///////////////////////////////////////////////
692 // 実行中のプロシージャのローカル変数をセット
693 ///////////////////////////////////////////////
694
695 extern VARIABLE *LocalVar;
696 extern int MaxLocalVarNum;
697 int sw;
698
699 MaxLocalVarNum=0;
700
701 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
702 i2=pobj_dti->iProcLevel-i2;
703
704 if(pobj_dti->lplpSpBase[i2]){
705 extern SUBINFO **ppSubHash;
706 SUBINFO *psi;
707 for(i3=0,sw=0;i3<MAX_HASH;i3++){
708 psi=ppSubHash[i3];
709 while(psi){
710 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
711 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
712 sw=1;
713 break;
714 }
715
716 psi=psi->pNextData;
717 }
718 if(sw) break;
719 }
720
721
722 if(psi){
723 LocalVar=psi->pVar;
724 MaxLocalVarNum=psi->VarNum;
725
726 pobj_CompilingClass=psi->pobj_ParentClass;
727 }
728 }
729
730
731 ////////////////////////
732 // 変数リストを再表示
733 ////////////////////////
734
735 //処理時間を短くするため、一時的に非表示にする
736 LockWindowUpdate(hDebugWnd);
737 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
738 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
739
740 //リフレッシュ
741 RefreshLocalVar();
742 RefreshGlobalVar();
743 RefreshWatchList();
744
745 LockWindowUpdate(NULL);
746 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
747 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
748}
749
750
751
752
753//////////////////////////////////////
754// エディタに埋め込み表示のデバッガ
755//////////////////////////////////////
756
757BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
758 extern HINSTANCE hInst;
759 extern DWORD dwStepRun;
760
761 //デバッガ用ツールバー
762#define BMPNUM_DEBUGGERTOOLBAR 3
763#define BTNNUM_DEBUGGERTOOLBAR 4
764 TBBUTTON DebuggerToolBar[]={
765 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
766 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
767 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
768 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
769 };
770 TOOLTIPTEXT *pTipText;
771
772 static HIMAGELIST hImageList,hImageList_Disabled;
773
774 switch(message){
775 case WM_INITDIALOG:
776 //ツールバーを生成
777 extern HWND hDebuggerToolbar;
778 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
779 NULL,
780 0,0,0,
781 DebuggerToolBar,
782 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
783 0,0,16,15,sizeof(TBBUTTON));
784
785 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
786 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
787 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
788 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
789 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
790 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
791
792 break;
793 case WM_COMMAND:
794 switch(LOWORD(wParam)){
795 case IDC_DEBUG_START:
796 DestroyWindow(GetParent(hwnd));
797 return 1;
798 case IDC_DEBUG_STEPIN:
799 dwStepRun=1;
800 return 1;
801 case IDC_DEBUG_STEPOVER:
802 dwStepRun=2;
803 return 1;
804 }
805 break;
806 case WM_NOTIFY:
807 pTipText=(TOOLTIPTEXT *)lParam;
808 if(pTipText->hdr.code==TTN_NEEDTEXT){
809 //ツールチップを表示
810 switch(pTipText->hdr.idFrom){
811 case IDC_DEBUG_START:
812 pTipText->lpszText="実行";
813 break;
814 case IDC_DEBUG_STEPOVER:
815 pTipText->lpszText="ステップ アウト";
816 break;
817 case IDC_DEBUG_STEPIN:
818 pTipText->lpszText="ステップ イン";
819 break;
820 }
821 }
822 break;
823 case WM_SIZE:
824 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
825 return 1;
826
827 case WM_DESTROY:
828 ImageList_Destroy(hImageList);
829 ImageList_Destroy(hImageList_Disabled);
830 return 1;
831 }
832 return 0;
833}
834
835WNDPROC OldTabProc;
836LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
837 extern HINSTANCE hInst;
838
839 static HMENU hDummyMenu,hMenu=0;
840
841 switch(message){
842 case WM_CONTEXTMENU:
843 if(hMenu==0){
844 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
845 hMenu=GetSubMenu(hDummyMenu,0);
846 }
847
848 MENUITEMINFO mi;
849 mi.cbSize=sizeof(MENUITEMINFO);
850 mi.fMask=MIIM_STATE;
851 mi.fState=MFS_CHECKED;
852
853 if(pobj_nv->bShow_DefaultSystem_Var)
854 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
855 if(pobj_nv->bShow_Rad_Var)
856 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
857 if(pobj_nv->bShow_GUID_Var)
858 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
859
860 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
861
862 break;
863 case WM_COMMAND:
864 mi.cbSize=sizeof(MENUITEMINFO);
865 mi.fMask=MIIM_STATE;
866 switch(LOWORD(wParam)){
867 case IDM_SHOW_DEFAULTSYSTEM_VAR:
868 if(pobj_nv->bShow_DefaultSystem_Var){
869 pobj_nv->bShow_DefaultSystem_Var=0;
870 mi.fState=MFS_UNCHECKED;
871 }
872 else{
873 pobj_nv->bShow_DefaultSystem_Var=1;
874 mi.fState=MFS_CHECKED;
875 }
876 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
877 RefreshGlobalVar_with_WindowLock();
878 break;
879 case IDM_SHOW_RAD_VAR:
880 if(pobj_nv->bShow_Rad_Var){
881 pobj_nv->bShow_Rad_Var=0;
882 mi.fState=MFS_UNCHECKED;
883 }
884 else{
885 pobj_nv->bShow_Rad_Var=1;
886 mi.fState=MFS_CHECKED;
887 }
888 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
889 RefreshGlobalVar_with_WindowLock();
890 break;
891 case IDM_SHOW_GUID_VAR:
892 if(pobj_nv->bShow_GUID_Var){
893 pobj_nv->bShow_GUID_Var=0;
894 mi.fState=MFS_UNCHECKED;
895 }
896 else{
897 pobj_nv->bShow_GUID_Var=1;
898 mi.fState=MFS_CHECKED;
899 }
900 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
901 RefreshGlobalVar_with_WindowLock();
902 break;
903 }
904 break;
905 case WM_DESTROY:
906 DestroyMenu(hMenu);
907 hMenu=0;
908 break;
909 }
910 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
911}
912
913BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
914 extern HANDLE hHeap;
915 extern HINSTANCE hInst;
916 extern DWORD dwStepRun;
917 extern double width_ratio_VarList;
918 RECT rect;
919 int i,i2,i3;
920 char temporary[VN_SIZE];
921 LV_DISPINFO *lvinfo;
922 LVITEM ListView_Item;
923
924 static POINT pos_VarList;
925 static POINT pos_WatchList;
926
927 switch(message){
928 case WM_INITDIALOG:
929 extern HWND hDebugWnd;
930 hDebugWnd=hwnd;
931
932 //変数リストの初期位置を取得
933 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
934 pos_VarList.x=rect.left;
935 pos_VarList.y=rect.top;
936 ScreenToClient(hwnd,&pos_VarList);
937
938 //ウォッチリストの初期位置を取得
939 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
940 pos_WatchList.y=0;
941
942 //ツールバーのベースウィンドウを生成
943 static HWND hBase_ToolBar;
944 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
945 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
946
947 extern WNDPROC OldThreadComboProc;
948 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
949 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
950
951 extern WNDPROC OldProcComboProc;
952 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
953 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
954
955
956 ///////////////////////////
957 // タブコントロールを生成
958 ///////////////////////////
959
960 static HWND hTab;
961 HFONT hFont;
962 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
963 hTab=CreateWindow(WC_TABCONTROL,NULL,
964 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
965 0,0,0,0,hwnd,0,hInst,0);
966 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
967 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
968 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
969
970 //タブを設定
971 TC_ITEM tcItem;
972 tcItem.mask=TCIF_TEXT;
973 tcItem.pszText="グローバル";
974 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
975 tcItem.mask=TCIF_TEXT;
976 tcItem.pszText="ローカル";
977 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
978 tcItem.mask=TCIF_TEXT;
979 tcItem.pszText="This";
980 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
981
982 //グローバル変数リストのツリーを作成
983 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
984 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
985 0,0,0,0,
986 hTab,0,hInst,0);
987
988 //ローカル変数リストのツリーを作成
989 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
990 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
991 0,0,0,0,
992 hTab,0,hInst,0);
993
994 //This変数リストのツリーを作成
995 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
996 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
997 0,0,0,0,
998 hTab,0,hInst,0);
999
1000 ShowWindow(hVarTree_Global,SW_SHOW);
1001
1002
1003 //イメージリスト読み込み、設定
1004 static HIMAGELIST hVariOrderImageList;
1005 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1006 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1007 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1008 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1009 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1010 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1011 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1012 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1013 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1014
1015
1016 /////////////////////////
1017 // ウォッチリスト
1018 /////////////////////////
1019
1020 //コラムの設定
1021 static HWND hListView;
1022 LV_COLUMN ListView_Column;
1023 DWORD dwStyle;
1024
1025 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1026 GetClientRect(hListView,&rect);
1027 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1028 dwStyle|=LVS_EX_FULLROWSELECT;
1029 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1030
1031 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1032 ListView_Column.fmt=LVCFMT_LEFT;
1033
1034 extern int width_WatchColumn_Expression;
1035 ListView_Column.cx=width_WatchColumn_Expression;
1036 ListView_Column.pszText="ウォッチ式";
1037 ListView_Column.iSubItem=0;
1038 ListView_InsertColumn(hListView,0,&ListView_Column);
1039
1040 extern int width_WatchColumn_Value;
1041 ListView_Column.cx=width_WatchColumn_Value;
1042 ListView_Column.pszText="値";
1043 ListView_Column.iSubItem=1;
1044 ListView_InsertColumn(hListView,1,&ListView_Column);
1045
1046 //アイテムの設定
1047 ListView_Item.mask=LVIF_TEXT;
1048 ListView_Item.iSubItem=0;
1049 for(i=0;i<pobj_nv->WatchNum;i++){
1050 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1051 ListView_Item.iItem=i;
1052 ListView_InsertItem(hListView,&ListView_Item);
1053 }
1054 ListView_Item.pszText="...";
1055 ListView_Item.iItem=i;
1056 ListView_InsertItem(hListView,&ListView_Item);
1057
1058
1059 ///////////////////////
1060 // 変数リストの初期化
1061 ///////////////////////
1062 InitVarList((DWORD)lParam);
1063
1064 break;
1065 case WM_NOTIFY:
1066 NMHDR *hdr;
1067 hdr=(NMHDR *)lParam;
1068 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1069 i=TabCtrl_GetCurSel(hTab);
1070
1071 if(i==0){
1072 //グローバル変数を表示
1073 ShowWindow(hVarTree_Global,SW_SHOW);
1074 ShowWindow(hVarTree_Local,SW_HIDE);
1075 ShowWindow(hVarTree_This,SW_HIDE);
1076 }
1077 else if(i==1){
1078 //ローカル変数を表示
1079 ShowWindow(hVarTree_Global,SW_HIDE);
1080 ShowWindow(hVarTree_Local,SW_SHOW);
1081 ShowWindow(hVarTree_This,SW_HIDE);
1082 }
1083 else if(i==2){
1084 //This変数を表示
1085 ShowWindow(hVarTree_Global,SW_HIDE);
1086 ShowWindow(hVarTree_Local,SW_HIDE);
1087 ShowWindow(hVarTree_This,SW_SHOW);
1088 }
1089 }
1090
1091 if(hdr->hwndFrom==hListView){
1092 lvinfo=(LV_DISPINFO *)hdr;
1093 if(hdr->code==NM_DBLCLK){
1094 i2=ListView_GetItemCount(hListView);
1095 for(i=0;i<i2;i++){
1096 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1097 }
1098 if(i==i2) break;
1099
1100 ListView_EditLabel(hListView,i);
1101 }
1102
1103 static HWND hEdit;
1104 if(hdr->code==LVN_BEGINLABELEDIT){
1105 hEdit=ListView_GetEditControl(hListView);
1106
1107 GetWindowText(hEdit,temporary,VN_SIZE);
1108 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1109 }
1110 if(hdr->code==LVN_ENDLABELEDIT){
1111 GetWindowText(hEdit,temporary,VN_SIZE);
1112 if(temporary[0]=='\0'){
1113 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1114
1115 //空白入力の場合はそのアイテムを削除する
1116 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1117 break;
1118 }
1119 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1120
1121 //演算結果を表示
1122 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1123
1124 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1125 //リストアイテムを追加
1126 ListView_Item.mask=LVIF_TEXT;
1127 ListView_Item.pszText="...";
1128 ListView_Item.iItem=lvinfo->item.iItem+1;
1129 ListView_Item.iSubItem=0;
1130 ListView_InsertItem(hListView,&ListView_Item);
1131 }
1132 }
1133
1134 if(hdr->code==LVN_KEYDOWN){
1135 LV_KEYDOWN *plvKeydown;
1136 plvKeydown=(LV_KEYDOWN *)hdr;
1137 if(plvKeydown->wVKey==VK_DELETE){
1138 i2=ListView_GetItemCount(hListView);
1139 for(i=i2-2;i>=0;i--){
1140 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1141 ListView_DeleteItem(hListView,i);
1142 i3=i;
1143 }
1144 }
1145
1146 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1147 }
1148 }
1149 }
1150 break;
1151
1152 case WM_SIZE:
1153 //変数リストの位置
1154 int width_VarList;
1155 width_VarList=
1156 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1157
1158 MoveWindow(hTab,
1159 pos_VarList.x,
1160 pos_VarList.y,
1161 width_VarList,
1162 HIWORD(lParam)-pos_VarList.y,
1163 1);
1164
1165 GetClientRect(hTab,&rect);
1166 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1167 rect.left-=2;
1168 rect.right++;
1169 rect.bottom++;
1170
1171 MoveWindow(hVarTree_Global,
1172 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1173 MoveWindow(hVarTree_Local,
1174 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1175 MoveWindow(hVarTree_This,
1176 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1177
1178 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1179 pos_WatchList.y=0;
1180
1181 //ウォッチリストの位置
1182 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1183 pos_WatchList.x,
1184 pos_WatchList.y,
1185 LOWORD(lParam)-pos_WatchList.x,
1186 HIWORD(lParam)-pos_WatchList.y,
1187 1);
1188
1189 return 1;
1190
1191 case WM_VARLIST_CLOSE:
1192 DestroyWindow(hwnd);
1193 return 1;
1194 case WM_DESTROY:
1195 ImageList_Destroy(hVariOrderImageList);
1196
1197
1198 //////////////////////////////////////////////////////////////
1199 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1200 //////////////////////////////////////////////////////////////
1201
1202 for(i=0;i<pobj_nv->WatchNum;i++){
1203 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1204 }
1205 HeapDefaultFree(pobj_nv->ppWatchStr);
1206
1207 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1208 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1209 for(i=0;i<pobj_nv->WatchNum;i++){
1210 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1211 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1212 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1213 }
1214
1215
1216 //////////////////////////////
1217 // デバッグダイアログを破棄
1218 //////////////////////////////
1219
1220 hDebugWnd=0;
1221
1222 extern BOOL bClipCompileView;
1223 if(bClipCompileView){
1224 extern HWND hOwnerEditor;
1225 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1226 }
1227
1228 return 1;
1229
1230
1231
1232 ///////////////////////
1233 // デバッグコマンド
1234 ///////////////////////
1235
1236 case WM_DEBUG_CONTINUE:
1237 DestroyWindow(hwnd);
1238 return 1;
1239 case WM_STEP_IN:
1240 Debugger_StepIn();
1241 return 1;
1242 case WM_STEP_OVER:
1243 Debugger_StepOver();
1244 return 1;
1245 case WM_STEP_CURSOR:
1246 Debugger_StepCursor();
1247 return 1;
1248 }
1249 return 0;
1250}
1251
1252
1253
1254
1255//////////////////////////////////
1256// ポップアップ表示の変数リスト
1257//////////////////////////////////
1258
1259BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1260 extern HANDLE hHeap;
1261 extern HINSTANCE hInst;
1262 extern DWORD dwStepRun;
1263 RECT rect;
1264 POINT pos;
1265 SIZE size;
1266
1267 switch(message){
1268 case WM_INITDIALOG:
1269 extern HWND hDebugWnd;
1270 hDebugWnd=hwnd;
1271
1272 pos.x=pobj_nv->VarDlgRect.left;
1273 pos.y=pobj_nv->VarDlgRect.top;
1274 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1275 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1276 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1277
1278 extern WNDPROC OldThreadComboProc;
1279 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1280 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1281
1282 extern WNDPROC OldProcComboProc;
1283 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1284 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1285
1286 //イメージリスト読み込み、設定
1287 static HIMAGELIST hVariOrderImageList;
1288 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1289 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1290 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1291 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1292 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1293 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1294 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1295
1296 InitVarList((DWORD)lParam);
1297 break;
1298 case WM_COMMAND:
1299 switch(LOWORD(wParam)){
1300 case IDCANCEL:
1301 DestroyWindow(hwnd);
1302 return 1;
1303 case IDC_STEPIN:
1304 dwStepRun=1;
1305 return 1;
1306 case IDC_STEPOVER:
1307 dwStepRun=2;
1308 return 1;
1309 }
1310 break;
1311 case WM_SIZE:
1312 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1313 pos.x=rect.left;
1314 pos.y=rect.top;
1315 ScreenToClient(hwnd,&pos);
1316 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1317 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1318 return 1;
1319 case WM_VARLIST_CLOSE:
1320 DestroyWindow(hwnd);
1321 return 1;
1322 case WM_DESTROY:
1323 ImageList_Destroy(hVariOrderImageList);
1324
1325 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1326
1327 hDebugWnd=0;
1328
1329 return 1;
1330 }
1331 return 0;
1332}
Note: See TracBrowser for help on using the repository browser.