Changeset 263 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Aug 5, 2007, 3:47:49 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/BasicCompiler.h
r209 r263 57 57 char szDebugExeForDll[1024]; 58 58 59 //デバッグ用行番号情報60 LINEINFO *pLineInfo;61 int MaxLineInfoNum;62 63 59 //ウォッチリスト 64 60 int width_WatchColumn_Expression=200; -
trunk/abdev/BasicCompiler_Common/BreakPoint.cpp
r256 r263 3 3 #include <jenga/include/common/Environment.h> 4 4 #include <jenga/include/smoothie/Source.h> 5 6 #include <Compiler.h> 5 7 6 8 #include "common.h" … … 69 71 70 72 if(i2==piLine[nCount]){ 71 extern int MaxLineInfoNum; 72 extern LINEINFO *pLineInfo; 73 extern SourceLines oldSourceLines; 73 74 74 75 loop: … … 77 78 78 79 int i3; 79 for(i3=0;i3< MaxLineInfoNum-1;i3++){80 if( pLineInfo[i3].TopCp==tempCp) break;80 for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){ 81 if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break; 81 82 } 82 if(i3== MaxLineInfoNum-1){83 if(i3==oldSourceLines.size()-1){ 83 84 i2--; 84 85 goto loop; 85 86 } 86 87 87 nativeCodeBuffer[ pLineInfo[i3].TopObp]=(char)0xCC;88 nativeCodeBuffer[oldSourceLines[i3].GetNativeCodePos()]=(char)0xCC; 88 89 89 90 nCount++; -
trunk/abdev/BasicCompiler_Common/Compile.cpp
r261 r263 25 25 //With情報 26 26 WITHINFO WithInfo; 27 28 //デバッグ用行番号情報 29 SourceLines oldSourceLines; 27 30 28 31 … … 80 83 81 84 void NextLine(void){ 82 extern HANDLE hHeap; 83 extern int MaxLineInfoNum; 84 extern LINEINFO *pLineInfo; 85 if(MaxLineInfoNum){ 86 extern int obp; 87 if(pLineInfo[MaxLineInfoNum-1].TopObp==obp){ 88 pLineInfo[MaxLineInfoNum-1].TopCp=cp; 85 extern int obp; 86 87 extern SourceLines oldSourceLines; 88 if( oldSourceLines.size() ) 89 { 90 if( oldSourceLines.back().GetNativeCodePos() == obp ) 91 { 92 oldSourceLines.back().SetSourceCodePos( cp ); 89 93 return; 90 94 } 91 95 } 92 pLineInfo=(LINEINFO *)HeapReAlloc(hHeap,0,pLineInfo,(MaxLineInfoNum+1)*sizeof(LINEINFO));93 pLineInfo[MaxLineInfoNum].TopCp=cp;94 extern int obp;95 pLineInfo[MaxLineInfoNum].TopObp=obp;96 96 97 97 extern BOOL bDebugSupportProc; 98 98 extern BOOL bSystemProc; 99 pLineInfo[MaxLineInfoNum].dwCodeType=0; 100 if(bDebugSupportProc) 101 pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_DEBUGPROC; 102 if(bSystemProc) 103 pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_SYSTEMPROC; 104 105 MaxLineInfoNum++; 99 DWORD sourceLineType = 0; 100 if( bDebugSupportProc ) 101 { 102 sourceLineType |= CODETYPE_DEBUGPROC; 103 } 104 if( bSystemProc ) 105 { 106 sourceLineType |= CODETYPE_SYSTEMPROC; 107 } 108 oldSourceLines.push_back( SourceLine( (long)oldSourceLines.size(), obp, cp, sourceLineType ) ); 106 109 } 107 110 … … 334 337 breakpoint; 335 338 } 336 #if defined(_DEBUG)337 339 else 338 340 { 341 //#if defined(_DEBUG) 339 342 breakpoint; 340 } 341 #endif 343 //#endif 344 } 342 345 break; 343 346 … … 637 640 638 641 NextLine(); 642 compiler.codeGenerator.NextSourceLine(); 639 643 640 644 if(Command[0]==1){ -
trunk/abdev/BasicCompiler_Common/Debug.cpp
r259 r263 79 79 80 80 if(i2==iLineNum){ 81 extern int MaxLineInfoNum; 82 extern LINEINFO *pLineInfo; 81 extern SourceLines oldSourceLines; 83 82 84 83 loop: … … 87 86 88 87 int i3; 89 for(i3=0;i3< MaxLineInfoNum-1;i3++){90 if( pLineInfo[i3].TopCp==tempCp) break;91 } 92 if(i3== MaxLineInfoNum-1){88 for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){ 89 if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break; 90 } 91 if(i3==oldSourceLines.size()-1){ 93 92 i2--; 94 93 goto loop; 95 94 } 96 95 97 StepCursorObpSchedule= pLineInfo[i3].TopObp;96 StepCursorObpSchedule=oldSourceLines[i3].GetNativeCodePos(); 98 97 StepCursor_BackupChar=pobj_DBDebugSection->pobj_now->BreakStepCodeBuffer[StepCursorObpSchedule]; 99 98 -
trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r259 r263 98 98 // コードと行番号の関係 99 99 //////////////////////// 100 extern int MaxLineInfoNum; 101 extern LINEINFO *pLineInfo; 102 103 //バッファが足りない場合は再確保 104 if(MaxLineInfoNum*sizeof(LINEINFO)<32768) i3=32768; 105 else i3=MaxLineInfoNum*sizeof(LINEINFO)+32768; 106 if(BufferSize<i2+i3){ 107 BufferSize+=i3; 108 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 109 } 110 111 *(long *)(buffer+i2)=MaxLineInfoNum; 112 i2+=sizeof(long); 113 memcpy(buffer+i2,pLineInfo,MaxLineInfoNum*sizeof(LINEINFO)); 114 i2+=MaxLineInfoNum*sizeof(LINEINFO); 100 extern SourceLines oldSourceLines; 101 102 *(long *)(buffer+i2)=(long)oldSourceLines.size(); 103 i2+=sizeof(long); 104 BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines ) 105 { 106 *(long *)(buffer+i2) = sourceLine.GetLineNum(); 107 i2+=sizeof(long); 108 109 *(long *)(buffer+i2) = sourceLine.GetNativeCodePos(); 110 i2+=sizeof(long); 111 112 *(long *)(buffer+i2) = sourceLine.GetSourceCodePos(); 113 i2+=sizeof(long); 114 115 *(long *)(buffer+i2) = sourceLine.GetCodeType(); 116 i2+=sizeof(long); 117 118 //バッファが足りない場合は再確保 119 if(BufferSize<i2+32768){ 120 BufferSize+=32768; 121 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 122 } 123 } 115 124 116 125 … … 431 440 memcpy(buffer,OpBuffer,SizeOf_CodeSection); 432 441 433 int i2;434 for(i2=0;i2<MaxLineInfoNum;i2++){442 BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines ) 443 { 435 444 if(!( 436 pLineInfo[i2].dwCodeType&CODETYPE_SYSTEMPROC||437 pLineInfo[i2].dwCodeType&CODETYPE_DEBUGPROC438 )){445 sourceLine.IsInSystemProc() 446 || sourceLine.IsInDebugProc() ) ) 447 { 439 448 //int 3 440 buffer[ pLineInfo[i2].TopObp]=(char)0xCC;449 buffer[sourceLine.GetNativeCodePos()]=(char)0xCC; 441 450 } 442 451 } … … 487 496 488 497 //コードと行番号の関係 489 MaxLineInfoNum=*(long *)(buffer+i2); 490 i2+=sizeof(long); 491 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)+1); 492 memcpy(pLineInfo,buffer+i2,MaxLineInfoNum*sizeof(LINEINFO)); 493 i2+=MaxLineInfoNum*sizeof(LINEINFO); 498 int maxLineInfoNum; 499 maxLineInfoNum=*(long *)(buffer+i2); 500 i2+=sizeof(long); 501 for(i3=0;i3<maxLineInfoNum;i3++){ 502 int lineNum = *(long *)(buffer+i2); 503 i2+=sizeof(long); 504 505 int nativeCodePos = *(long *)(buffer+i2); 506 i2+=sizeof(long); 507 508 int sourceCodePos = *(long *)(buffer+i2); 509 i2+=sizeof(long); 510 511 DWORD sourceLineType = *(DWORD *)(buffer+i2); 512 i2+=sizeof(long); 513 514 oldSourceLines.push_back( SourceLine( lineNum, nativeCodePos, sourceCodePos, sourceLineType ) ); 515 } 494 516 495 517 … … 837 859 838 860 //コードと行番号の関係 839 extern int MaxLineInfoNum; 840 extern LINEINFO *pLineInfo; 841 MaxLineInfoNum=this->MaxLineInfoNum; 842 pLineInfo=this->pLineInfo; 861 extern SourceLines oldSourceLines; 862 oldSourceLines = this->oldSourceLines; 843 863 844 864 BreakStepCodeBuffer=pobj_DBBreakPoint->update(OpBuffer,SizeOf_CodeSection); … … 956 976 957 977 //コードと行番号の関係 958 extern int MaxLineInfoNum; 959 extern LINEINFO *pLineInfo; 960 MaxLineInfoNum=this->MaxLineInfoNum; 961 pLineInfo=this->pLineInfo; 978 extern SourceLines oldSourceLines; 979 oldSourceLines = this->oldSourceLines; 962 980 963 981 // クラス情報 … … 996 1014 delete this->pobj_DBClass; 997 1015 this->pobj_DBClass=0; 998 999 //コードと行番号の関係を解放1000 HeapDefaultFree(pLineInfo);1001 1016 1002 1017 //コードバッファを解放 -
trunk/abdev/BasicCompiler_Common/DebugSection.h
r206 r263 3 3 #include <jenga/include/smoothie/Source.h> 4 4 5 #include <Class.h> 6 #include <Procedure.h> 7 #include <Const.h> 8 5 #include <Compiler.h> 9 6 10 7 class CDebugSection{ … … 29 26 int SizeOf_CodeSection; 30 27 28 // オブジェクトモジュール 29 ObjectModule objectModule; 30 31 31 //インクルード情報 32 32 INCLUDEFILEINFO IncludeFileInfo; … … 36 36 37 37 //コードと行番号の関係 38 int MaxLineInfoNum; 39 LINEINFO *pLineInfo; 38 SourceLines oldSourceLines; 40 39 41 40 // クラス情報 -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r256 r263 160 160 HeapDefaultFree(pBitmapResourceInfo); 161 161 HeapDefaultFree(pIconResourceInfo); 162 163 //コードと行番号の関係情報を解放164 extern LINEINFO *pLineInfo;165 HeapDefaultFree(pLineInfo);166 162 167 163 //コンパイルダイアログのプログレスバーを上げる -
trunk/abdev/BasicCompiler_Common/VarList.cpp
r259 r263 569 569 570 570 //行番号情報 571 extern int MaxLineInfoNum; 572 extern LINEINFO *pLineInfo; 571 extern SourceLines oldSourceLines; 573 572 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){ 574 for(i2=0;i2< MaxLineInfoNum-1;i2++){575 if((ULONG_PTR)( pLineInfo[i2].TopObp+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&576 pobj_dti->lplpObp[i3]<=(ULONG_PTR)( pLineInfo[i2+1].TopObp+ImageBase+MemPos_CodeSection)) break;577 } 578 if(i2== MaxLineInfoNum) pobj_dti->lpdwCp[i3]=-1;579 else pobj_dti->lpdwCp[i3]= pLineInfo[i2].TopCp;573 for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){ 574 if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&& 575 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break; 576 } 577 if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1; 578 else pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos(); 580 579 } 581 580 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){ -
trunk/abdev/BasicCompiler_Common/common.h
r254 r263 140 140 141 141 142 #define CODETYPE_SYSTEMPROC 0x0001143 #define CODETYPE_DEBUGPROC 0x0002144 struct LINEINFO{145 int TopCp;146 int TopObp;147 DWORD dwCodeType;148 };149 142 struct RESOURCEDATAINFO{ 150 143 DWORD dwId; -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r262 r263 238 238 } 239 239 pNativeCode = &nativeCode; 240 } 241 242 void NextSourceLine() 243 { 244 pNativeCode->NextSourceLine(); 240 245 } 241 246 -
trunk/abdev/BasicCompiler_Common/include/Linker.h
r258 r263 41 41 } 42 42 43 const NativeCode &GetNativeCode() const 44 { 45 return nativeCode; 46 } 47 43 48 void SetImageBase( DWORD imageBase ) 44 49 { -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r258 r263 112 112 typedef std::vector<Schedule> Schedules; 113 113 114 #define CODETYPE_SYSTEMPROC 0x0001 115 #define CODETYPE_DEBUGPROC 0x0002 116 class SourceLine 117 { 118 int lineNum; 119 long nativeCodePos; 120 long sourceCodePos; 121 DWORD codeType; 122 123 // XMLシリアライズ用 124 private: 125 friend class boost::serialization::access; 126 template<class Archive> void serialize(Archive& ar, const unsigned int version) 127 { 128 trace_for_serialize( "serializing - SourceLine" ); 129 130 ar & BOOST_SERIALIZATION_NVP( lineNum ); 131 ar & BOOST_SERIALIZATION_NVP( nativeCodePos ); 132 ar & BOOST_SERIALIZATION_NVP( sourceCodePos ); 133 ar & BOOST_SERIALIZATION_NVP( codeType ); 134 } 135 136 public: 137 SourceLine( int lineNum, int nativeCodePos, int sourceCodePos, DWORD codeType ) 138 : lineNum( lineNum ) 139 , nativeCodePos( nativeCodePos ) 140 , sourceCodePos( sourceCodePos ) 141 , codeType( codeType ) 142 { 143 } 144 SourceLine() 145 { 146 } 147 148 int GetLineNum() const 149 { 150 return lineNum; 151 } 152 long GetNativeCodePos() const 153 { 154 return nativeCodePos; 155 } 156 long GetSourceCodePos() const 157 { 158 return sourceCodePos; 159 } 160 void SetSourceCodePos( int sourceCodePos ) 161 { 162 this->sourceCodePos = sourceCodePos; 163 } 164 DWORD GetCodeType() const 165 { 166 return codeType; 167 } 168 bool IsInSystemProc() const 169 { 170 return ( (codeType&CODETYPE_SYSTEMPROC) != 0 ); 171 } 172 bool IsInDebugProc() const 173 { 174 return ( (codeType&CODETYPE_DEBUGPROC) != 0 ); 175 } 176 }; 177 typedef std::vector<SourceLine> SourceLines; 178 114 179 class NativeCode 115 180 { … … 118 183 int size; 119 184 185 // リンカで解決しなければならないスケジュール 120 186 Schedules schedules; 187 188 // ソースコード行番号とネイティブコード位置の対応情報 189 SourceLines sourceLines; 121 190 122 191 // XMLシリアライズ用 … … 132 201 ar & BOOST_SERIALIZATION_NVP( size ); 133 202 ar & BOOST_SERIALIZATION_NVP( schedules ); 203 ar & BOOST_SERIALIZATION_NVP( sourceLines ); 134 204 135 205 // 読み込み後の処理 … … 163 233 ar & BOOST_SERIALIZATION_NVP( size ); 164 234 ar & BOOST_SERIALIZATION_NVP( schedules ); 235 ar & BOOST_SERIALIZATION_NVP( sourceLines ); 165 236 } 166 237 … … 192 263 Put( nativeCode, isOpBuffer ); 193 264 } 194 NativeCode( const char *codeBuffer, int size )265 NativeCode( const char *codeBuffer, int size, bool isOpBuffer ) 195 266 : allocateSize( 8192 ) 196 267 , codeBuffer( (char *)malloc( allocateSize ) ) 197 268 , size( 0 ) 198 269 { 199 Put( codeBuffer, size );270 Put( codeBuffer, size, isOpBuffer ); 200 271 } 201 272 ~NativeCode() … … 214 285 } 215 286 287 const char *GetCodeBuffer() const 288 { 289 return codeBuffer; 290 } 216 291 int GetSize() const 217 292 { … … 332 407 ObpPlus(); 333 408 } 409 410 void NextSourceLine(); 334 411 }; -
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r259 r263 737 737 pUserProc=(UserProc *)pVtbl[i]; 738 738 if(!pUserProc) continue; 739 pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection; 739 740 // 古いOpBufferを利用する場合は_beginOpAddressOldでないとダメ 741 //pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection; 742 pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 740 743 } 741 744 } -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r258 r263 26 26 if( schedule.GetType() == Schedule::DllProc ) 27 27 { 28 #ifdef _AMD64 28 #ifdef _AMD64_ 29 29 nativeCode.Overwrite( 30 30 schedule.GetOffset(), … … 103 103 void Linker::Link( vector<ObjectModule *> &objectModules ) 104 104 { 105 // nativeCodeは初期状態でなければならない 106 if( nativeCode.GetSize() > 0 ) 107 { 108 SetError(); 109 } 110 105 111 /* 106 112 BOOST_FOREACH( ObjectModule *pObjectModule, objectModules ) -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r258 r263 22 22 long baseOffset = size; 23 23 24 // コードバッファを追加 24 25 Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer ); 25 26 27 // スケジュールを追加 26 28 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules ) 27 29 { … … 31 33 baseOffset + schedule.GetOffset(), 32 34 schedule.GetLongPtrValue() 35 ) 36 ); 37 } 38 39 // ソースコード行番号とネイティブコード位置の対応情報を追加 40 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines ) 41 { 42 this->sourceLines.push_back( 43 SourceLine( 44 sourceLine.GetLineNum(), 45 baseOffset + sourceLine.GetNativeCodePos(), 46 sourceLine.GetSourceCodePos(), 47 sourceLine.GetCodeType() 33 48 ) 34 49 ); … … 85 100 ObpPlus( sizeof(long) ); 86 101 } 102 103 void NativeCode::NextSourceLine() 104 { 105 if( sourceLines.size() ) 106 { 107 if( sourceLines.back().GetNativeCodePos() == size ) 108 { 109 sourceLines.back().SetSourceCodePos( cp ); 110 return; 111 } 112 } 113 114 extern BOOL bDebugSupportProc; 115 extern BOOL bSystemProc; 116 DWORD sourceLineType = 0; 117 if( bDebugSupportProc ) 118 { 119 sourceLineType |= CODETYPE_DEBUGPROC; 120 } 121 if( bSystemProc ) 122 { 123 sourceLineType |= CODETYPE_SYSTEMPROC; 124 } 125 sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) ); 126 }
Note:
See TracChangeset
for help on using the changeset viewer.