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

Last change on this file since 250 was 220, checked in by dai_9181, 17 years ago

[64bitコンパイラ] スタックフレームが128ビット境界ラインにならないバグを修正

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