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

Last change on this file since 408 was 393, checked in by dai_9181, 17 years ago

デバッガ変数リストのローカル変数のスコープ判定が間違っていたため、修正。

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