Changeset 263 in dev for trunk/abdev/BasicCompiler_Common


Ignore:
Timestamp:
Aug 5, 2007, 3:47:49 AM (17 years ago)
Author:
dai_9181
Message:
 
Location:
trunk/abdev/BasicCompiler_Common
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/BasicCompiler.h

    r209 r263  
    5757char szDebugExeForDll[1024];
    5858
    59 //デバッグ用行番号情報
    60 LINEINFO *pLineInfo;
    61 int MaxLineInfoNum;
    62 
    6359//ウォッチリスト
    6460int width_WatchColumn_Expression=200;
  • trunk/abdev/BasicCompiler_Common/BreakPoint.cpp

    r256 r263  
    33#include <jenga/include/common/Environment.h>
    44#include <jenga/include/smoothie/Source.h>
     5
     6#include <Compiler.h>
    57
    68#include "common.h"
     
    6971
    7072        if(i2==piLine[nCount]){
    71             extern int MaxLineInfoNum;
    72             extern LINEINFO *pLineInfo;
     73            extern SourceLines oldSourceLines;
    7374
    7475loop:
     
    7778
    7879            int i3;
    79             for(i3=0;i3<MaxLineInfoNum-1;i3++){
    80                 if(pLineInfo[i3].TopCp==tempCp) break;
     80            for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){
     81                if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break;
    8182            }
    82             if(i3==MaxLineInfoNum-1){
     83            if(i3==oldSourceLines.size()-1){
    8384                i2--;
    8485                goto loop;
    8586            }
    8687
    87             nativeCodeBuffer[pLineInfo[i3].TopObp]=(char)0xCC;
     88            nativeCodeBuffer[oldSourceLines[i3].GetNativeCodePos()]=(char)0xCC;
    8889
    8990            nCount++;
  • trunk/abdev/BasicCompiler_Common/Compile.cpp

    r261 r263  
    2525//With情報
    2626WITHINFO WithInfo;
     27
     28//デバッグ用行番号情報
     29SourceLines oldSourceLines;
    2730
    2831
     
    8083
    8184void NextLine(void){
    82     extern HANDLE hHeap;
    83     extern int MaxLineInfoNum;
    84     extern LINEINFO *pLineInfo;
    85     if(MaxLineInfoNum){
    86         extern int obp;
    87         if(pLineInfo[MaxLineInfoNum-1].TopObp==obp){
    88             pLineInfo[MaxLineInfoNum-1].TopCp=cp;
     85    extern int obp;
     86
     87    extern SourceLines oldSourceLines;
     88    if( oldSourceLines.size() )
     89    {
     90        if( oldSourceLines.back().GetNativeCodePos() == obp )
     91        {
     92            oldSourceLines.back().SetSourceCodePos( cp );
    8993            return;
    9094        }
    9195    }
    92     pLineInfo=(LINEINFO *)HeapReAlloc(hHeap,0,pLineInfo,(MaxLineInfoNum+1)*sizeof(LINEINFO));
    93     pLineInfo[MaxLineInfoNum].TopCp=cp;
    94     extern int obp;
    95     pLineInfo[MaxLineInfoNum].TopObp=obp;
    9696
    9797    extern BOOL bDebugSupportProc;
    9898    extern BOOL bSystemProc;
    99     pLineInfo[MaxLineInfoNum].dwCodeType=0;
    100     if(bDebugSupportProc)
    101         pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_DEBUGPROC;
    102     if(bSystemProc)
    103         pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_SYSTEMPROC;
    104 
    105     MaxLineInfoNum++;
     99    DWORD sourceLineType = 0;
     100    if( bDebugSupportProc )
     101    {
     102        sourceLineType |= CODETYPE_DEBUGPROC;
     103    }
     104    if( bSystemProc )
     105    {
     106        sourceLineType |= CODETYPE_SYSTEMPROC;
     107    }
     108    oldSourceLines.push_back( SourceLine( (long)oldSourceLines.size(), obp, cp, sourceLineType ) );
    106109}
    107110
     
    334337                breakpoint;
    335338            }
    336 #if defined(_DEBUG)
    337339            else
    338340            {
     341//#if defined(_DEBUG)
    339342                breakpoint;
    340             }
    341 #endif
     343//#endif
     344            }
    342345            break;
    343346
     
    637640
    638641            NextLine();
     642            compiler.codeGenerator.NextSourceLine();
    639643
    640644            if(Command[0]==1){
  • trunk/abdev/BasicCompiler_Common/Debug.cpp

    r259 r263  
    7979
    8080        if(i2==iLineNum){
    81             extern int MaxLineInfoNum;
    82             extern LINEINFO *pLineInfo;
     81            extern SourceLines oldSourceLines;
    8382
    8483loop:
     
    8786
    8887            int i3;
    89             for(i3=0;i3<MaxLineInfoNum-1;i3++){
    90                 if(pLineInfo[i3].TopCp==tempCp) break;
    91             }
    92             if(i3==MaxLineInfoNum-1){
     88            for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){
     89                if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break;
     90            }
     91            if(i3==oldSourceLines.size()-1){
    9392                i2--;
    9493                goto loop;
    9594            }
    9695
    97             StepCursorObpSchedule=pLineInfo[i3].TopObp;
     96            StepCursorObpSchedule=oldSourceLines[i3].GetNativeCodePos();
    9897            StepCursor_BackupChar=pobj_DBDebugSection->pobj_now->BreakStepCodeBuffer[StepCursorObpSchedule];
    9998
  • trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp

    r259 r263  
    9898    // コードと行番号の関係
    9999    ////////////////////////
    100     extern int MaxLineInfoNum;
    101     extern LINEINFO *pLineInfo;
    102 
    103     //バッファが足りない場合は再確保
    104     if(MaxLineInfoNum*sizeof(LINEINFO)<32768) i3=32768;
    105     else i3=MaxLineInfoNum*sizeof(LINEINFO)+32768;
    106     if(BufferSize<i2+i3){
    107         BufferSize+=i3;
    108         buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
    109     }
    110 
    111     *(long *)(buffer+i2)=MaxLineInfoNum;
    112     i2+=sizeof(long);
    113     memcpy(buffer+i2,pLineInfo,MaxLineInfoNum*sizeof(LINEINFO));
    114     i2+=MaxLineInfoNum*sizeof(LINEINFO);
     100    extern SourceLines oldSourceLines;
     101
     102    *(long *)(buffer+i2)=(long)oldSourceLines.size();
     103    i2+=sizeof(long);
     104    BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines )
     105    {
     106        *(long *)(buffer+i2) = sourceLine.GetLineNum();
     107        i2+=sizeof(long);
     108
     109        *(long *)(buffer+i2) = sourceLine.GetNativeCodePos();
     110        i2+=sizeof(long);
     111
     112        *(long *)(buffer+i2) = sourceLine.GetSourceCodePos();
     113        i2+=sizeof(long);
     114
     115        *(long *)(buffer+i2) = sourceLine.GetCodeType();
     116        i2+=sizeof(long);
     117
     118        //バッファが足りない場合は再確保
     119        if(BufferSize<i2+32768){
     120            BufferSize+=32768;
     121            buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize);
     122        }
     123    }
    115124
    116125
     
    431440    memcpy(buffer,OpBuffer,SizeOf_CodeSection);
    432441
    433     int i2;
    434     for(i2=0;i2<MaxLineInfoNum;i2++){
     442    BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines )
     443    {
    435444        if(!(
    436             pLineInfo[i2].dwCodeType&CODETYPE_SYSTEMPROC||
    437             pLineInfo[i2].dwCodeType&CODETYPE_DEBUGPROC
    438             )){
     445            sourceLine.IsInSystemProc()
     446            || sourceLine.IsInDebugProc() ) )
     447        {
    439448            //int 3
    440             buffer[pLineInfo[i2].TopObp]=(char)0xCC;
     449            buffer[sourceLine.GetNativeCodePos()]=(char)0xCC;
    441450        }
    442451    }
     
    487496
    488497    //コードと行番号の関係
    489     MaxLineInfoNum=*(long *)(buffer+i2);
    490     i2+=sizeof(long);
    491     pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)+1);
    492     memcpy(pLineInfo,buffer+i2,MaxLineInfoNum*sizeof(LINEINFO));
    493     i2+=MaxLineInfoNum*sizeof(LINEINFO);
     498    int maxLineInfoNum;
     499    maxLineInfoNum=*(long *)(buffer+i2);
     500    i2+=sizeof(long);
     501    for(i3=0;i3<maxLineInfoNum;i3++){
     502        int lineNum = *(long *)(buffer+i2);
     503        i2+=sizeof(long);
     504
     505        int nativeCodePos = *(long *)(buffer+i2);
     506        i2+=sizeof(long);
     507
     508        int sourceCodePos = *(long *)(buffer+i2);
     509        i2+=sizeof(long);
     510
     511        DWORD sourceLineType = *(DWORD *)(buffer+i2);
     512        i2+=sizeof(long);
     513
     514        oldSourceLines.push_back( SourceLine( lineNum, nativeCodePos, sourceCodePos, sourceLineType ) );
     515    }
    494516
    495517
     
    837859
    838860    //コードと行番号の関係
    839     extern int MaxLineInfoNum;
    840     extern LINEINFO *pLineInfo;
    841     MaxLineInfoNum=this->MaxLineInfoNum;
    842     pLineInfo=this->pLineInfo;
     861    extern SourceLines oldSourceLines;
     862    oldSourceLines = this->oldSourceLines;
    843863
    844864    BreakStepCodeBuffer=pobj_DBBreakPoint->update(OpBuffer,SizeOf_CodeSection);
     
    956976
    957977    //コードと行番号の関係
    958     extern int MaxLineInfoNum;
    959     extern LINEINFO *pLineInfo;
    960     MaxLineInfoNum=this->MaxLineInfoNum;
    961     pLineInfo=this->pLineInfo;
     978    extern SourceLines oldSourceLines;
     979    oldSourceLines = this->oldSourceLines;
    962980
    963981    // クラス情報
     
    9961014    delete this->pobj_DBClass;
    9971015    this->pobj_DBClass=0;
    998 
    999     //コードと行番号の関係を解放
    1000     HeapDefaultFree(pLineInfo);
    10011016
    10021017    //コードバッファを解放
  • trunk/abdev/BasicCompiler_Common/DebugSection.h

    r206 r263  
    33#include <jenga/include/smoothie/Source.h>
    44
    5 #include <Class.h>
    6 #include <Procedure.h>
    7 #include <Const.h>
    8 
     5#include <Compiler.h>
    96
    107class CDebugSection{
     
    2926    int SizeOf_CodeSection;
    3027
     28    // オブジェクトモジュール
     29    ObjectModule objectModule;
     30
    3131    //インクルード情報
    3232    INCLUDEFILEINFO IncludeFileInfo;
     
    3636
    3737    //コードと行番号の関係
    38     int MaxLineInfoNum;
    39     LINEINFO *pLineInfo;
     38    SourceLines oldSourceLines;
    4039
    4140    // クラス情報
  • trunk/abdev/BasicCompiler_Common/MakeExe.cpp

    r256 r263  
    160160    HeapDefaultFree(pBitmapResourceInfo);
    161161    HeapDefaultFree(pIconResourceInfo);
    162 
    163     //コードと行番号の関係情報を解放
    164     extern LINEINFO *pLineInfo;
    165     HeapDefaultFree(pLineInfo);
    166162
    167163    //コンパイルダイアログのプログレスバーを上げる
  • trunk/abdev/BasicCompiler_Common/VarList.cpp

    r259 r263  
    569569
    570570    //行番号情報
    571     extern int MaxLineInfoNum;
    572     extern LINEINFO *pLineInfo;
     571    extern SourceLines oldSourceLines;
    573572    for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
    574         for(i2=0;i2<MaxLineInfoNum-1;i2++){
    575             if((ULONG_PTR)(pLineInfo[i2].TopObp+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
    576                 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(pLineInfo[i2+1].TopObp+ImageBase+MemPos_CodeSection)) break;
    577         }
    578         if(i2==MaxLineInfoNum) pobj_dti->lpdwCp[i3]=-1;
    579         else pobj_dti->lpdwCp[i3]=pLineInfo[i2].TopCp;
     573        for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){
     574            if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
     575                pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break;
     576        }
     577        if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1;
     578        else pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos();
    580579    }
    581580    for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
  • trunk/abdev/BasicCompiler_Common/common.h

    r254 r263  
    140140
    141141
    142 #define CODETYPE_SYSTEMPROC     0x0001
    143 #define CODETYPE_DEBUGPROC      0x0002
    144 struct LINEINFO{
    145     int TopCp;
    146     int TopObp;
    147     DWORD dwCodeType;
    148 };
    149142struct RESOURCEDATAINFO{
    150143    DWORD dwId;
  • trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r262 r263  
    238238        }
    239239        pNativeCode = &nativeCode;
     240    }
     241
     242    void NextSourceLine()
     243    {
     244        pNativeCode->NextSourceLine();
    240245    }
    241246
  • trunk/abdev/BasicCompiler_Common/include/Linker.h

    r258 r263  
    4141    }
    4242
     43    const NativeCode &GetNativeCode() const
     44    {
     45        return nativeCode;
     46    }
     47
    4348    void SetImageBase( DWORD imageBase )
    4449    {
  • trunk/abdev/BasicCompiler_Common/include/NativeCode.h

    r258 r263  
    112112typedef std::vector<Schedule> Schedules;
    113113
     114#define CODETYPE_SYSTEMPROC     0x0001
     115#define CODETYPE_DEBUGPROC      0x0002
     116class SourceLine
     117{
     118    int lineNum;
     119    long nativeCodePos;
     120    long sourceCodePos;
     121    DWORD codeType;
     122
     123    // XMLシリアライズ用
     124private:
     125    friend class boost::serialization::access;
     126    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     127    {
     128        trace_for_serialize( "serializing - SourceLine" );
     129
     130        ar & BOOST_SERIALIZATION_NVP( lineNum );
     131        ar & BOOST_SERIALIZATION_NVP( nativeCodePos );
     132        ar & BOOST_SERIALIZATION_NVP( sourceCodePos );
     133        ar & BOOST_SERIALIZATION_NVP( codeType );
     134    }
     135
     136public:
     137    SourceLine( int lineNum, int nativeCodePos, int sourceCodePos, DWORD codeType )
     138        : lineNum( lineNum )
     139        , nativeCodePos( nativeCodePos )
     140        , sourceCodePos( sourceCodePos )
     141        , codeType( codeType )
     142    {
     143    }
     144    SourceLine()
     145    {
     146    }
     147
     148    int GetLineNum() const
     149    {
     150        return lineNum;
     151    }
     152    long GetNativeCodePos() const
     153    {
     154        return nativeCodePos;
     155    }
     156    long GetSourceCodePos() const
     157    {
     158        return sourceCodePos;
     159    }
     160    void SetSourceCodePos( int sourceCodePos )
     161    {
     162        this->sourceCodePos = sourceCodePos;
     163    }
     164    DWORD GetCodeType() const
     165    {
     166        return codeType;
     167    }
     168    bool IsInSystemProc() const
     169    {
     170        return ( (codeType&CODETYPE_SYSTEMPROC) != 0 );
     171    }
     172    bool IsInDebugProc() const
     173    {
     174        return ( (codeType&CODETYPE_DEBUGPROC) != 0 );
     175    }
     176};
     177typedef std::vector<SourceLine> SourceLines;
     178
    114179class NativeCode
    115180{
     
    118183    int size;
    119184
     185    // リンカで解決しなければならないスケジュール
    120186    Schedules schedules;
     187
     188    // ソースコード行番号とネイティブコード位置の対応情報
     189    SourceLines sourceLines;
    121190
    122191    // XMLシリアライズ用
     
    132201        ar & BOOST_SERIALIZATION_NVP( size );
    133202        ar & BOOST_SERIALIZATION_NVP( schedules );
     203        ar & BOOST_SERIALIZATION_NVP( sourceLines );
    134204
    135205        // 読み込み後の処理
     
    163233        ar & BOOST_SERIALIZATION_NVP( size );
    164234        ar & BOOST_SERIALIZATION_NVP( schedules );
     235        ar & BOOST_SERIALIZATION_NVP( sourceLines );
    165236    }
    166237
     
    192263        Put( nativeCode, isOpBuffer );
    193264    }
    194     NativeCode( const char *codeBuffer, int size )
     265    NativeCode( const char *codeBuffer, int size, bool isOpBuffer )
    195266        : allocateSize( 8192 )
    196267        , codeBuffer( (char *)malloc( allocateSize ) )
    197268        , size( 0 )
    198269    {
    199         Put( codeBuffer, size );
     270        Put( codeBuffer, size, isOpBuffer );
    200271    }
    201272    ~NativeCode()
     
    214285    }
    215286
     287    const char *GetCodeBuffer() const
     288    {
     289        return codeBuffer;
     290    }
    216291    int GetSize() const
    217292    {
     
    332407        ObpPlus();
    333408    }
     409
     410    void NextSourceLine();
    334411};
  • trunk/abdev/BasicCompiler_Common/src/Class.cpp

    r259 r263  
    737737        pUserProc=(UserProc *)pVtbl[i];
    738738        if(!pUserProc) continue;
    739         pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection;
     739
     740        // 古いOpBufferを利用する場合は_beginOpAddressOldでないとダメ
     741        //pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection;
     742        pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection;
    740743    }
    741744}
  • trunk/abdev/BasicCompiler_Common/src/Linker.cpp

    r258 r263  
    2626        if( schedule.GetType() == Schedule::DllProc )
    2727        {
    28 #ifdef _AMD64
     28#ifdef _AMD64_
    2929            nativeCode.Overwrite(
    3030                schedule.GetOffset(),
     
    103103void Linker::Link( vector<ObjectModule *> &objectModules )
    104104{
     105    // nativeCodeは初期状態でなければならない
     106    if( nativeCode.GetSize() > 0 )
     107    {
     108        SetError();
     109    }
     110
    105111    /*
    106112    BOOST_FOREACH( ObjectModule *pObjectModule, objectModules )
  • trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp

    r258 r263  
    2222    long baseOffset = size;
    2323
     24    // コードバッファを追加
    2425    Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer );
    2526
     27    // スケジュールを追加
    2628    BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
    2729    {
     
    3133                baseOffset + schedule.GetOffset(),
    3234                schedule.GetLongPtrValue()
     35            )
     36        );
     37    }
     38
     39    // ソースコード行番号とネイティブコード位置の対応情報を追加
     40    BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
     41    {
     42        this->sourceLines.push_back(
     43            SourceLine(
     44                sourceLine.GetLineNum(),
     45                baseOffset + sourceLine.GetNativeCodePos(),
     46                sourceLine.GetSourceCodePos(),
     47                sourceLine.GetCodeType()
    3348            )
    3449        );
     
    85100    ObpPlus( sizeof(long) );
    86101}
     102
     103void NativeCode::NextSourceLine()
     104{
     105    if( sourceLines.size() )
     106    {
     107        if( sourceLines.back().GetNativeCodePos() == size )
     108        {
     109            sourceLines.back().SetSourceCodePos( cp );
     110            return;
     111        }
     112    }
     113
     114    extern BOOL bDebugSupportProc;
     115    extern BOOL bSystemProc;
     116    DWORD sourceLineType = 0;
     117    if( bDebugSupportProc )
     118    {
     119        sourceLineType |= CODETYPE_DEBUGPROC;
     120    }
     121    if( bSystemProc )
     122    {
     123        sourceLineType |= CODETYPE_SYSTEMPROC;
     124    }
     125    sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) );
     126}
Note: See TracChangeset for help on using the changeset viewer.