[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[182] | 3 | #include <jenga/include/smoothie/Smoothie.h>
|
---|
| 4 |
|
---|
[193] | 5 | #include <Compiler.h>
|
---|
[206] | 6 | #include <Class.h>
|
---|
| 7 | #include <Variable.h>
|
---|
[182] | 8 |
|
---|
[4] | 9 | #include "../BasicCompiler_Common/common.h"
|
---|
[206] | 10 | #include "../BasicCompiler_Common/DebugSection.h"
|
---|
[4] | 11 |
|
---|
| 12 | #ifdef _AMD64_
|
---|
| 13 | #include "../BasicCompiler64/opcode.h"
|
---|
| 14 | #else
|
---|
[5] | 15 | #include "../BasicCompiler32/opcode.h"
|
---|
[4] | 16 | #endif
|
---|
| 17 |
|
---|
| 18 | #define MDLFILE_VER 0x70000003
|
---|
| 19 |
|
---|
| 20 |
|
---|
[75] | 21 | void SetLpIndex_DebugFile(char *buffer,int *p,const Type &type){
|
---|
| 22 | if(NATURAL_TYPE(type.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(type.GetBasicType())==DEF_STRUCT){
|
---|
[131] | 23 | lstrcpy(buffer+(*p),type.GetClass().GetName().c_str());
|
---|
[4] | 24 | (*p)+=lstrlen(buffer+(*p))+1;
|
---|
| 25 | }
|
---|
| 26 | else{
|
---|
[75] | 27 | *(LONG_PTR *)(buffer+(*p))=type.GetIndex();
|
---|
[4] | 28 | (*p)+=sizeof(LONG_PTR);
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 |
|
---|
[75] | 33 | void GetLpIndex_DebugFile(char *buffer,int *p,Type &type){
|
---|
| 34 | if(NATURAL_TYPE(type.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(type.GetBasicType())==DEF_STRUCT){
|
---|
[4] | 35 | char szClassName[VN_SIZE];
|
---|
| 36 | lstrcpy(szClassName,buffer+(*p));
|
---|
| 37 | (*p)+=lstrlen(buffer+(*p))+1;
|
---|
| 38 |
|
---|
[256] | 39 | type.SetClassPtr( compiler.objectModule.meta.GetClasses().Find(szClassName) );
|
---|
[4] | 40 | }
|
---|
| 41 | else{
|
---|
[75] | 42 | type.SetIndex( *(LONG_PTR *)(buffer+(*p)) );
|
---|
[4] | 43 | (*p)+=sizeof(LONG_PTR);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | CDebugSection::~CDebugSection(){
|
---|
| 50 | if(pobj_DBClass) DeleteDebugInfo();
|
---|
| 51 | if(buffer){
|
---|
| 52 | HeapDefaultFree(buffer);
|
---|
| 53 | buffer=0;
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 | void CDebugSection::make(void){
|
---|
| 57 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
[206] | 58 | int i2,i3,BufferSize;
|
---|
[4] | 59 |
|
---|
| 60 | if(buffer){
|
---|
| 61 | HeapDefaultFree(buffer);
|
---|
| 62 | buffer=0;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | i2=0;
|
---|
| 66 |
|
---|
| 67 | extern char *basbuf;
|
---|
| 68 | BufferSize=lstrlen(basbuf)+65535;
|
---|
| 69 | buffer=(char *)HeapAlloc(hHeap,0,BufferSize);
|
---|
| 70 |
|
---|
| 71 | //デバッグ用ファイルのバージョン
|
---|
| 72 | *(long *)(buffer+i2)=MDLFILE_VER;
|
---|
| 73 | i2+=sizeof(long);
|
---|
| 74 |
|
---|
| 75 | //プラットフォームのビット数
|
---|
| 76 | *(long *)(buffer+i2)=PLATFORM;
|
---|
| 77 | i2+=sizeof(long);
|
---|
| 78 |
|
---|
| 79 | //インクルード情報
|
---|
| 80 | *(long *)(buffer+i2)=IncludeFileInfo.FilesNum;
|
---|
| 81 | i2+=sizeof(long);
|
---|
| 82 | for(i3=0;i3<IncludeFileInfo.FilesNum;i3++){
|
---|
| 83 | lstrcpy(buffer+i2,IncludeFileInfo.ppFileNames[i3]);
|
---|
| 84 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 85 | }
|
---|
| 86 | buffer[i2++]=0;
|
---|
| 87 | for(i3=0;;i3++){
|
---|
| 88 | buffer[i2++]=(char)IncludeFileInfo.LineOfFile[i3];
|
---|
| 89 | if(IncludeFileInfo.LineOfFile[i3]==-1) break;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | //ソースコード
|
---|
| 93 | lstrcpy(buffer+i2,basbuf);
|
---|
| 94 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | ////////////////////////
|
---|
| 98 | // コードと行番号の関係
|
---|
| 99 | ////////////////////////
|
---|
[263] | 100 | extern SourceLines oldSourceLines;
|
---|
[4] | 101 |
|
---|
[263] | 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 | }
|
---|
[4] | 123 | }
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | ////////////////////////////////////////////
|
---|
| 128 | // クラス情報(名前のみ。詳細は後で保存)
|
---|
| 129 | ////////////////////////////////////////////
|
---|
| 130 |
|
---|
| 131 | //イテレータをリセット
|
---|
[256] | 132 | compiler.objectModule.meta.GetClasses().Iterator_Reset();
|
---|
[4] | 133 |
|
---|
| 134 | //個数
|
---|
[256] | 135 | *(long *)(buffer+i2)=compiler.objectModule.meta.GetClasses().Iterator_GetMaxCount();
|
---|
[4] | 136 | i2+=sizeof(long);
|
---|
| 137 |
|
---|
[256] | 138 | while(compiler.objectModule.meta.GetClasses().Iterator_HasNext()){
|
---|
[4] | 139 | CClass *pobj_c;
|
---|
[256] | 140 | pobj_c=compiler.objectModule.meta.GetClasses().Iterator_GetNext();
|
---|
[4] | 141 |
|
---|
| 142 | //クラス名
|
---|
[131] | 143 | lstrcpy(buffer+i2,pobj_c->GetName().c_str());
|
---|
[4] | 144 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | //////////////////
|
---|
| 150 | // TypeDef情報
|
---|
| 151 | //////////////////
|
---|
[256] | 152 | *(long *)(buffer+i2)=(int)compiler.objectModule.meta.GetTypeDefs().size();
|
---|
[4] | 153 | i2+=sizeof(long);
|
---|
[256] | 154 | for(i3=0;i3<(int)compiler.objectModule.meta.GetTypeDefs().size();i3++){
|
---|
| 155 | lstrcpy(buffer+i2,compiler.objectModule.meta.GetTypeDefs()[i3].GetName().c_str() );
|
---|
[4] | 156 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 157 |
|
---|
[256] | 158 | lstrcpy(buffer+i2,compiler.objectModule.meta.GetTypeDefs()[i3].GetBaseName().c_str() );
|
---|
[4] | 159 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 160 |
|
---|
| 161 | //バッファが足りない場合は再確保
|
---|
| 162 | if(BufferSize<i2+32768){
|
---|
| 163 | BufferSize+=32768;
|
---|
| 164 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | //グローバル変数情報
|
---|
[256] | 170 | *(long *)(buffer+i2)=(int)compiler.objectModule.meta.GetGlobalVars().size();
|
---|
[4] | 171 | i2+=sizeof(long);
|
---|
[256] | 172 | BOOST_FOREACH( Variable *pVar, compiler.objectModule.meta.GetGlobalVars() ){
|
---|
[4] | 173 | //変数名
|
---|
[75] | 174 | lstrcpy(buffer+i2,pVar->GetName().c_str());
|
---|
[4] | 175 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 176 |
|
---|
| 177 | //型
|
---|
[206] | 178 | *(long *)(buffer+i2)=pVar->GetType().GetBasicType();
|
---|
[4] | 179 | i2+=sizeof(long);
|
---|
| 180 |
|
---|
| 181 | //型の拡張情報
|
---|
[206] | 182 | SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
|
---|
[4] | 183 |
|
---|
[75] | 184 | buffer[i2++] = pVar->IsRef() ? 1 : 0;
|
---|
[4] | 185 |
|
---|
[75] | 186 | buffer[i2++] = pVar->IsArray() ? 1 : 0;
|
---|
[4] | 187 |
|
---|
[75] | 188 | if(pVar->IsArray()){
|
---|
[206] | 189 | *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
|
---|
| 190 | i2+=sizeof(long);
|
---|
| 191 | BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
|
---|
| 192 | {
|
---|
| 193 | *(long *)(buffer+i2)=indexMax;
|
---|
[4] | 194 | i2+=sizeof(long);
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | //レキシカルスコープ情報
|
---|
[206] | 199 | *(long *)(buffer+i2)=pVar->GetScopeStartAddress();
|
---|
[4] | 200 | i2+=sizeof(long);
|
---|
[206] | 201 | *(long *)(buffer+i2)=pVar->GetScopeEndAddress();
|
---|
[4] | 202 | i2+=sizeof(long);
|
---|
[206] | 203 | *(long *)(buffer+i2)=pVar->GetScopeLevel();
|
---|
[4] | 204 | i2+=sizeof(long);
|
---|
| 205 |
|
---|
| 206 | //メモリ位置
|
---|
[206] | 207 | *(long *)(buffer+i2)=pVar->GetOffsetAddress();
|
---|
[4] | 208 | i2+=sizeof(long);
|
---|
| 209 |
|
---|
| 210 | //バッファが足りない場合は再確保
|
---|
| 211 | if(BufferSize<i2+32768){
|
---|
| 212 | BufferSize+=32768;
|
---|
| 213 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | //グローバル実行領域のサイズ
|
---|
| 218 | extern int GlobalOpBufferSize;
|
---|
| 219 | *(long *)(buffer+i2)=GlobalOpBufferSize;
|
---|
| 220 | i2+=sizeof(long);
|
---|
| 221 |
|
---|
| 222 | //プロシージャ情報
|
---|
[256] | 223 | *(long *)(buffer+i2) = compiler.objectModule.meta.GetUserProcs().Iterator_GetMaxCount();
|
---|
[4] | 224 | i2+=sizeof(long);
|
---|
[256] | 225 | compiler.objectModule.meta.GetUserProcs().Iterator_Reset();
|
---|
| 226 | while( compiler.objectModule.meta.GetUserProcs().Iterator_HasNext() )
|
---|
[206] | 227 | {
|
---|
[256] | 228 | UserProc *pUserProc = compiler.objectModule.meta.GetUserProcs().Iterator_GetNext();
|
---|
[4] | 229 |
|
---|
[206] | 230 | if(pUserProc->GetParentClassPtr()){
|
---|
| 231 | lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->GetName().c_str());
|
---|
[4] | 232 | i2+=lstrlen(buffer+i2)+1;
|
---|
[206] | 233 | }
|
---|
| 234 | else{
|
---|
| 235 | lstrcpy(buffer+i2,"");
|
---|
| 236 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 237 | }
|
---|
[4] | 238 |
|
---|
[206] | 239 | //ID
|
---|
| 240 | *(long *)(buffer+i2)=pUserProc->GetId();
|
---|
| 241 | i2+=sizeof(long);
|
---|
[4] | 242 |
|
---|
[206] | 243 | //関数名
|
---|
| 244 | lstrcpy(buffer+i2,pUserProc->GetName().c_str());
|
---|
| 245 | i2+=lstrlen(buffer+i2)+1;
|
---|
[4] | 246 |
|
---|
[259] | 247 | *(long *)(buffer+i2)=pUserProc->_beginOpAddressOld;
|
---|
[206] | 248 | i2+=sizeof(long);
|
---|
[259] | 249 | *(long *)(buffer+i2)=pUserProc->_endOpAddressOld;
|
---|
[206] | 250 | i2+=sizeof(long);
|
---|
[4] | 251 |
|
---|
[206] | 252 | //ローカル変数情報
|
---|
| 253 | *(long *)(buffer+i2)=(int)pUserProc->GetLocalVars().size();
|
---|
| 254 | i2+=sizeof(long);
|
---|
[4] | 255 |
|
---|
[206] | 256 | //バッファが足りない場合は再確保
|
---|
| 257 | if(BufferSize<i2+32768){
|
---|
| 258 | BufferSize+=32768;
|
---|
| 259 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 260 | }
|
---|
[4] | 261 |
|
---|
[206] | 262 | BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){
|
---|
| 263 | lstrcpy(buffer+i2,pVar->GetName().c_str());
|
---|
| 264 | i2+=lstrlen(buffer+i2)+1;
|
---|
[4] | 265 |
|
---|
[206] | 266 | //型
|
---|
| 267 | *(long *)(buffer+i2)=pVar->GetType().GetBasicType();
|
---|
| 268 | i2+=sizeof(long);
|
---|
[4] | 269 |
|
---|
[206] | 270 | //型の拡張情報
|
---|
| 271 | SetLpIndex_DebugFile(buffer,&i2,pVar->GetType());
|
---|
[4] | 272 |
|
---|
[206] | 273 | //参照型パラメータかどうか
|
---|
| 274 | buffer[i2++] = pVar->IsRef() ? 1 : 0;
|
---|
[4] | 275 |
|
---|
[206] | 276 | //配列かどうか
|
---|
| 277 | buffer[i2++] = pVar->IsArray() ? 1 : 0;
|
---|
[4] | 278 |
|
---|
[206] | 279 | //配列要素
|
---|
| 280 | if(pVar->IsArray()){
|
---|
| 281 | *(long *)(buffer+i2)=(int)pVar->GetSubscripts().size();
|
---|
[4] | 282 | i2+=sizeof(long);
|
---|
[206] | 283 | BOOST_FOREACH( int indexMax, pVar->GetSubscripts() )
|
---|
| 284 | {
|
---|
| 285 | *(long *)(buffer+i2)=indexMax;
|
---|
| 286 | i2+=sizeof(long);
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
[4] | 289 |
|
---|
[206] | 290 | //レキシカルスコープ情報
|
---|
| 291 | *(long *)(buffer+i2)=pVar->GetScopeStartAddress();
|
---|
| 292 | i2+=sizeof(long);
|
---|
| 293 | *(long *)(buffer+i2)=pVar->GetScopeEndAddress();
|
---|
| 294 | i2+=sizeof(long);
|
---|
| 295 | *(long *)(buffer+i2)=pVar->GetScopeLevel();
|
---|
| 296 | i2+=sizeof(long);
|
---|
[4] | 297 |
|
---|
[206] | 298 | //メモリ位置
|
---|
| 299 | *(long *)(buffer+i2)=pVar->GetOffsetAddress();
|
---|
| 300 | i2+=sizeof(long);
|
---|
[4] | 301 |
|
---|
| 302 |
|
---|
[206] | 303 |
|
---|
| 304 |
|
---|
| 305 | //バッファが足りない場合は再確保
|
---|
| 306 | if(BufferSize<i2+32768){
|
---|
| 307 | BufferSize+=32768;
|
---|
| 308 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
[4] | 309 | }
|
---|
| 310 | }
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | ///////////////////
|
---|
| 316 | // クラス情報
|
---|
| 317 | ///////////////////
|
---|
| 318 |
|
---|
| 319 | //イテレータをリセット
|
---|
[256] | 320 | compiler.objectModule.meta.GetClasses().Iterator_Reset();
|
---|
[4] | 321 |
|
---|
[256] | 322 | while(compiler.objectModule.meta.GetClasses().Iterator_HasNext()){
|
---|
[4] | 323 | CClass *pobj_c;
|
---|
[256] | 324 | pobj_c=compiler.objectModule.meta.GetClasses().Iterator_GetNext();
|
---|
[4] | 325 |
|
---|
| 326 |
|
---|
| 327 | //クラス名
|
---|
[131] | 328 | lstrcpy(buffer+i2,pobj_c->GetName().c_str());
|
---|
[4] | 329 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 330 |
|
---|
| 331 | //仮想関数の数
|
---|
[141] | 332 | *(long *)(buffer+i2)=pobj_c->GetVtblNum();
|
---|
[4] | 333 | i2+=sizeof(long);
|
---|
| 334 |
|
---|
| 335 | //アラインメント
|
---|
[232] | 336 | *(long *)(buffer+i2)=pobj_c->GetFixedAlignment();
|
---|
[4] | 337 | i2+=sizeof(long);
|
---|
| 338 |
|
---|
[206] | 339 | // 動的メンバ
|
---|
[182] | 340 | *(long *)(buffer+i2)=(int)pobj_c->GetDynamicMembers().size();
|
---|
[4] | 341 | i2+=sizeof(long);
|
---|
[182] | 342 | BOOST_FOREACH( CMember *member, pobj_c->GetDynamicMembers() ){
|
---|
[137] | 343 | // 名前
|
---|
[140] | 344 | lstrcpy(buffer+i2,member->GetName().c_str());
|
---|
[4] | 345 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 346 |
|
---|
[137] | 347 | // 型
|
---|
[140] | 348 | *(long *)(buffer+i2)=member->GetType().GetBasicType();
|
---|
[4] | 349 | i2+=sizeof(long);
|
---|
| 350 |
|
---|
[137] | 351 | // 型の拡張情報
|
---|
[140] | 352 | SetLpIndex_DebugFile(buffer,&i2,member->GetType());
|
---|
[4] | 353 |
|
---|
[137] | 354 | // アクセシビリティ
|
---|
[140] | 355 | *(Prototype::Accessibility *)(buffer+i2)=member->GetAccessibility();
|
---|
[137] | 356 | i2+=sizeof(Prototype::Accessibility);
|
---|
[4] | 357 |
|
---|
[206] | 358 | *(long *)(buffer+i2)=(int)member->GetSubscripts().size();
|
---|
| 359 | i2+=sizeof(long);
|
---|
| 360 | BOOST_FOREACH( int indexMax, member->GetSubscripts() )
|
---|
| 361 | {
|
---|
| 362 | *(long *)(buffer+i2)=indexMax;
|
---|
| 363 | i2+=sizeof(long);
|
---|
| 364 | }
|
---|
[137] | 365 |
|
---|
[4] | 366 | //バッファが足りない場合は再確保
|
---|
| 367 | if(BufferSize<i2+32768){
|
---|
| 368 | BufferSize+=32768;
|
---|
| 369 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[206] | 373 | // 動的メソッド
|
---|
[182] | 374 | *(long *)(buffer+i2)=(long)pobj_c->GetMethods().size();
|
---|
[4] | 375 | i2+=sizeof(long);
|
---|
[182] | 376 | BOOST_FOREACH( const CMethod *pMethod, pobj_c->GetMethods() ){
|
---|
[137] | 377 | *(Prototype::Accessibility *)(buffer+i2)=pMethod->GetAccessibility();
|
---|
| 378 | i2+=sizeof(Prototype::Accessibility);
|
---|
[135] | 379 | if( pMethod->GetInheritsClassPtr() ){
|
---|
| 380 | lstrcpy(buffer+i2,pMethod->GetInheritsClassPtr()->GetName().c_str());
|
---|
[4] | 381 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 382 | }
|
---|
| 383 | else{
|
---|
| 384 | lstrcpy(buffer+i2,"");
|
---|
| 385 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 386 | }
|
---|
[206] | 387 | lstrcpy(buffer+i2,pMethod->GetUserProc().GetName().c_str());
|
---|
[4] | 388 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 389 | }
|
---|
| 390 |
|
---|
| 391 | //静的メンバ
|
---|
[182] | 392 | *(long *)(buffer+i2)=(long)pobj_c->GetStaticMembers().size();
|
---|
[4] | 393 | i2+=sizeof(long);
|
---|
[182] | 394 | BOOST_FOREACH( CMember *member, pobj_c->GetStaticMembers() ){
|
---|
[137] | 395 | // 名前
|
---|
[135] | 396 | lstrcpy(buffer+i2,member->GetName().c_str());
|
---|
[4] | 397 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 398 |
|
---|
[137] | 399 | // 型
|
---|
| 400 | *(long *)(buffer+i2)=member->GetType().GetBasicType();
|
---|
[4] | 401 | i2+=sizeof(long);
|
---|
| 402 |
|
---|
[137] | 403 | // 型の拡張情報
|
---|
| 404 | SetLpIndex_DebugFile(buffer,&i2,member->GetType());
|
---|
[4] | 405 |
|
---|
[137] | 406 | // アクセシビリティ
|
---|
| 407 | *(Prototype::Accessibility *)(buffer+i2)=member->GetAccessibility();
|
---|
| 408 | i2+=sizeof(Prototype::Accessibility);
|
---|
[4] | 409 |
|
---|
[206] | 410 | // 配列
|
---|
| 411 | *(long *)(buffer+i2)=(int)member->GetSubscripts().size();
|
---|
| 412 | i2+=sizeof(long);
|
---|
| 413 | BOOST_FOREACH( int indexMax, member->GetSubscripts() )
|
---|
| 414 | {
|
---|
| 415 | *(long *)(buffer+i2)=indexMax;
|
---|
| 416 | i2+=sizeof(long);
|
---|
| 417 | }
|
---|
[137] | 418 |
|
---|
[4] | 419 | //バッファが足りない場合は再確保
|
---|
| 420 | if(BufferSize<i2+32768){
|
---|
| 421 | BufferSize+=32768;
|
---|
| 422 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | //バッファが足りない場合は再確保
|
---|
| 427 | if(BufferSize<i2+32768){
|
---|
| 428 | BufferSize+=32768;
|
---|
| 429 | buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
|
---|
| 430 | }
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | length=i2;
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | char *CDebugSection::MakeSingleStepCode(void){
|
---|
| 437 | char *buffer;
|
---|
| 438 | buffer=(char *)HeapAlloc(hHeap,0,SizeOf_CodeSection);
|
---|
| 439 |
|
---|
| 440 | memcpy(buffer,OpBuffer,SizeOf_CodeSection);
|
---|
| 441 |
|
---|
[263] | 442 | BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines )
|
---|
| 443 | {
|
---|
[4] | 444 | if(!(
|
---|
[263] | 445 | sourceLine.IsInSystemProc()
|
---|
| 446 | || sourceLine.IsInDebugProc() ) )
|
---|
| 447 | {
|
---|
[4] | 448 | //int 3
|
---|
[263] | 449 | buffer[sourceLine.GetNativeCodePos()]=(char)0xCC;
|
---|
[4] | 450 | }
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 | return buffer;
|
---|
| 454 | }
|
---|
| 455 | BOOL CDebugSection::__load(void){
|
---|
[206] | 456 | int i2,i3,i4,num;
|
---|
[4] | 457 | char temp2[MAX_PATH],*temp5;
|
---|
| 458 |
|
---|
[206] | 459 | compiler.pCompilingClass = NULL;
|
---|
[16] | 460 |
|
---|
[4] | 461 | i2=0;
|
---|
| 462 |
|
---|
| 463 | //デバッグ用ファイルのバージョンをチェック
|
---|
| 464 | if(*(long *)(buffer+i2)<MDLFILE_VER){
|
---|
| 465 | HeapDefaultFree(buffer);
|
---|
| 466 | return 0;
|
---|
| 467 | }
|
---|
| 468 | i2+=sizeof(long);
|
---|
| 469 |
|
---|
| 470 | //プラットフォームのビット数をチェック
|
---|
| 471 | if(*(long *)(buffer+i2)!=PLATFORM){
|
---|
| 472 | HeapDefaultFree(buffer);
|
---|
| 473 | return 0;
|
---|
| 474 | }
|
---|
| 475 | i2+=sizeof(long);
|
---|
| 476 |
|
---|
| 477 | //インクルード情報
|
---|
| 478 | IncludeFileInfo.FilesNum=*(long *)(buffer+i2);
|
---|
| 479 | i2+=sizeof(long);
|
---|
[191] | 480 | IncludeFileInfo.ppFileNames=(char **)malloc(IncludeFileInfo.FilesNum*sizeof(char *));
|
---|
[4] | 481 | for(i3=0;i3<IncludeFileInfo.FilesNum;i3++){
|
---|
| 482 | if(buffer[i2]=='\0') break;
|
---|
[191] | 483 | IncludeFileInfo.ppFileNames[i3]=(char *)malloc(lstrlen(buffer+i2)+1);
|
---|
[4] | 484 | lstrcpy(IncludeFileInfo.ppFileNames[i3],buffer+i2);
|
---|
| 485 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 486 | }
|
---|
| 487 | for(i2++,i3=0;;i2++,i3++){
|
---|
| 488 | IncludeFileInfo.LineOfFile[i3]=(long)buffer[i2];
|
---|
| 489 | if(IncludeFileInfo.LineOfFile[i3]==-1) break;
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | //ソースコード
|
---|
| 493 | i2++;
|
---|
[88] | 494 | source.SetBuffer( buffer + i2 );
|
---|
[15] | 495 | i2+=lstrlen(buffer+i2)+1;
|
---|
[4] | 496 |
|
---|
| 497 | //コードと行番号の関係
|
---|
[263] | 498 | int maxLineInfoNum;
|
---|
| 499 | maxLineInfoNum=*(long *)(buffer+i2);
|
---|
[4] | 500 | i2+=sizeof(long);
|
---|
[263] | 501 | for(i3=0;i3<maxLineInfoNum;i3++){
|
---|
| 502 | int lineNum = *(long *)(buffer+i2);
|
---|
| 503 | i2+=sizeof(long);
|
---|
[4] | 504 |
|
---|
[263] | 505 | int nativeCodePos = *(long *)(buffer+i2);
|
---|
| 506 | i2+=sizeof(long);
|
---|
[4] | 507 |
|
---|
[263] | 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 | }
|
---|
| 516 |
|
---|
| 517 |
|
---|
[4] | 518 | ///////////////////////////////////////////
|
---|
| 519 | // クラス情報(名前のみ。詳細は後で取得)
|
---|
| 520 | ///////////////////////////////////////////
|
---|
| 521 |
|
---|
[206] | 522 | this->pobj_DBClass=new Classes();
|
---|
[4] | 523 |
|
---|
| 524 | int iMaxClassCount;
|
---|
| 525 | iMaxClassCount=*(long *)(buffer+i2);
|
---|
| 526 | i2+=sizeof(long);
|
---|
| 527 | for(i3=0;i3<iMaxClassCount;i3++){
|
---|
| 528 | //クラス名
|
---|
[101] | 529 | // TODO: 名前空間が未完成
|
---|
[182] | 530 | this->pobj_DBClass->Add(NamespaceScopes(),NamespaceScopesCollection(),buffer+i2,0);
|
---|
[4] | 531 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 532 | }
|
---|
| 533 |
|
---|
[256] | 534 | compiler.objectModule.meta.SetClasses( this->pobj_DBClass );
|
---|
[4] | 535 |
|
---|
| 536 |
|
---|
| 537 | //////////////////
|
---|
| 538 | // TypeDef情報
|
---|
| 539 | //////////////////
|
---|
| 540 |
|
---|
| 541 | //初期化
|
---|
[256] | 542 | compiler.objectModule.meta.GetTypeDefs().clear();
|
---|
[4] | 543 |
|
---|
| 544 | //個数を取得
|
---|
| 545 | num=*(long *)(buffer+i2);
|
---|
| 546 | i2+=sizeof(long);
|
---|
| 547 | for(i3=0;i3<num;i3++){
|
---|
| 548 | temp5=buffer+i2;
|
---|
| 549 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 550 |
|
---|
[113] | 551 | // 名前空間に未対応
|
---|
[256] | 552 | compiler.objectModule.meta.GetTypeDefs().push_back( TypeDef( NamespaceScopes(), temp5, buffer+i2, -1 ) );
|
---|
[4] | 553 |
|
---|
| 554 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | //定数を取得
|
---|
| 558 | GetConstInfo();
|
---|
[256] | 559 | this->globalConsts = compiler.objectModule.meta.GetGlobalConsts();
|
---|
| 560 | this->globalConstMacros = compiler.objectModule.meta.GetGlobalConstMacros();
|
---|
[4] | 561 |
|
---|
| 562 | //グローバル変数情報
|
---|
[256] | 563 | compiler.objectModule.meta.GetGlobalVars().clear();
|
---|
[75] | 564 | int maxGlobalVars=*(long *)(buffer+i2);
|
---|
[4] | 565 | i2+=sizeof(long);
|
---|
[75] | 566 | for(i3=0;i3<maxGlobalVars;i3++){
|
---|
[4] | 567 |
|
---|
| 568 | //変数名
|
---|
[75] | 569 | char *name = buffer+i2;
|
---|
[4] | 570 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 571 |
|
---|
[75] | 572 | int basicType = *(long *)(buffer+i2);
|
---|
[4] | 573 | i2+=sizeof(long);
|
---|
| 574 |
|
---|
[75] | 575 | Type type( basicType );
|
---|
| 576 | GetLpIndex_DebugFile(buffer,&i2,type);
|
---|
[4] | 577 |
|
---|
[75] | 578 | bool isRef = (buffer[i2++]) ? true:false;
|
---|
[4] | 579 |
|
---|
[75] | 580 | bool isArray = (buffer[i2++]) ? true:false;
|
---|
| 581 |
|
---|
[206] | 582 | Variable *pVar = new Variable( name, type, false, isRef, "" );
|
---|
[75] | 583 |
|
---|
| 584 | if(isArray){
|
---|
[206] | 585 | Subscripts subscripts;
|
---|
| 586 | int nSubScriptsNum = *(long *)(buffer+i2);
|
---|
| 587 | i2+=sizeof(long);
|
---|
| 588 | for( int i=0; i<nSubScriptsNum; i++ )
|
---|
| 589 | {
|
---|
| 590 | subscripts.push_back( *(long *)(buffer+i2) );
|
---|
[4] | 591 | i2+=sizeof(long);
|
---|
| 592 | }
|
---|
[75] | 593 |
|
---|
[206] | 594 | pVar->SetArray( subscripts );
|
---|
[4] | 595 | }
|
---|
| 596 |
|
---|
| 597 | //レキシカルスコープ情報
|
---|
[206] | 598 | pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
|
---|
[4] | 599 | i2+=sizeof(long);
|
---|
[206] | 600 | pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
|
---|
[4] | 601 | i2+=sizeof(long);
|
---|
[206] | 602 | pVar->SetScopeLevel( *(long *)(buffer+i2) );
|
---|
[4] | 603 | i2+=sizeof(long);
|
---|
| 604 |
|
---|
| 605 | //メモリ位置
|
---|
[206] | 606 | pVar->SetOffsetAddress( *(long *)(buffer+i2) );
|
---|
[4] | 607 | i2+=sizeof(long);
|
---|
[75] | 608 |
|
---|
| 609 | //変数を追加
|
---|
[256] | 610 | compiler.objectModule.meta.GetGlobalVars().push_back( pVar );
|
---|
[4] | 611 | }
|
---|
| 612 |
|
---|
| 613 | //グローバル実行領域のサイズ
|
---|
| 614 | GlobalOpBufferSize=*(long *)(buffer+i2);
|
---|
| 615 | i2+=sizeof(long);
|
---|
| 616 |
|
---|
| 617 | //プロシージャ情報
|
---|
[206] | 618 | userProcs.Clear();
|
---|
| 619 | int subNum = *(long *)(buffer+i2);
|
---|
[4] | 620 | i2+=sizeof(long);
|
---|
[206] | 621 | for(int i6=0;i6<subNum;i6++){
|
---|
[4] | 622 | char szParentClassName[VN_SIZE];
|
---|
| 623 | lstrcpy(szParentClassName,buffer+i2);
|
---|
| 624 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 625 |
|
---|
[114] | 626 | const CClass *pClass = NULL;
|
---|
| 627 | if(szParentClassName[0]){
|
---|
[256] | 628 | pClass=compiler.objectModule.meta.GetClasses().Find(szParentClassName);
|
---|
[114] | 629 | }
|
---|
[4] | 630 |
|
---|
| 631 | //ID
|
---|
[75] | 632 | int id=*(long *)(buffer+i2);
|
---|
[4] | 633 | i2+=sizeof(long);
|
---|
| 634 |
|
---|
| 635 | //名前
|
---|
[75] | 636 | char *name = buffer+i2;
|
---|
[4] | 637 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 638 |
|
---|
[75] | 639 | // オブジェクトを生成
|
---|
[100] | 640 | // TODO: 名前空間が未完成
|
---|
[206] | 641 | UserProc *pUserProc = new UserProc( NamespaceScopes(), NamespaceScopesCollection(), name, Procedure::Function, false, false, false, id );
|
---|
[75] | 642 | pUserProc->SetParentClass( pClass );
|
---|
| 643 |
|
---|
[259] | 644 | pUserProc->_beginOpAddressOld = *(long *)(buffer+i2);
|
---|
[4] | 645 | i2+=sizeof(long);
|
---|
[259] | 646 | pUserProc->_endOpAddressOld = *(long *)(buffer+i2);
|
---|
[4] | 647 | i2+=sizeof(long);
|
---|
| 648 |
|
---|
[75] | 649 | pUserProc->CompleteCompile();
|
---|
[4] | 650 |
|
---|
| 651 | //ローカル変数情報
|
---|
[206] | 652 | pUserProc->GetLocalVars().clear();
|
---|
[75] | 653 | int maxLocalVar=*(long *)(buffer+i2);
|
---|
[4] | 654 | i2+=sizeof(long);
|
---|
[75] | 655 | for(i3=0;i3<maxLocalVar;i3++){
|
---|
| 656 | //変数名
|
---|
| 657 | char *name = buffer+i2;
|
---|
[4] | 658 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 659 |
|
---|
[75] | 660 | int basicType = *(long *)(buffer+i2);
|
---|
[4] | 661 | i2+=sizeof(long);
|
---|
| 662 |
|
---|
[75] | 663 | Type type( basicType );
|
---|
| 664 | GetLpIndex_DebugFile(buffer,&i2,type);
|
---|
[4] | 665 |
|
---|
[75] | 666 | bool isRef = (buffer[i2++]) ? true:false;
|
---|
[4] | 667 |
|
---|
[75] | 668 | bool isArray = (buffer[i2++]) ? true:false;
|
---|
| 669 |
|
---|
[206] | 670 | Variable *pVar = new Variable( name, type, false, isRef, "" );
|
---|
[75] | 671 |
|
---|
| 672 | if(isArray){
|
---|
[206] | 673 | Subscripts subscripts;
|
---|
| 674 | int nSubScriptsNum = *(long *)(buffer+i2);
|
---|
| 675 | i2+=sizeof(long);
|
---|
| 676 | for( int i=0; i<nSubScriptsNum; i++ )
|
---|
| 677 | {
|
---|
| 678 | subscripts.push_back( *(long *)(buffer+i2) );
|
---|
[4] | 679 | i2+=sizeof(long);
|
---|
| 680 | }
|
---|
[75] | 681 |
|
---|
[206] | 682 | pVar->SetArray( subscripts );
|
---|
[4] | 683 | }
|
---|
| 684 |
|
---|
| 685 | //レキシカルスコープ情報
|
---|
[206] | 686 | pVar->SetScopeStartAddress( *(long *)(buffer+i2) );
|
---|
[4] | 687 | i2+=sizeof(long);
|
---|
[206] | 688 | pVar->SetScopeEndAddress( *(long *)(buffer+i2) );
|
---|
[4] | 689 | i2+=sizeof(long);
|
---|
[206] | 690 | pVar->SetScopeLevel( *(long *)(buffer+i2) );
|
---|
[4] | 691 | i2+=sizeof(long);
|
---|
| 692 |
|
---|
[75] | 693 | //メモリ位置
|
---|
[206] | 694 | pVar->SetOffsetAddress( *(long *)(buffer+i2) );
|
---|
[4] | 695 | i2+=sizeof(long);
|
---|
[75] | 696 |
|
---|
| 697 | //変数を追加
|
---|
[206] | 698 | pUserProc->GetLocalVars().push_back( pVar );
|
---|
[4] | 699 | }
|
---|
| 700 |
|
---|
| 701 |
|
---|
| 702 | /////////////////////////////////
|
---|
[75] | 703 | // 格納位置を計算してpUserProcをセット
|
---|
[4] | 704 | /////////////////////////////////
|
---|
| 705 |
|
---|
[206] | 706 | // ハッシュに追加
|
---|
| 707 | if( !userProcs.Insert( pUserProc, -1 ) )
|
---|
| 708 | {
|
---|
| 709 | //return NULL;
|
---|
[4] | 710 | }
|
---|
| 711 | }
|
---|
[206] | 712 | userProcs.Iterator_Init();
|
---|
[4] | 713 |
|
---|
| 714 | //クラス情報
|
---|
| 715 | CClass *pobj_c;
|
---|
| 716 | for(i3=0;i3<iMaxClassCount;i3++){
|
---|
| 717 | //クラス名
|
---|
| 718 | char szClassName[VN_SIZE];
|
---|
| 719 | lstrcpy(szClassName,buffer+i2);
|
---|
| 720 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 721 |
|
---|
[256] | 722 | pobj_c = const_cast<CClass *>( compiler.objectModule.meta.GetClasses().Find(szClassName) );
|
---|
[4] | 723 |
|
---|
| 724 | //仮想関数の数
|
---|
[141] | 725 | pobj_c->SetVtblNum( *(long *)(buffer+i2) );
|
---|
[4] | 726 | i2+=sizeof(long);
|
---|
| 727 |
|
---|
| 728 | //アラインメント
|
---|
[232] | 729 | pobj_c->SetFixedAlignment( *(long *)(buffer+i2) );
|
---|
[4] | 730 | i2+=sizeof(long);
|
---|
| 731 |
|
---|
[206] | 732 | // 動的メンバ
|
---|
[140] | 733 | int nDynamicMember = *(long *)(buffer+i2);
|
---|
[4] | 734 | i2+=sizeof(long);
|
---|
[140] | 735 | for( i4=0; i4<nDynamicMember; i4++ ){
|
---|
[137] | 736 | // 名前
|
---|
| 737 | string name = (char *)(buffer+i2);
|
---|
[4] | 738 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 739 |
|
---|
[137] | 740 | // 型
|
---|
[75] | 741 | Type type( *(long *)(buffer+i2) );
|
---|
[4] | 742 | i2+=sizeof(long);
|
---|
| 743 |
|
---|
[137] | 744 | // 型の拡張情報
|
---|
[75] | 745 | GetLpIndex_DebugFile(buffer,&i2,type);
|
---|
[4] | 746 |
|
---|
[137] | 747 | // アクセシビリティ
|
---|
| 748 | Prototype::Accessibility accessibility = *(Prototype::Accessibility *)(buffer+i2);
|
---|
| 749 | i2+=sizeof(Prototype::Accessibility);
|
---|
[75] | 750 |
|
---|
[206] | 751 | Subscripts subscripts;
|
---|
| 752 | int nSubScriptsNum = *(long *)(buffer+i2);
|
---|
| 753 | i2+=sizeof(long);
|
---|
| 754 | for( int i=0; i<nSubScriptsNum; i++ )
|
---|
| 755 | {
|
---|
| 756 | subscripts.push_back( *(long *)(buffer+i2) );
|
---|
| 757 | i2+=sizeof(long);
|
---|
| 758 | }
|
---|
[137] | 759 |
|
---|
[206] | 760 | CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
|
---|
[140] | 761 |
|
---|
[182] | 762 | pobj_c->GetDynamicMembers().push_back( member );
|
---|
[4] | 763 | }
|
---|
| 764 |
|
---|
[206] | 765 | // 動的メソッド
|
---|
[51] | 766 | int nMethod = *(long *)(buffer+i2);
|
---|
[4] | 767 | i2+=sizeof(long);
|
---|
[51] | 768 | for( i4=0; i4<nMethod; i4++ ){
|
---|
[4] | 769 |
|
---|
[137] | 770 | Prototype::Accessibility accessibility=*(Prototype::Accessibility *)(buffer+i2);
|
---|
| 771 | i2+=sizeof(Prototype::Accessibility);
|
---|
[4] | 772 |
|
---|
| 773 | char szInherits[VN_SIZE];
|
---|
| 774 | lstrcpy(szInherits,buffer+i2);
|
---|
| 775 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 776 |
|
---|
[114] | 777 | const CClass *pobj_InheritsClass = NULL;
|
---|
[100] | 778 | if(szInherits[0]){
|
---|
[256] | 779 | pobj_InheritsClass=compiler.objectModule.meta.GetClasses().Find(szInherits);
|
---|
[100] | 780 | }
|
---|
[4] | 781 |
|
---|
| 782 | lstrcpy(temp2,buffer+i2);
|
---|
| 783 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 784 |
|
---|
[114] | 785 | const CClass *pobj_temp_c;
|
---|
[100] | 786 | pobj_temp_c=pobj_InheritsClass;
|
---|
[4] | 787 | if(pobj_temp_c==0) pobj_temp_c=pobj_c;
|
---|
[206] | 788 |
|
---|
[256] | 789 | UserProc *pUserProc = compiler.objectModule.meta.GetUserProcs().GetHashArrayElement( temp2 );
|
---|
[206] | 790 | while(pUserProc){
|
---|
| 791 | if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c)
|
---|
| 792 | {
|
---|
| 793 | break;
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | pUserProc=pUserProc->GetChainNext();
|
---|
[4] | 797 | }
|
---|
[51] | 798 |
|
---|
[137] | 799 | CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, 0,0,false, pobj_InheritsClass);
|
---|
[100] | 800 |
|
---|
[182] | 801 | pobj_c->GetMethods().push_back( pMethod );
|
---|
[4] | 802 | }
|
---|
| 803 |
|
---|
| 804 | //静的メンバ
|
---|
[53] | 805 | int nStaticMember = *(long *)(buffer+i2);
|
---|
[4] | 806 | i2+=sizeof(long);
|
---|
[53] | 807 | for( i4=0; i4<nStaticMember; i4++ ){
|
---|
[137] | 808 | // 名前
|
---|
| 809 | string name = (char *)(buffer+i2);
|
---|
[4] | 810 | i2+=lstrlen(buffer+i2)+1;
|
---|
| 811 |
|
---|
[137] | 812 | // 型
|
---|
[75] | 813 | Type type( *(long *)(buffer+i2) );
|
---|
[4] | 814 | i2+=sizeof(long);
|
---|
| 815 |
|
---|
[137] | 816 | // 型の拡張情報
|
---|
[75] | 817 | GetLpIndex_DebugFile(buffer,&i2,type);
|
---|
[4] | 818 |
|
---|
[137] | 819 | // アクセシビリティ
|
---|
| 820 | Prototype::Accessibility accessibility = *(Prototype::Accessibility *)(buffer+i2);
|
---|
| 821 | i2+=sizeof(Prototype::Accessibility);
|
---|
[75] | 822 |
|
---|
[206] | 823 | // 配列
|
---|
| 824 | Subscripts subscripts;
|
---|
| 825 | int nSubScriptsNum = *(long *)(buffer+i2);
|
---|
| 826 | i2+=sizeof(long);
|
---|
| 827 | for( int i=0; i<nSubScriptsNum; i++ )
|
---|
| 828 | {
|
---|
| 829 | subscripts.push_back( *(long *)(buffer+i2) );
|
---|
| 830 | i2+=sizeof(long);
|
---|
| 831 | }
|
---|
[53] | 832 |
|
---|
[206] | 833 | CMember *member=new CMember( accessibility, name, type, false, subscripts, "", "" );
|
---|
[137] | 834 |
|
---|
[182] | 835 | pobj_c->GetStaticMembers().push_back( member );
|
---|
[4] | 836 | }
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 | HeapDefaultFree(buffer);
|
---|
| 840 | buffer=0;
|
---|
| 841 |
|
---|
| 842 |
|
---|
| 843 |
|
---|
| 844 |
|
---|
[256] | 845 | compiler.objectModule.meta.GetUserProcs() = userProcs;
|
---|
[4] | 846 | pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc");
|
---|
| 847 |
|
---|
| 848 |
|
---|
| 849 | SingleStepCodeBuffer=MakeSingleStepCode();
|
---|
| 850 |
|
---|
| 851 |
|
---|
| 852 | /////////////////////////////
|
---|
| 853 | // ブレークポイントを適用
|
---|
| 854 | /////////////////////////////
|
---|
| 855 |
|
---|
| 856 | //インクルード情報
|
---|
| 857 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
| 858 | IncludeFileInfo=this->IncludeFileInfo;
|
---|
| 859 |
|
---|
| 860 | //コードと行番号の関係
|
---|
[263] | 861 | extern SourceLines oldSourceLines;
|
---|
| 862 | oldSourceLines = this->oldSourceLines;
|
---|
[4] | 863 |
|
---|
| 864 | BreakStepCodeBuffer=pobj_DBBreakPoint->update(OpBuffer,SizeOf_CodeSection);
|
---|
| 865 |
|
---|
| 866 | //プロセスメモリにコピー
|
---|
| 867 | extern HANDLE hDebugProcess;
|
---|
[76] | 868 | SIZE_T accessBytes;
|
---|
[4] | 869 | WriteProcessMemory(hDebugProcess,(void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection),
|
---|
| 870 | BreakStepCodeBuffer,
|
---|
[76] | 871 | SizeOf_CodeSection,&accessBytes);
|
---|
[4] | 872 |
|
---|
| 873 |
|
---|
| 874 | return 1;
|
---|
| 875 | }
|
---|
| 876 |
|
---|
| 877 | BOOL CDebugSection::load(HMODULE hModule){
|
---|
| 878 | if(buffer){
|
---|
| 879 | HeapDefaultFree(buffer);
|
---|
| 880 | buffer=0;
|
---|
| 881 | }
|
---|
| 882 |
|
---|
| 883 |
|
---|
| 884 | extern HANDLE hDebugProcess;
|
---|
[76] | 885 | SIZE_T accessBytes;
|
---|
[4] | 886 | IMAGE_DOS_HEADER ImageDosHeader;
|
---|
[76] | 887 | ReadProcessMemory(hDebugProcess,hModule,&ImageDosHeader,sizeof(IMAGE_DOS_HEADER),&accessBytes);
|
---|
[4] | 888 |
|
---|
| 889 | int pe_size;
|
---|
| 890 | #ifdef _AMD64_
|
---|
| 891 | IMAGE_NT_HEADERS64 pe_hdr;
|
---|
| 892 | pe_size=sizeof(IMAGE_NT_HEADERS64);
|
---|
| 893 | #else
|
---|
| 894 | IMAGE_NT_HEADERS pe_hdr;
|
---|
| 895 | pe_size=sizeof(IMAGE_NT_HEADERS);
|
---|
| 896 | #endif
|
---|
[76] | 897 | ReadProcessMemory(hDebugProcess,(void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew),&pe_hdr,pe_size,&accessBytes);
|
---|
[4] | 898 |
|
---|
| 899 | IMAGE_SECTION_HEADER *pSectionHdr;
|
---|
| 900 | pSectionHdr=(IMAGE_SECTION_HEADER *)HeapAlloc(hHeap,0,pe_hdr.FileHeader.NumberOfSections*sizeof(IMAGE_SECTION_HEADER));
|
---|
| 901 | ReadProcessMemory(hDebugProcess,
|
---|
| 902 | (void *)(((ULONG_PTR)hModule)+ImageDosHeader.e_lfanew+pe_size),
|
---|
| 903 | pSectionHdr,
|
---|
| 904 | pe_hdr.FileHeader.NumberOfSections*sizeof(IMAGE_SECTION_HEADER),
|
---|
[76] | 905 | &accessBytes);
|
---|
[4] | 906 |
|
---|
| 907 | int i;
|
---|
| 908 | for(i=0;i<pe_hdr.FileHeader.NumberOfSections;i++){
|
---|
| 909 |
|
---|
| 910 | //リライタブルセクション内の情報
|
---|
| 911 | if(lstrcmp((char *)pSectionHdr[i].Name,".data")==0){
|
---|
| 912 | dwRVA_RWSection=pSectionHdr[i].VirtualAddress;
|
---|
| 913 | }
|
---|
| 914 |
|
---|
| 915 | //コードセクション内の情報
|
---|
| 916 | if(lstrcmp((char *)pSectionHdr[i].Name,".text")==0){
|
---|
| 917 | dwRVA_CodeSection=pSectionHdr[i].VirtualAddress;
|
---|
| 918 | SizeOf_CodeSection=pSectionHdr[i].SizeOfRawData;
|
---|
| 919 | }
|
---|
| 920 |
|
---|
| 921 | //デバッグセクション内の情報
|
---|
| 922 | if(lstrcmp((char *)pSectionHdr[i].Name,".debug")==0){
|
---|
| 923 | length=pSectionHdr[i].Misc.VirtualSize;
|
---|
| 924 | buffer=(char *)HeapAlloc(hHeap,0,length+1);
|
---|
| 925 |
|
---|
| 926 | ReadProcessMemory(hDebugProcess,
|
---|
| 927 | (void *)(((ULONG_PTR)hModule)+pSectionHdr[i].VirtualAddress),
|
---|
| 928 | buffer,
|
---|
| 929 | length,
|
---|
[76] | 930 | &accessBytes);
|
---|
[4] | 931 | buffer[length]=0;
|
---|
| 932 | }
|
---|
| 933 |
|
---|
| 934 | }
|
---|
| 935 | HeapDefaultFree(pSectionHdr);
|
---|
| 936 |
|
---|
| 937 | if(!buffer) return 0;
|
---|
| 938 |
|
---|
| 939 |
|
---|
| 940 | dwImageBase=(DWORD)(ULONG_PTR)hModule;
|
---|
| 941 |
|
---|
| 942 |
|
---|
| 943 |
|
---|
[191] | 944 | if(OpBuffer) free(OpBuffer);
|
---|
[188] | 945 | OpBuffer=(char *)malloc(SizeOf_CodeSection);
|
---|
[4] | 946 |
|
---|
| 947 | ReadProcessMemory(hDebugProcess,
|
---|
| 948 | (void *)(ULONG_PTR)(dwImageBase+dwRVA_CodeSection),OpBuffer,
|
---|
[76] | 949 | SizeOf_CodeSection,&accessBytes);
|
---|
[4] | 950 |
|
---|
| 951 |
|
---|
| 952 | return __load();
|
---|
| 953 | }
|
---|
| 954 |
|
---|
| 955 | void CDebugSection::choice(void){
|
---|
| 956 | //イメージベース
|
---|
| 957 | extern DWORD ImageBase;
|
---|
| 958 | ImageBase=this->dwImageBase;
|
---|
| 959 |
|
---|
| 960 | //リライタブルセクションのRVA
|
---|
| 961 | extern int MemPos_RWSection;
|
---|
| 962 | MemPos_RWSection=this->dwRVA_RWSection;
|
---|
| 963 |
|
---|
| 964 | //コードセクションのRVAとサイズ
|
---|
| 965 | extern int MemPos_CodeSection;
|
---|
| 966 | extern int FileSize_CodeSection;
|
---|
| 967 | MemPos_CodeSection=this->dwRVA_CodeSection;
|
---|
| 968 | FileSize_CodeSection=this->SizeOf_CodeSection;
|
---|
| 969 |
|
---|
| 970 | //インクルード情報
|
---|
| 971 | extern INCLUDEFILEINFO IncludeFileInfo;
|
---|
| 972 | IncludeFileInfo=this->IncludeFileInfo;
|
---|
| 973 |
|
---|
| 974 | //ソースコード
|
---|
[88] | 975 | Smoothie::Lexical::source = source;
|
---|
[4] | 976 |
|
---|
| 977 | //コードと行番号の関係
|
---|
[263] | 978 | extern SourceLines oldSourceLines;
|
---|
| 979 | oldSourceLines = this->oldSourceLines;
|
---|
[4] | 980 |
|
---|
| 981 | // クラス情報
|
---|
[256] | 982 | compiler.objectModule.meta.SetClasses( this->pobj_DBClass );
|
---|
[4] | 983 |
|
---|
| 984 | //定数を取得
|
---|
[256] | 985 | compiler.objectModule.meta.GetGlobalConsts() = this->globalConsts;
|
---|
| 986 | compiler.objectModule.meta.GetGlobalConstMacros() = this->globalConstMacros;
|
---|
[4] | 987 |
|
---|
| 988 | //グローバル実行領域のサイズ
|
---|
| 989 | extern int GlobalOpBufferSize;
|
---|
| 990 | GlobalOpBufferSize=this->GlobalOpBufferSize;
|
---|
| 991 |
|
---|
| 992 | //プロシージャ
|
---|
[256] | 993 | compiler.objectModule.meta.GetUserProcs() = userProcs;
|
---|
[4] | 994 |
|
---|
[206] | 995 | extern const UserProc *pSub_DebugSys_EndProc;
|
---|
[4] | 996 | pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc;
|
---|
| 997 |
|
---|
| 998 | //ネイティブコードバッファ
|
---|
| 999 | extern char *OpBuffer;
|
---|
| 1000 | OpBuffer=this->OpBuffer;
|
---|
| 1001 | }
|
---|
| 1002 |
|
---|
| 1003 | void CDebugSection::DeleteDebugInfo(void){
|
---|
| 1004 | int i2;
|
---|
| 1005 |
|
---|
| 1006 | //インクルード情報を解放
|
---|
| 1007 | for(i2=0;i2<IncludeFileInfo.FilesNum;i2++)
|
---|
[191] | 1008 | {
|
---|
| 1009 | free(IncludeFileInfo.ppFileNames[i2]);
|
---|
| 1010 | }
|
---|
| 1011 | free(IncludeFileInfo.ppFileNames);
|
---|
[4] | 1012 |
|
---|
| 1013 | //クラスに関するメモリを解放
|
---|
[182] | 1014 | delete this->pobj_DBClass;
|
---|
| 1015 | this->pobj_DBClass=0;
|
---|
[4] | 1016 |
|
---|
| 1017 | //コードバッファを解放
|
---|
[182] | 1018 | free(OpBuffer);
|
---|
[4] | 1019 | OpBuffer=0;
|
---|
| 1020 |
|
---|
| 1021 | HeapDefaultFree(SingleStepCodeBuffer);
|
---|
| 1022 | SingleStepCodeBuffer=0;
|
---|
| 1023 |
|
---|
| 1024 | HeapDefaultFree(BreakStepCodeBuffer);
|
---|
| 1025 | BreakStepCodeBuffer=0;
|
---|
| 1026 | }
|
---|
| 1027 |
|
---|
| 1028 |
|
---|
| 1029 |
|
---|
| 1030 | CDBDebugSection::CDBDebugSection(){
|
---|
| 1031 | ppobj_ds=(CDebugSection **)HeapAlloc(hHeap,0,1);
|
---|
| 1032 | num=0;
|
---|
| 1033 | }
|
---|
| 1034 | CDBDebugSection::~CDBDebugSection(){
|
---|
| 1035 | int i;
|
---|
| 1036 | for(i=0;i<num;i++){
|
---|
| 1037 | delete ppobj_ds[i];
|
---|
| 1038 | }
|
---|
| 1039 | HeapDefaultFree(ppobj_ds);
|
---|
| 1040 | }
|
---|
| 1041 |
|
---|
| 1042 | BOOL CDBDebugSection::add(HMODULE hModule){
|
---|
| 1043 | CDebugSection *pobj_d;
|
---|
| 1044 | pobj_d=new CDebugSection();
|
---|
| 1045 | if(!pobj_d->load(hModule)){
|
---|
| 1046 | //デバッグ情報が存在しないとき
|
---|
| 1047 | delete pobj_d;
|
---|
| 1048 | return 0;
|
---|
| 1049 | }
|
---|
| 1050 |
|
---|
| 1051 | ppobj_ds=(CDebugSection **)HeapReAlloc(hHeap,0,ppobj_ds,(num+1)*sizeof(CDebugSection *));
|
---|
| 1052 | ppobj_ds[num]=pobj_d;
|
---|
| 1053 | num++;
|
---|
| 1054 |
|
---|
| 1055 | return 1;
|
---|
| 1056 | }
|
---|
| 1057 |
|
---|
| 1058 | void CDBDebugSection::del(HMODULE hModule){
|
---|
| 1059 | int i;
|
---|
| 1060 | for(i=0;i<num;i++){
|
---|
| 1061 | if((HMODULE)(ULONG_PTR)ppobj_ds[i]->dwImageBase==hModule){
|
---|
| 1062 | delete ppobj_ds[i];
|
---|
| 1063 |
|
---|
| 1064 | num--;
|
---|
| 1065 | for(;i<num;i++){
|
---|
| 1066 | ppobj_ds[i]=ppobj_ds[i+1];
|
---|
| 1067 | }
|
---|
| 1068 | break;
|
---|
| 1069 | }
|
---|
| 1070 | }
|
---|
| 1071 | }
|
---|
| 1072 |
|
---|
| 1073 | void CDBDebugSection::choice(int index){
|
---|
| 1074 | pobj_now=ppobj_ds[index];
|
---|
| 1075 | pobj_now->choice();
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|
| 1078 |
|
---|
| 1079 |
|
---|
| 1080 | CDBDebugSection *pobj_DBDebugSection;
|
---|