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