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