[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[4] | 3 | //////////////////////////
|
---|
| 4 | // ブレークポイント
|
---|
| 5 | //////////////////////////
|
---|
| 6 |
|
---|
[648] | 7 | BreakPointManager *pobj_DBBreakPoint;
|
---|
[4] | 8 |
|
---|
[725] | 9 | BreakPointsPerFile::BreakPointsPerFile(const char *lpszFileName,int iLineNum){
|
---|
[648] | 10 | this->filename = lpszFileName;
|
---|
[4] | 11 |
|
---|
[648] | 12 | lines.clear();
|
---|
| 13 | lines.push_back( iLineNum );
|
---|
[4] | 14 | }
|
---|
[648] | 15 | void BreakPointsPerFile::add(int iLineNum){
|
---|
| 16 | lines.push_back( iLineNum );
|
---|
[4] | 17 | }
|
---|
[648] | 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 | }
|
---|
[4] | 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
[648] | 30 | void BreakPointsPerFile::update(char *nativeCodeBuffer)
|
---|
[280] | 31 | {
|
---|
[4] | 32 | int FileNum;
|
---|
[280] | 33 | const IncludedFilesRelation *pIncludedFilesRelation = NULL;
|
---|
[313] | 34 | const BasicSource *pNowSource = NULL;
|
---|
[648] | 35 |
|
---|
| 36 | extern BasicSources sourcesLinkRelationalObjectModule;
|
---|
| 37 | BOOST_FOREACH( const BasicSource &source, sourcesLinkRelationalObjectModule )
|
---|
[280] | 38 | {
|
---|
[648] | 39 | pIncludedFilesRelation = &source.GetIncludedFilesRelation();
|
---|
[280] | 40 |
|
---|
| 41 | for(FileNum=0;FileNum<pIncludedFilesRelation->GetFileCounts();FileNum++)
|
---|
| 42 | {
|
---|
[648] | 43 | if(lstrcmpi(pIncludedFilesRelation->GetFilePathFromFileNumber(FileNum).c_str(),this->filename.c_str())==0)
|
---|
[313] | 44 | {
|
---|
[648] | 45 | pNowSource = &source;
|
---|
[313] | 46 | break;
|
---|
| 47 | }
|
---|
[280] | 48 | }
|
---|
| 49 | if( FileNum == pIncludedFilesRelation->GetFileCounts() )
|
---|
| 50 | {
|
---|
| 51 | pIncludedFilesRelation = NULL;
|
---|
| 52 | }
|
---|
| 53 | else
|
---|
| 54 | {
|
---|
| 55 | break;
|
---|
| 56 | }
|
---|
[4] | 57 | }
|
---|
[280] | 58 |
|
---|
| 59 | if( !pIncludedFilesRelation )
|
---|
[279] | 60 | {
|
---|
[648] | 61 | Jenga::Throw( "BreakPointsPerFile::update内で不正な処理" );
|
---|
[279] | 62 | return;
|
---|
| 63 | }
|
---|
[4] | 64 |
|
---|
| 65 | int i;
|
---|
| 66 | for(i=0;;i++){
|
---|
[280] | 67 | if( pIncludedFilesRelation->GetFileNumber( i ) == FileNum
|
---|
| 68 | || pIncludedFilesRelation->GetFileNumber( i ) == -1 )
|
---|
[279] | 69 | {
|
---|
| 70 | break;
|
---|
| 71 | }
|
---|
[4] | 72 | }
|
---|
[280] | 73 | if( pIncludedFilesRelation->GetFileNumber( i ) == -1 )
|
---|
[279] | 74 | {
|
---|
| 75 | return;
|
---|
| 76 | }
|
---|
[4] | 77 |
|
---|
| 78 | int FileBaseLine;
|
---|
| 79 | FileBaseLine=i;
|
---|
| 80 |
|
---|
| 81 | int i2,nCount=0;
|
---|
| 82 | for(i2=0;;i2++){
|
---|
[280] | 83 | if( pIncludedFilesRelation->GetFileNumber( FileBaseLine+i2 ) == -1 )
|
---|
[279] | 84 | {
|
---|
[4] | 85 | //ソースコードの終端行
|
---|
| 86 | break;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[648] | 89 | if(i2==this->lines[nCount]){
|
---|
[263] | 90 | extern SourceLines oldSourceLines;
|
---|
[4] | 91 |
|
---|
| 92 | loop:
|
---|
[313] | 93 | int tempCp = GetSourceCodeIndexFromLine( pNowSource->GetBuffer(), FileBaseLine+i2 );
|
---|
[4] | 94 |
|
---|
| 95 | int i3;
|
---|
[263] | 96 | for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){
|
---|
[637] | 97 | if(oldSourceLines[i3].GetSourceCodePosition().GetPos()==tempCp) break;
|
---|
[4] | 98 | }
|
---|
[263] | 99 | if(i3==oldSourceLines.size()-1){
|
---|
[4] | 100 | i2--;
|
---|
| 101 | goto loop;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[263] | 104 | nativeCodeBuffer[oldSourceLines[i3].GetNativeCodePos()]=(char)0xCC;
|
---|
[4] | 105 |
|
---|
| 106 | nCount++;
|
---|
[648] | 107 | if( nCount >= static_cast<int>(this->lines.size()) )
|
---|
| 108 | {
|
---|
| 109 | break;
|
---|
| 110 | }
|
---|
[4] | 111 | }
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
[648] | 116 | BreakPointManager::BreakPointManager()
|
---|
| 117 | {
|
---|
[4] | 118 | char *buffer;
|
---|
| 119 | buffer=(char *)HeapAlloc(hHeap,0,65535);
|
---|
| 120 |
|
---|
[719] | 121 | char temporary[MAX_PATH];
|
---|
| 122 | GetTempPath(MAX_PATH,temporary);
|
---|
| 123 | if(temporary[lstrlen(temporary)-1]!='\\') lstrcat(temporary,"\\");
|
---|
| 124 | lstrcat(temporary,"ab_breakpoint.tmp");
|
---|
| 125 |
|
---|
[165] | 126 | HANDLE hFile=CreateFile(
|
---|
[719] | 127 | temporary,
|
---|
[165] | 128 | GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
---|
[648] | 129 | if(hFile!=INVALID_HANDLE_VALUE)
|
---|
| 130 | {
|
---|
[4] | 131 | DWORD dwAccBytes;
|
---|
| 132 | ReadFile(hFile,buffer,MAX_PATH,&dwAccBytes,NULL);
|
---|
| 133 | CloseHandle(hFile);
|
---|
| 134 | buffer[dwAccBytes]=0;
|
---|
| 135 | }
|
---|
[648] | 136 | else
|
---|
| 137 | {
|
---|
| 138 | buffer[0]=0;
|
---|
| 139 | }
|
---|
[4] | 140 |
|
---|
| 141 | int i=0,i2;
|
---|
| 142 | char szFilePath[MAX_PATH];
|
---|
| 143 | while(buffer[i]){
|
---|
| 144 | //ファイルパス
|
---|
| 145 | i=GetOneParameter(buffer,i,szFilePath);
|
---|
| 146 | RemoveStringQuotes(szFilePath);
|
---|
| 147 |
|
---|
| 148 | while(buffer[i]!='\n'&&buffer[i]!='\0'){
|
---|
| 149 | //行番号
|
---|
[165] | 150 | char temporary[1024];
|
---|
[4] | 151 | i=GetOneParameter(buffer,i,temporary);
|
---|
| 152 | i2=atoi(temporary);
|
---|
| 153 |
|
---|
| 154 | insert(szFilePath,i2);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | while(buffer[i]=='\n') i++;
|
---|
| 158 |
|
---|
| 159 | if(buffer[i]=='\0') break;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | HeapDefaultFree(buffer);
|
---|
| 163 | }
|
---|
[725] | 164 | void BreakPointManager::insert(const char *lpszFileName,int iLineNum)
|
---|
[648] | 165 | {
|
---|
| 166 | BOOST_FOREACH( BreakPointsPerFile &breakpointsPerFile, breakpointsPerFiles )
|
---|
| 167 | {
|
---|
| 168 | if(lstrcmpi(breakpointsPerFile.filename.c_str(),lpszFileName)==0)
|
---|
| 169 | {
|
---|
| 170 | breakpointsPerFile.add( iLineNum );
|
---|
[4] | 171 | return;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[648] | 175 | this->breakpointsPerFiles.push_back( BreakPointsPerFile( lpszFileName, iLineNum ) );
|
---|
[4] | 176 | }
|
---|
[725] | 177 | void BreakPointManager::remove(const char *lpszFileName,int iLineNum)
|
---|
[648] | 178 | {
|
---|
| 179 | for( int i=0; i<static_cast<int>(this->breakpointsPerFiles.size()); i++ )
|
---|
| 180 | {
|
---|
| 181 | BreakPointsPerFile *pBreakpointsPerFile = &breakpointsPerFiles[i];
|
---|
| 182 | if(lstrcmpi(pBreakpointsPerFile->filename.c_str(),lpszFileName)==0)
|
---|
| 183 | {
|
---|
| 184 | pBreakpointsPerFile->remove( iLineNum );
|
---|
| 185 | if( pBreakpointsPerFile->lines.empty() )
|
---|
| 186 | {
|
---|
| 187 | Jenga::Common::EraseVectorItem<BreakPointsPerFiles>( this->breakpointsPerFiles, i );
|
---|
| 188 | }
|
---|
[4] | 189 | break;
|
---|
| 190 | }
|
---|
| 191 | }
|
---|
| 192 | }
|
---|
| 193 |
|
---|
[648] | 194 | char *BreakPointManager::update(char *nativeCodeBuffer,int SizeOf_CodeSection){
|
---|
[4] | 195 | char *buffer;
|
---|
| 196 | buffer=(char *)HeapAlloc(hHeap,0,SizeOf_CodeSection);
|
---|
[256] | 197 | memcpy(buffer,nativeCodeBuffer,SizeOf_CodeSection);
|
---|
[4] | 198 |
|
---|
[648] | 199 | BOOST_FOREACH( BreakPointsPerFile &breakpointsPerFile, breakpointsPerFiles )
|
---|
| 200 | {
|
---|
| 201 | breakpointsPerFile.update( buffer );
|
---|
[4] | 202 | }
|
---|
| 203 |
|
---|
| 204 | return buffer;
|
---|
| 205 | }
|
---|