source: dev/trunk/abdev/BasicCompiler_Common/VarList.cpp@ 154

Last change on this file since 154 was 140, checked in by dai_9181, 17 years ago

traceログ機能を搭載
動的メンバをstl::vectorにまとめた
シンボルをクラス化した

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