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

Last change on this file since 219 was 208, checked in by dai_9181, 17 years ago

UserProc/DllProc/ProcPointerクラスをSymbolクラスからの派生にした

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