Changeset 648 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src/BreakPoint.cpp
- Timestamp:
- Jun 17, 2008, 9:24:12 PM (16 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/BreakPoint.cpp
r647 r648 5 5 ////////////////////////// 6 6 7 CDBBreakPoint *pobj_DBBreakPoint; 8 9 CFileBreakPoint::CFileBreakPoint(char *lpszFileName,int iLineNum){ 10 this->lpszFileName=(char *)HeapAlloc(hHeap,0,lstrlen(lpszFileName)+1); 11 lstrcpy(this->lpszFileName,lpszFileName); 12 13 piLine=(int *)HeapAlloc(hHeap,0,sizeof(int)); 14 piLine[0]=iLineNum; 15 num=1; 16 } 17 CFileBreakPoint::~CFileBreakPoint(){ 18 HeapDefaultFree(lpszFileName); 19 HeapDefaultFree(piLine); 20 } 21 void CFileBreakPoint::add(int iLineNum){ 22 piLine=(int *)HeapReAlloc(hHeap,0,piLine,(num+1)*sizeof(int)); 23 piLine[num]=iLineNum; 24 num++; 25 } 26 void CFileBreakPoint::remove(int iLineNum){ 27 int i; 28 for(i=0;i<num;i++){ 29 if(iLineNum==piLine[i]) break; 30 } 31 if(i==num) return; 32 33 num--; 34 for(;i<num;i++){ 35 piLine[i]=piLine[i+1]; 36 } 37 } 38 39 void CFileBreakPoint::update(char *nativeCodeBuffer) 7 BreakPointManager *pobj_DBBreakPoint; 8 9 BreakPointsPerFile::BreakPointsPerFile(char *lpszFileName,int iLineNum){ 10 this->filename = lpszFileName; 11 12 lines.clear(); 13 lines.push_back( iLineNum ); 14 } 15 void BreakPointsPerFile::add(int iLineNum){ 16 lines.push_back( iLineNum ); 17 } 18 void BreakPointsPerFile::remove( int iLineNum ) 19 { 20 for( int i=0; i<static_cast<int>(this->lines.size()); i++ ) 21 { 22 if( iLineNum == this->lines[i] ) 23 { 24 Jenga::Common::EraseVectorItem<std::vector<int>>( this->lines, i ); 25 break; 26 } 27 } 28 } 29 30 void BreakPointsPerFile::update(char *nativeCodeBuffer) 40 31 { 41 32 int FileNum; 42 33 const IncludedFilesRelation *pIncludedFilesRelation = NULL; 43 34 const BasicSource *pNowSource = NULL; 44 BOOST_FOREACH( const ObjectModule *pObjectModule, compiler.staticLibraries ) 45 {46 const BasicSource *pSource = &pObjectModule->GetSource();47 48 pIncludedFilesRelation = & pSource->GetIncludedFilesRelation();35 36 extern BasicSources sourcesLinkRelationalObjectModule; 37 BOOST_FOREACH( const BasicSource &source, sourcesLinkRelationalObjectModule ) 38 { 39 pIncludedFilesRelation = &source.GetIncludedFilesRelation(); 49 40 50 41 for(FileNum=0;FileNum<pIncludedFilesRelation->GetFileCounts();FileNum++) 51 42 { 52 if(lstrcmpi(pIncludedFilesRelation->GetFilePathFromFileNumber(FileNum).c_str(), lpszFileName)==0)43 if(lstrcmpi(pIncludedFilesRelation->GetFilePathFromFileNumber(FileNum).c_str(),this->filename.c_str())==0) 53 44 { 54 pNowSource = pSource;45 pNowSource = &source; 55 46 break; 56 47 } … … 68 59 if( !pIncludedFilesRelation ) 69 60 { 70 Jenga::Throw( " CFileBreakPoint::update内で不正な処理" );61 Jenga::Throw( "BreakPointsPerFile::update内で不正な処理" ); 71 62 return; 72 63 } … … 96 87 } 97 88 98 if(i2== piLine[nCount]){89 if(i2==this->lines[nCount]){ 99 90 extern SourceLines oldSourceLines; 100 91 … … 114 105 115 106 nCount++; 116 if(nCount>=num) break; 117 } 118 } 119 } 120 121 122 CDBBreakPoint::CDBBreakPoint(){ 123 ppItem=(CFileBreakPoint **)HeapAlloc(hHeap,0,1); 124 num=0; 125 107 if( nCount >= static_cast<int>(this->lines.size()) ) 108 { 109 break; 110 } 111 } 112 } 113 } 114 115 116 BreakPointManager::BreakPointManager() 117 { 126 118 char *buffer; 127 119 buffer=(char *)HeapAlloc(hHeap,0,65535); 128 120 121 std::string filepath = ActiveBasic::Common::Environment::GetAbdevRootPath() + "\\ab_breakpoint.tmp"; 129 122 HANDLE hFile=CreateFile( 130 ( Jenga::Common::Environment::GetAppDir() + "\\ab_breakpoint.tmp" ).c_str(),123 filepath.c_str(), 131 124 GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 132 if(hFile!=INVALID_HANDLE_VALUE){ 125 if(hFile!=INVALID_HANDLE_VALUE) 126 { 133 127 DWORD dwAccBytes; 134 128 ReadFile(hFile,buffer,MAX_PATH,&dwAccBytes,NULL); … … 136 130 buffer[dwAccBytes]=0; 137 131 } 138 else buffer[0]=0; 132 else 133 { 134 buffer[0]=0; 135 } 139 136 140 137 int i=0,i2; … … 161 158 HeapDefaultFree(buffer); 162 159 } 163 CDBBreakPoint::~CDBBreakPoint(){ 164 int i; 165 for(i=0;i<num;i++){ 166 delete ppItem[i]; 167 } 168 HeapDefaultFree(ppItem); 169 } 170 void CDBBreakPoint::insert(char *lpszFileName,int iLineNum){ 171 int i; 172 for(i=0;i<num;i++){ 173 if(lstrcmpi(ppItem[i]->lpszFileName,lpszFileName)==0){ 174 ppItem[i]->add(iLineNum); 160 void BreakPointManager::insert(char *lpszFileName,int iLineNum) 161 { 162 BOOST_FOREACH( BreakPointsPerFile &breakpointsPerFile, breakpointsPerFiles ) 163 { 164 if(lstrcmpi(breakpointsPerFile.filename.c_str(),lpszFileName)==0) 165 { 166 breakpointsPerFile.add( iLineNum ); 175 167 return; 176 168 } 177 169 } 178 170 179 if(i==num){ 180 ppItem=(CFileBreakPoint **)HeapReAlloc(hHeap,0,ppItem,(num+1)*sizeof(CFileBreakPoint *)); 181 ppItem[num]=new CFileBreakPoint(lpszFileName,iLineNum); 182 num++; 183 } 184 } 185 void CDBBreakPoint::remove(char *lpszFileName,int iLineNum){ 186 int i; 187 for(i=0;i<num;i++){ 188 if(lstrcmpi(lpszFileName,ppItem[i]->lpszFileName)==0){ 189 ppItem[i]->remove(iLineNum); 190 break; 191 } 192 } 193 if(i==num) return; 194 195 if(ppItem[i]->num==0){ 196 delete ppItem[i]; 197 198 num--; 199 for(;i<num;i++){ 200 ppItem[i]=ppItem[i+1]; 201 } 202 } 203 } 204 205 char *CDBBreakPoint::update(char *nativeCodeBuffer,int SizeOf_CodeSection){ 171 this->breakpointsPerFiles.push_back( BreakPointsPerFile( lpszFileName, iLineNum ) ); 172 } 173 void BreakPointManager::remove(char *lpszFileName,int iLineNum) 174 { 175 for( int i=0; i<static_cast<int>(this->breakpointsPerFiles.size()); i++ ) 176 { 177 BreakPointsPerFile *pBreakpointsPerFile = &breakpointsPerFiles[i]; 178 if(lstrcmpi(pBreakpointsPerFile->filename.c_str(),lpszFileName)==0) 179 { 180 pBreakpointsPerFile->remove( iLineNum ); 181 if( pBreakpointsPerFile->lines.empty() ) 182 { 183 Jenga::Common::EraseVectorItem<BreakPointsPerFiles>( this->breakpointsPerFiles, i ); 184 } 185 break; 186 } 187 } 188 } 189 190 char *BreakPointManager::update(char *nativeCodeBuffer,int SizeOf_CodeSection){ 206 191 char *buffer; 207 192 buffer=(char *)HeapAlloc(hHeap,0,SizeOf_CodeSection); 208 193 memcpy(buffer,nativeCodeBuffer,SizeOf_CodeSection); 209 194 210 int i;211 for(i=0;i<num;i++){212 ppItem[i]->update(buffer);195 BOOST_FOREACH( BreakPointsPerFile &breakpointsPerFile, breakpointsPerFiles ) 196 { 197 breakpointsPerFile.update( buffer ); 213 198 } 214 199
Note:
See TracChangeset
for help on using the changeset viewer.