Changeset 75 in dev for BasicCompiler64/WatchList.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/WatchList.cpp
r73 r75 5 5 #include "../BasicCompiler_Common/debug.h" 6 6 7 int Debugging_GetArray( int *SubScripts,char *array,int type,LONG_PTR lpIndex,LONG_PTR *plpOffset);7 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset); 8 8 9 9 ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar){ … … 61 61 } 62 62 63 BOOL Debugging_SetRelativeOffset(int *pType,LONG_PTR lpIndex,RELATIVE_VAR *pRelativeVar,char *lpPtrOffset){63 bool Debugging_SetRelativeOffset( Type &type,RELATIVE_VAR *pRelativeVar,char *lpPtrOffset){ 64 64 int array_num; 65 65 66 66 _int64 i64data; 67 i nt type;68 type=StaticCalculation(true, lpPtrOffset,0,&i64data,0,1);69 if(!type) return 0;70 if( IsRealNumberType(type)){67 if( !StaticCalculation( true, lpPtrOffset, 0, &i64data, Type(), 1 ) ){ 68 return false; 69 } 70 if( type.IsReal() ){ 71 71 double dbl; 72 72 memcpy(&dbl,&i64data,sizeof(double)); … … 76 76 array_num=(int)i64data; 77 77 78 if( PTR_LEVEL(*pType)){79 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1);80 array_num *= GetTypeSize(*pType,-1);78 if( type.PtrLevel() ){ 79 type.PtrLevelDown(); 80 array_num *= type.GetSize(); 81 81 } 82 82 else{ 83 83 //エラー 84 return 0;84 return false; 85 85 } 86 86 … … 89 89 SIZE_T stAccBytes; 90 90 lpData=Debugging_GetVarPtr(pRelativeVar); 91 if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&stAccBytes)) return 0; 91 if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&stAccBytes)){ 92 return false; 93 } 92 94 pRelativeVar->dwKind=VAR_DIRECTMEM; 93 95 94 96 pRelativeVar->offset+=array_num; 95 return 1;97 return true; 96 98 } 97 99 98 BOOL Debugging_GetMember(CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){100 int Debugging_GetMember( const CClass &objClass,char *member,RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 99 101 int i,i2; 100 102 … … 117 119 //////////////////////////// 118 120 119 int offset = pobj_c->GetMemberOffset( VarName, &i );120 if(i== pobj_c->iMemberNum) return 0;121 int offset = objClass.GetMemberOffset( VarName, &i ); 122 if(i==objClass.iMemberNum) return 0; 121 123 122 124 123 125 //アクセシビリティをチェック 124 if((bPrivateAccess==0&& pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||125 pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){126 if((bPrivateAccess==0&&objClass.ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)|| 127 objClass.ppobj_Member[i]->dwAccess==ACCESS_NON){ 126 128 return 0; 127 129 } 128 else if(bPrivateAccess==0&& pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED)130 else if(bPrivateAccess==0&&objClass.ppobj_Member[i]->dwAccess==ACCESS_PROTECTED) 129 131 return 0; 130 132 131 *pType=pobj_c->ppobj_Member[i]->TypeInfo.type; 132 *plpNestIndex=pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex; 133 resultType = *objClass.ppobj_Member[i]; 133 134 134 135 //ポインタ変数の場合 135 if( IsPtrType(*pType)){136 if( pobj_c->ppobj_Member[i]->SubScripts[0]==-1){136 if( resultType.IsPointer() ){ 137 if(objClass.ppobj_Member[i]->SubScripts[0]==-1){ 137 138 lstrcpy(lpPtrOffset,array); 138 139 array[0]=0; … … 148 149 //配列オフセット 149 150 i2=Debugging_GetArray( 150 pobj_c->ppobj_Member[i]->SubScripts,151 objClass.ppobj_Member[i]->SubScripts, 151 152 array, 152 *pType, 153 pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex, 153 resultType, 154 154 &pRelativeVar->offset); 155 155 if(i2==0){ … … 162 162 } 163 163 } 164 else if( pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){165 *pType|=FLAG_PTR;164 else if(objClass.ppobj_Member[i]->SubScripts[0]!=-1){ 165 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 166 166 } 167 167 … … 169 169 //入れ子構造の場合 170 170 171 if( *pType==DEF_OBJECT || *pType==DEF_STRUCT){171 if( resultType.IsObject() || resultType.IsStruct() ){ 172 172 if( refType != CClass::Dot ) return 0; 173 173 174 if( *pType==DEF_OBJECT){174 if( resultType.IsObject() ){ 175 175 extern HANDLE hDebugProcess; 176 176 LONG_PTR lpData; … … 181 181 } 182 182 } 183 else if( *pType==DEF_PTR_OBJECT || *pType==DEF_PTR_STRUCT){183 else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ 184 184 //構造体ポインタ型メンバ変数 185 185 … … 188 188 189 189 //直接参照に切り替え 190 Debugging_SetRelativeOffset( pType,*plpNestIndex,pRelativeVar,lpPtrOffset);190 Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 191 191 192 192 lpPtrOffset[0]=0; … … 204 204 } 205 205 206 i2=Debugging_GetMember( pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,206 i2=Debugging_GetMember(objClass.ppobj_Member[i]->GetClass(), 207 207 NestMember, 208 pType,209 208 pRelativeVar, 210 plpNestIndex,209 resultType, 211 210 0); 212 211 if(i2==0){ … … 221 220 222 221 if(lpPtrOffset[0]){ 223 Debugging_SetRelativeOffset( pType,*plpNestIndex,pRelativeVar,lpPtrOffset);222 Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 224 223 } 225 224 226 225 return 1; 227 226 } 228 int Debugging_GetArray( int *SubScripts,char *array,int type,LONG_PTR lpIndex,LONG_PTR *plpOffset){227 int Debugging_GetArray( const int *SubScripts,char *array,const Type &type,LONG_PTR *plpOffset){ 229 228 extern HANDLE hHeap; 230 int i,i2,i3,i4,i5,array_offset ,TypeSize;229 int i,i2,i3,i4,i5,array_offset; 231 230 char temporary[VN_SIZE],*pParm[MAX_PARMS]; 232 231 … … 275 274 for(i=i3-1;i>=0;i--){ 276 275 _int64 i64data; 277 i2=StaticCalculation(true, pParm[i],0,&i64data,0,1); 278 if(i2==0){ 276 Type resultType; 277 bool isMemoryAccessError; 278 if( !StaticCalculation(true, pParm[i],0,&i64data,resultType,1, &isMemoryAccessError ) ){ 279 279 //式エラー 280 280 return 0; 281 281 } 282 if(i 2==-1){282 if(isMemoryAccessError){ 283 283 //アクセスエラー 284 284 return -1; 285 285 } 286 286 287 if( IsRealNumberType(i2)){287 if(resultType.IsReal()){ 288 288 double dbl; 289 289 memcpy(&dbl,&i64data,sizeof(double)); … … 299 299 } 300 300 301 TypeSize=GetTypeSize(type,lpIndex); 302 303 array_offset*=TypeSize; 301 array_offset *= type.GetSize(); 304 302 305 303 *plpOffset+=array_offset; … … 308 306 } 309 307 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ 310 int i; 311 SubInfo *psi; 312 313 //ripからプロシージャを取得 314 psi=GetSubFromObp(obp_Rip); 315 316 for(i=0;i<psi->VarNum;i++){ 317 if(lstrcmp(psi->pVar[i].name,"_System_LocalThis")==0) break; 318 } 319 if(i==psi->VarNum) return 0; 320 321 return psi->pVar[i].offset; 308 UserProc *pUserProc = GetSubFromObp(obp_Rip); 309 310 foreach( Variable *pVar, pUserProc->localVars ){ 311 if( pVar->GetName() == "_System_LocalThis" ){ 312 return pVar->offset; 313 } 314 } 315 return 0; 322 316 } 323 int Debugging_GetVarOffset( char *variable,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){317 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss){ 324 318 extern HANDLE hDebugProcess; 325 319 int i,i2,i3; … … 332 326 GetVarFormatString(VarName,array,lpPtrOffset,member,refType); 333 327 334 LONG_PTR lpIndex; 335 int *pSubScripts; 336 BOOL bArray; 328 const int *pSubScripts; 329 bool isArray; 337 330 338 331 … … 340 333 // ローカル変数 341 334 ///////////////// 342 extern VARIABLE *LocalVar; 343 extern int MaxLocalVarNum; 344 for(i=0;i<MaxLocalVarNum;i++){ 345 if(lstrcmp(VarName,LocalVar[i].name)==0) break; 346 } 347 if(i!=MaxLocalVarNum){ 335 const Variable *pVar = UserProc::CompilingUserProc().localVars.Find( VarName ); 336 if( pVar ){ 348 337 //ポインタ変数の場合 349 if( IsPtrType(LocalVar[i].type)){350 if( !LocalVar[i].bArray){338 if( pVar->IsPointer() ){ 339 if( !pVar->IsArray() ){ 351 340 lstrcpy(lpPtrOffset,array); 352 341 array[0]=0; … … 357 346 } 358 347 359 pRelativeVar->offset=LocalVar[i].offset; 360 if(LocalVar[i].fRef) pRelativeVar->dwKind=VAR_REFLOCAL; 361 else pRelativeVar->dwKind=VAR_LOCAL; 362 *pType=LocalVar[i].type; 363 lpIndex=LocalVar[i].u.index; 364 *plpIndex=lpIndex; 365 bArray=LocalVar[i].bArray; 366 pSubScripts=LocalVar[i].SubScripts; 348 pRelativeVar->offset = pVar->offset; 349 if( pVar->IsRef() ){ 350 pRelativeVar->dwKind=VAR_REFLOCAL; 351 } 352 else{ 353 pRelativeVar->dwKind=VAR_LOCAL; 354 } 355 resultType = *pVar; 356 isArray = pVar->IsArray(); 357 pSubScripts = pVar->GetSubScriptsPtr(); 367 358 } 368 359 else{ … … 406 397 pRelativeVar->dwKind=VAR_DIRECTMEM; 407 398 408 LONG_PTR lp2; 409 i3=Debugging_GetMember(pobj_CompilingClass,variable,pType,pRelativeVar,&lp2,1); 399 i3=Debugging_GetMember(*pobj_CompilingClass,variable,pRelativeVar,resultType,1); 410 400 if(i3==0){ 411 401 //式エラー … … 417 407 } 418 408 419 *plpIndex=lp2;420 409 return 1; 421 410 } … … 426 415 // グローバル変数 427 416 /////////////////// 428 extern VARIABLE *GlobalVar; 429 extern int MaxGlobalVarNum; 430 431 for(i=0;i<MaxGlobalVarNum;i++){ 432 if(lstrcmp(VarName,GlobalVar[i].name)==0) break; 433 } 434 if(i==MaxGlobalVarNum){ 417 418 const Variable *pVar = globalVars.Find( VarName ); 419 if( !pVar ){ 435 420 //一致しないとき 436 421 return 0; … … 438 423 439 424 //ポインタ変数の場合 440 if( IsPtrType(GlobalVar[i].type)){441 if( !GlobalVar[i].bArray){425 if( pVar->IsPointer() ){ 426 if( !pVar->IsArray() ){ 442 427 lstrcpy(lpPtrOffset,array); 443 428 array[0]=0; … … 448 433 } 449 434 450 pRelativeVar->offset= GlobalVar[i].offset;451 if( GlobalVar[i].fRef) pRelativeVar->dwKind=VAR_REFGLOBAL;435 pRelativeVar->offset=pVar->offset; 436 if(pVar->IsRef()) pRelativeVar->dwKind=VAR_REFGLOBAL; 452 437 else pRelativeVar->dwKind=VAR_GLOBAL; 453 *pType=GlobalVar[i].type; 454 lpIndex=GlobalVar[i].u.index; 455 *plpIndex=lpIndex; 456 bArray=GlobalVar[i].bArray; 457 pSubScripts=GlobalVar[i].SubScripts; 458 } 459 460 461 if(array[0]==0&&bArray){ 438 resultType = *pVar; 439 isArray = pVar->IsArray(); 440 pSubScripts=pVar->GetSubScriptsPtr(); 441 } 442 443 444 if(array[0]==0&&isArray){ 462 445 //配列の先頭ポインタを示す場合 463 *pType|=FLAG_PTR;464 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM );446 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 447 if(pss) memcpy(pss,pSubScripts,MAX_ARRAYDIM*sizeof(int)); 465 448 return 1; 466 449 } 467 450 468 451 if(array[0]){ 469 i3=Debugging_GetArray(pSubScripts,array, *pType,lpIndex,&pRelativeVar->offset);452 i3=Debugging_GetArray(pSubScripts,array,resultType,&pRelativeVar->offset); 470 453 if(i3==0){ 471 454 //式エラー … … 478 461 } 479 462 if(member[0]){ 480 if( *pType==DEF_OBJECT || *pType==DEF_STRUCT){463 if( resultType.IsObject() || resultType.IsStruct() ){ 481 464 //実態オブジェクトのメンバを参照(obj.member) 482 465 if( refType != CClass::Dot ){ … … 484 467 } 485 468 486 LONG_PTR lp2; 487 i3=Debugging_GetMember((CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0); 469 i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); 488 470 if(i3==0){ 489 471 //式エラー … … 494 476 return -1; 495 477 } 496 497 *plpIndex=lp2; 498 } 499 else if(*pType==DEF_PTR_OBJECT || *pType==DEF_PTR_STRUCT){ 478 } 479 else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ 500 480 //ポインタオブジェクトが示すメンバを参照 501 481 if(lpPtrOffset[0]){ 502 482 //pObj[n].member 503 483 if( refType != CClass::Dot ) return 0; 504 Debugging_SetRelativeOffset(pType,lpIndex,pRelativeVar,lpPtrOffset); 505 506 LONG_PTR lp2; 507 i3=Debugging_GetMember((CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0); 484 Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); 485 486 i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); 508 487 if(i3==0){ 509 488 //式エラー … … 514 493 return -1; 515 494 } 516 517 *plpIndex=lp2;518 495 } 519 496 else{ … … 527 504 pRelativeVar->offset=lpData; 528 505 529 LONG_PTR lp2; 530 i3=Debugging_GetMember((CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0); 506 i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); 531 507 if(i3==0){ 532 508 //式エラー … … 537 513 return -1; 538 514 } 539 540 *plpIndex=lp2;541 515 } 542 516 } … … 548 522 549 523 if(lpPtrOffset[0]){ 550 if(!Debugging_SetRelativeOffset( pType,lpIndex,pRelativeVar,lpPtrOffset)) return 0;524 if(!Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset)) return 0; 551 525 } 552 526
Note:
See TracChangeset
for help on using the changeset viewer.