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

Last change on this file since 280 was 280, checked in by dai_9181, 17 years ago
File size: 39.3 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.GetObjectModule().meta.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.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
361 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
362 {
363 pUserProc = compiler.GetObjectModule().meta.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 SourceLines oldSourceLines;
572 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
573 for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){
574 if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
575 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break;
576 }
577 if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1;
578 else
579 {
580 pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos();
581 pobj_dti->lpdwSourceIndex[i3]=oldSourceLines[i2].GetSourceIndex();
582 }
583 }
584 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
585 if(pobj_dti->lpdwCp[i3]==-1){
586 pobj_dti->iProcLevel--;
587 for(i2=i3;i2<(int)pobj_dti->iProcLevel+1;i2++){
588 pobj_dti->lplpObp[i2]=pobj_dti->lplpObp[i2+1];
589 pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
590 pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
591 pobj_dti->lpdwSourceIndex[i2]=pobj_dti->lpdwSourceIndex[i2+1];
592 }
593 i3--;
594 continue;
595 }
596 }
597
598 std::string dummyStr;
599 if(!compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel], i2, dummyStr )){
600 extern HWND hMainDlg;
601 //"デバッグ情報の取得に失敗"
602 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
603 return 0;
604 }
605 ShowErrorLine(i2,dummyStr.c_str());
606
607 //プロシージャ コンボボックス
608 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
609 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
610
611 UserProc *pUserProc = NULL;
612 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
613 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
614 {
615 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
616
617 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
618 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress()))
619 {
620 lstrcpy(temporary,pUserProc->GetName().c_str());
621 break;
622 }
623 }
624 if(!pUserProc){
625 if(i2==0){
626 lstrcpy(temporary,"Global");
627 pobj_dti->lplpSpBase[i2]=0;
628 }
629 else lstrcpy(temporary,"error");
630 }
631 SendMessage(hProcCombo,CB_ADDSTRING,0,(LPARAM)temporary);
632 }
633 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
634
635 return pobj_dti->iProcLevel;
636}
637
638//IDC_THREADCOMBOプロシージャ
639LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
640 extern WNDPROC OldThreadComboProc;
641 int i2;
642 DWORD dwThreadID;
643 char temporary[255];
644
645 switch(message){
646 case WM_COMMAND:
647 if(HIWORD(wParam)==CBN_SELCHANGE){
648 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(LPARAM)temporary);
649 sscanf(temporary+2,"%X",&dwThreadID);
650
651 extern DWORD _DebugSys_dwThreadID[256];
652 i2=0;
653 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
654
655 //次回のステップ実行対象を指定
656 extern int NextStepThreadNum;
657 NextStepThreadNum=i2;
658
659 //スレッド情報をリフレッシュ
660 pobj_dti->Reflesh(i2);
661
662 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
663
664 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
665 }
666 break;
667 }
668 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
669}
670//IDC_PROCCOMBOプロシージャ
671LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
672 extern WNDPROC OldProcComboProc;
673 int i2,i3;
674
675 switch(message){
676 case WM_COMMAND:
677 if(HIWORD(wParam)==CBN_SELCHANGE){
678 i2=(int)SendMessage(hwnd,CB_GETCURSEL,0,0);
679
680 std::string dummyStr;
681 compiler.GetObjectModule().GetSource( pobj_dti->lpdwSourceIndex[pobj_dti->iProcLevel] ).GetLineInfo( pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2], i3, dummyStr );
682 ShowErrorLine(i3,dummyStr.c_str());
683
684 RefreshLocalVar_with_WindowLock();
685 }
686 break;
687 }
688 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
689}
690void InitVarList(DWORD dwThreadId){
691 extern HWND hDebugWnd;
692 int i2,i5;
693 char temporary[255];
694
695
696 //スレッド
697 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
698 extern DWORD _DebugSys_dwThreadID[256];
699 for(i2=0;i2<256;i2++){
700 if(_DebugSys_dwThreadID[i2]){
701 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
702 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
703 if(_DebugSys_dwThreadID[i2]==dwThreadId){
704 extern int NextStepThreadNum;
705 NextStepThreadNum=i2;
706 }
707 }
708 }
709 sprintf(temporary,"&H%08X",dwThreadId);
710 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
711 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
712
713 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
714
715
716 ///////////////////////////////////////////////
717 // 実行中のプロシージャのローカル変数をセット
718 ///////////////////////////////////////////////
719
720 i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
721 i2=pobj_dti->iProcLevel-i2;
722
723 if(pobj_dti->lplpSpBase[i2]){
724
725 UserProc *pUserProc = NULL;
726 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
727 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
728 {
729 pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
730
731 if(rva_to_real(pUserProc->GetBeginOpAddress()) <= pobj_dti->lplpObp[i2] &&
732 pobj_dti->lplpObp[i2] < rva_to_real(pUserProc->GetEndOpAddress())){
733 break;
734 }
735 }
736
737 if(pUserProc){
738 compiler.pCompilingClass = pUserProc->GetParentClassPtr();
739 UserProc::CompileStartForUserProc( pUserProc );
740 }
741 }
742
743
744 ////////////////////////
745 // 変数リストを再表示
746 ////////////////////////
747
748 //処理時間を短くするため、一時的に非表示にする
749 LockWindowUpdate(hDebugWnd);
750 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
751 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
752
753 //リフレッシュ
754 RefreshLocalVar();
755 RefreshGlobalVar();
756 RefreshWatchList();
757
758 LockWindowUpdate(NULL);
759 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
760 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
761}
762
763
764
765
766//////////////////////////////////////
767// エディタに埋め込み表示のデバッガ
768//////////////////////////////////////
769
770BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
771 extern HINSTANCE hInst;
772 extern DWORD dwStepRun;
773
774 //デバッガ用ツールバー
775#define BMPNUM_DEBUGGERTOOLBAR 3
776#define BTNNUM_DEBUGGERTOOLBAR 4
777 TBBUTTON DebuggerToolBar[]={
778 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
779 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
780 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
781 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
782 };
783 TOOLTIPTEXT *pTipText;
784
785 static HIMAGELIST hImageList,hImageList_Disabled;
786
787 switch(message){
788 case WM_INITDIALOG:
789 //ツールバーを生成
790 extern HWND hDebuggerToolbar;
791 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
792 NULL,
793 0,0,0,
794 DebuggerToolBar,
795 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
796 0,0,16,15,sizeof(TBBUTTON));
797
798 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
799 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
800 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
801 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
802 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
803 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
804
805 break;
806 case WM_COMMAND:
807 switch(LOWORD(wParam)){
808 case IDC_DEBUG_START:
809 DestroyWindow(GetParent(hwnd));
810 return 1;
811 case IDC_DEBUG_STEPIN:
812 dwStepRun=1;
813 return 1;
814 case IDC_DEBUG_STEPOVER:
815 dwStepRun=2;
816 return 1;
817 }
818 break;
819 case WM_NOTIFY:
820 pTipText=(TOOLTIPTEXT *)lParam;
821 if(pTipText->hdr.code==TTN_NEEDTEXT){
822 //ツールチップを表示
823 switch(pTipText->hdr.idFrom){
824 case IDC_DEBUG_START:
825 pTipText->lpszText="実行";
826 break;
827 case IDC_DEBUG_STEPOVER:
828 pTipText->lpszText="ステップ アウト";
829 break;
830 case IDC_DEBUG_STEPIN:
831 pTipText->lpszText="ステップ イン";
832 break;
833 }
834 }
835 break;
836 case WM_SIZE:
837 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
838 return 1;
839
840 case WM_DESTROY:
841 ImageList_Destroy(hImageList);
842 ImageList_Destroy(hImageList_Disabled);
843 return 1;
844 }
845 return 0;
846}
847
848WNDPROC OldTabProc;
849LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
850 extern HINSTANCE hInst;
851
852 static HMENU hDummyMenu,hMenu=0;
853
854 switch(message){
855 case WM_CONTEXTMENU:
856 if(hMenu==0){
857 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
858 hMenu=GetSubMenu(hDummyMenu,0);
859 }
860
861 MENUITEMINFO mi;
862 mi.cbSize=sizeof(MENUITEMINFO);
863 mi.fMask=MIIM_STATE;
864 mi.fState=MFS_CHECKED;
865
866 if(pobj_nv->bShow_DefaultSystem_Var)
867 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
868 if(pobj_nv->bShow_Rad_Var)
869 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
870 if(pobj_nv->bShow_GUID_Var)
871 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
872
873 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
874
875 break;
876 case WM_COMMAND:
877 mi.cbSize=sizeof(MENUITEMINFO);
878 mi.fMask=MIIM_STATE;
879 switch(LOWORD(wParam)){
880 case IDM_SHOW_DEFAULTSYSTEM_VAR:
881 if(pobj_nv->bShow_DefaultSystem_Var){
882 pobj_nv->bShow_DefaultSystem_Var=0;
883 mi.fState=MFS_UNCHECKED;
884 }
885 else{
886 pobj_nv->bShow_DefaultSystem_Var=1;
887 mi.fState=MFS_CHECKED;
888 }
889 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
890 RefreshGlobalVar_with_WindowLock();
891 break;
892 case IDM_SHOW_RAD_VAR:
893 if(pobj_nv->bShow_Rad_Var){
894 pobj_nv->bShow_Rad_Var=0;
895 mi.fState=MFS_UNCHECKED;
896 }
897 else{
898 pobj_nv->bShow_Rad_Var=1;
899 mi.fState=MFS_CHECKED;
900 }
901 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
902 RefreshGlobalVar_with_WindowLock();
903 break;
904 case IDM_SHOW_GUID_VAR:
905 if(pobj_nv->bShow_GUID_Var){
906 pobj_nv->bShow_GUID_Var=0;
907 mi.fState=MFS_UNCHECKED;
908 }
909 else{
910 pobj_nv->bShow_GUID_Var=1;
911 mi.fState=MFS_CHECKED;
912 }
913 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
914 RefreshGlobalVar_with_WindowLock();
915 break;
916 }
917 break;
918 case WM_DESTROY:
919 DestroyMenu(hMenu);
920 hMenu=0;
921 break;
922 }
923 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
924}
925
926BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
927 extern HANDLE hHeap;
928 extern HINSTANCE hInst;
929 extern DWORD dwStepRun;
930 extern double width_ratio_VarList;
931 RECT rect;
932 int i,i2,i3;
933 char temporary[VN_SIZE];
934 LV_DISPINFO *lvinfo;
935 LVITEM ListView_Item;
936
937 static POINT pos_VarList;
938 static POINT pos_WatchList;
939
940 switch(message){
941 case WM_INITDIALOG:
942 extern HWND hDebugWnd;
943 hDebugWnd=hwnd;
944
945 //変数リストの初期位置を取得
946 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
947 pos_VarList.x=rect.left;
948 pos_VarList.y=rect.top;
949 ScreenToClient(hwnd,&pos_VarList);
950
951 //ウォッチリストの初期位置を取得
952 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
953 pos_WatchList.y=0;
954
955 //ツールバーのベースウィンドウを生成
956 static HWND hBase_ToolBar;
957 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,(DLGPROC)DebuggerButtonsProc);
958 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
959
960 extern WNDPROC OldThreadComboProc;
961 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
962 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
963
964 extern WNDPROC OldProcComboProc;
965 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
966 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
967
968
969 ///////////////////////////
970 // タブコントロールを生成
971 ///////////////////////////
972
973 static HWND hTab;
974 HFONT hFont;
975 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
976 hTab=CreateWindow(WC_TABCONTROL,NULL,
977 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
978 0,0,0,0,hwnd,0,hInst,0);
979 SendMessage(hTab,WM_SETFONT,(WPARAM)hFont,0);
980 OldTabProc=(WNDPROC)GetWindowLongPtr(hTab,GWLP_WNDPROC);
981 SetWindowLongPtr(hTab,GWLP_WNDPROC,(LONG_PTR)TabProc);
982
983 //タブを設定
984 TC_ITEM tcItem;
985 tcItem.mask=TCIF_TEXT;
986 tcItem.pszText="グローバル";
987 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
988 tcItem.mask=TCIF_TEXT;
989 tcItem.pszText="ローカル";
990 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
991 tcItem.mask=TCIF_TEXT;
992 tcItem.pszText="This";
993 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
994
995 //グローバル変数リストのツリーを作成
996 hVarTree_Global=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 //ローカル変数リストのツリーを作成
1002 hVarTree_Local=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 //This変数リストのツリーを作成
1008 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
1009 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
1010 0,0,0,0,
1011 hTab,0,hInst,0);
1012
1013 ShowWindow(hVarTree_Global,SW_SHOW);
1014
1015
1016 //イメージリスト読み込み、設定
1017 static HIMAGELIST hVariOrderImageList;
1018 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1019 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1020 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1021 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1022 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1023 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1024 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1025 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1026 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1027
1028
1029 /////////////////////////
1030 // ウォッチリスト
1031 /////////////////////////
1032
1033 //コラムの設定
1034 static HWND hListView;
1035 LV_COLUMN ListView_Column;
1036 DWORD dwStyle;
1037
1038 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1039 GetClientRect(hListView,&rect);
1040 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1041 dwStyle|=LVS_EX_FULLROWSELECT;
1042 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1043
1044 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1045 ListView_Column.fmt=LVCFMT_LEFT;
1046
1047 extern int width_WatchColumn_Expression;
1048 ListView_Column.cx=width_WatchColumn_Expression;
1049 ListView_Column.pszText="ウォッチ式";
1050 ListView_Column.iSubItem=0;
1051 ListView_InsertColumn(hListView,0,&ListView_Column);
1052
1053 extern int width_WatchColumn_Value;
1054 ListView_Column.cx=width_WatchColumn_Value;
1055 ListView_Column.pszText="値";
1056 ListView_Column.iSubItem=1;
1057 ListView_InsertColumn(hListView,1,&ListView_Column);
1058
1059 //アイテムの設定
1060 ListView_Item.mask=LVIF_TEXT;
1061 ListView_Item.iSubItem=0;
1062 for(i=0;i<pobj_nv->WatchNum;i++){
1063 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1064 ListView_Item.iItem=i;
1065 ListView_InsertItem(hListView,&ListView_Item);
1066 }
1067 ListView_Item.pszText="...";
1068 ListView_Item.iItem=i;
1069 ListView_InsertItem(hListView,&ListView_Item);
1070
1071
1072 ///////////////////////
1073 // 変数リストの初期化
1074 ///////////////////////
1075 InitVarList((DWORD)lParam);
1076
1077 break;
1078 case WM_NOTIFY:
1079 NMHDR *hdr;
1080 hdr=(NMHDR *)lParam;
1081 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1082 i=TabCtrl_GetCurSel(hTab);
1083
1084 if(i==0){
1085 //グローバル変数を表示
1086 ShowWindow(hVarTree_Global,SW_SHOW);
1087 ShowWindow(hVarTree_Local,SW_HIDE);
1088 ShowWindow(hVarTree_This,SW_HIDE);
1089 }
1090 else if(i==1){
1091 //ローカル変数を表示
1092 ShowWindow(hVarTree_Global,SW_HIDE);
1093 ShowWindow(hVarTree_Local,SW_SHOW);
1094 ShowWindow(hVarTree_This,SW_HIDE);
1095 }
1096 else if(i==2){
1097 //This変数を表示
1098 ShowWindow(hVarTree_Global,SW_HIDE);
1099 ShowWindow(hVarTree_Local,SW_HIDE);
1100 ShowWindow(hVarTree_This,SW_SHOW);
1101 }
1102 }
1103
1104 if(hdr->hwndFrom==hListView){
1105 lvinfo=(LV_DISPINFO *)hdr;
1106 if(hdr->code==NM_DBLCLK){
1107 i2=ListView_GetItemCount(hListView);
1108 for(i=0;i<i2;i++){
1109 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1110 }
1111 if(i==i2) break;
1112
1113 ListView_EditLabel(hListView,i);
1114 }
1115
1116 static HWND hEdit;
1117 if(hdr->code==LVN_BEGINLABELEDIT){
1118 hEdit=ListView_GetEditControl(hListView);
1119
1120 GetWindowText(hEdit,temporary,VN_SIZE);
1121 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1122 }
1123 if(hdr->code==LVN_ENDLABELEDIT){
1124 GetWindowText(hEdit,temporary,VN_SIZE);
1125 if(temporary[0]=='\0'){
1126 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1127
1128 //空白入力の場合はそのアイテムを削除する
1129 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1130 break;
1131 }
1132 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1133
1134 //演算結果を表示
1135 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1136
1137 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1138 //リストアイテムを追加
1139 ListView_Item.mask=LVIF_TEXT;
1140 ListView_Item.pszText="...";
1141 ListView_Item.iItem=lvinfo->item.iItem+1;
1142 ListView_Item.iSubItem=0;
1143 ListView_InsertItem(hListView,&ListView_Item);
1144 }
1145 }
1146
1147 if(hdr->code==LVN_KEYDOWN){
1148 LV_KEYDOWN *plvKeydown;
1149 plvKeydown=(LV_KEYDOWN *)hdr;
1150 if(plvKeydown->wVKey==VK_DELETE){
1151 i2=ListView_GetItemCount(hListView);
1152 for(i=i2-2;i>=0;i--){
1153 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1154 ListView_DeleteItem(hListView,i);
1155 i3=i;
1156 }
1157 }
1158
1159 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1160 }
1161 }
1162 }
1163 break;
1164
1165 case WM_SIZE:
1166 //変数リストの位置
1167 int width_VarList;
1168 width_VarList=
1169 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1170
1171 MoveWindow(hTab,
1172 pos_VarList.x,
1173 pos_VarList.y,
1174 width_VarList,
1175 HIWORD(lParam)-pos_VarList.y,
1176 1);
1177
1178 GetClientRect(hTab,&rect);
1179 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1180 rect.left-=2;
1181 rect.right++;
1182 rect.bottom++;
1183
1184 MoveWindow(hVarTree_Global,
1185 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1186 MoveWindow(hVarTree_Local,
1187 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1188 MoveWindow(hVarTree_This,
1189 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1190
1191 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1192 pos_WatchList.y=0;
1193
1194 //ウォッチリストの位置
1195 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1196 pos_WatchList.x,
1197 pos_WatchList.y,
1198 LOWORD(lParam)-pos_WatchList.x,
1199 HIWORD(lParam)-pos_WatchList.y,
1200 1);
1201
1202 return 1;
1203
1204 case WM_VARLIST_CLOSE:
1205 DestroyWindow(hwnd);
1206 return 1;
1207 case WM_DESTROY:
1208 ImageList_Destroy(hVariOrderImageList);
1209
1210
1211 //////////////////////////////////////////////////////////////
1212 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1213 //////////////////////////////////////////////////////////////
1214
1215 for(i=0;i<pobj_nv->WatchNum;i++){
1216 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1217 }
1218 HeapDefaultFree(pobj_nv->ppWatchStr);
1219
1220 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1221 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1222 for(i=0;i<pobj_nv->WatchNum;i++){
1223 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1224 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1225 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1226 }
1227
1228
1229 //////////////////////////////
1230 // デバッグダイアログを破棄
1231 //////////////////////////////
1232
1233 hDebugWnd=0;
1234
1235 extern BOOL bClipCompileView;
1236 if(bClipCompileView){
1237 extern HWND hOwnerEditor;
1238 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1239 }
1240
1241 return 1;
1242
1243
1244
1245 ///////////////////////
1246 // デバッグコマンド
1247 ///////////////////////
1248
1249 case WM_DEBUG_CONTINUE:
1250 DestroyWindow(hwnd);
1251 return 1;
1252 case WM_STEP_IN:
1253 Debugger_StepIn();
1254 return 1;
1255 case WM_STEP_OVER:
1256 Debugger_StepOver();
1257 return 1;
1258 case WM_STEP_CURSOR:
1259 Debugger_StepCursor();
1260 return 1;
1261 }
1262 return 0;
1263}
1264
1265
1266
1267
1268//////////////////////////////////
1269// ポップアップ表示の変数リスト
1270//////////////////////////////////
1271
1272BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1273 extern HANDLE hHeap;
1274 extern HINSTANCE hInst;
1275 extern DWORD dwStepRun;
1276 RECT rect;
1277 POINT pos;
1278 SIZE size;
1279
1280 switch(message){
1281 case WM_INITDIALOG:
1282 extern HWND hDebugWnd;
1283 hDebugWnd=hwnd;
1284
1285 pos.x=pobj_nv->VarDlgRect.left;
1286 pos.y=pobj_nv->VarDlgRect.top;
1287 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1288 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1289 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1290
1291 extern WNDPROC OldThreadComboProc;
1292 OldThreadComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC);
1293 SetWindowLongPtr(GetDlgItem(hwnd,IDC_THREADCOMBO),GWLP_WNDPROC,(LONG_PTR)ThreadComboProc);
1294
1295 extern WNDPROC OldProcComboProc;
1296 OldProcComboProc=(WNDPROC)GetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC);
1297 SetWindowLongPtr(GetDlgItem(hwnd,IDC_PROCCOMBO),GWLP_WNDPROC,(LONG_PTR)ProcComboProc);
1298
1299 //イメージリスト読み込み、設定
1300 static HIMAGELIST hVariOrderImageList;
1301 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1302 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1303 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1304 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1305 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1306 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1307 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1308
1309 InitVarList((DWORD)lParam);
1310 break;
1311 case WM_COMMAND:
1312 switch(LOWORD(wParam)){
1313 case IDCANCEL:
1314 DestroyWindow(hwnd);
1315 return 1;
1316 case IDC_STEPIN:
1317 dwStepRun=1;
1318 return 1;
1319 case IDC_STEPOVER:
1320 dwStepRun=2;
1321 return 1;
1322 }
1323 break;
1324 case WM_SIZE:
1325 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1326 pos.x=rect.left;
1327 pos.y=rect.top;
1328 ScreenToClient(hwnd,&pos);
1329 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1330 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1331 return 1;
1332 case WM_VARLIST_CLOSE:
1333 DestroyWindow(hwnd);
1334 return 1;
1335 case WM_DESTROY:
1336 ImageList_Destroy(hVariOrderImageList);
1337
1338 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1339
1340 hDebugWnd=0;
1341
1342 return 1;
1343 }
1344 return 0;
1345}
Note: See TracBrowser for help on using the repository browser.