source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/VarList.cpp@ 743

Last change on this file since 743 was 743, checked in by dai, 16 years ago

oldSourceLinesを排除。

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