source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/NativeCode.cpp@ 643

Last change on this file since 643 was 641, checked in by dai_9181, 16 years ago

・デバッグトレース時、グローバル領域の終端行でステップインまたはステップアウトしたときにデバッグ情報の取得に失敗して強制終了してしまう不具合を修正。
・グローバル領域のデバッグ実行ができなくなっている不具合を修正。

File size: 5.2 KB
Line 
1#include "stdafx.h"
2
3#define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip)
4
5const ::DllProc &Schedule::GetDllProc() const
6{
7 _ASSERT( type == Schedule::DllProc );
8 return *pDllProc;
9}
10const ::UserProc &Schedule::GetUserProc() const
11{
12 _ASSERT( type == Schedule::UserProc || type == Schedule::AddressOf || type == Schedule::CatchAddress );
13 return *pUserProc;
14}
15const ::CClass &Schedule::GetClass() const
16{
17 _ASSERT( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo );
18 return *pClass;
19}
20
21bool Schedule::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
22{
23 switch( type )
24 {
25 case UserProc:
26 case AddressOf:
27 case CatchAddress:
28 if( this->pUserProc->IsNeedResolve() )
29 {
30 const ::UserProc *pTempUserProc = resolver.meta.GetUserProcs().FindLike( this->pUserProc );
31 if( pTempUserProc )
32 {
33 this->pUserProc = pTempUserProc;
34 }
35 else
36 {
37 resolveErrors.Add( ResolveError( this->pUserProc->GetRelationalObjectModuleIndex(), this->pUserProc->GetFullName() ) );
38 }
39 }
40 break;
41 case DllProc:
42 if( this->pDllProc->IsNeedResolve() )
43 {
44 const ::DllProc *pTempDllProc = resolver.meta.GetDllProcs().FindLike( this->pDllProc );
45 if( pTempDllProc )
46 {
47 this->pDllProc = pTempDllProc;
48 }
49 else
50 {
51 resolveErrors.Add( ResolveError( this->pDllProc->GetRelationalObjectModuleIndex(), this->pDllProc->GetFullName() ) );
52 }
53 }
54 break;
55 case ComVtbl:
56 case Vtbl:
57 case TypeInfo:
58 if( this->pClass->IsNeedResolve() )
59 {
60 const CClass *pTempClass = resolver.meta.GetClasses().FindLike( this->pClass );
61 if( pTempClass )
62 {
63 this->pClass = pTempClass;
64 }
65 else
66 {
67 resolveErrors.Add( ResolveError( this->pClass->GetRelationalObjectModuleIndex(), this->pClass->GetFullName() ) );
68 }
69 }
70 break;
71 default:
72 break;
73 }
74
75 return true;
76}
77
78void NativeCode::PutEx( const NativeCode &nativeCode )
79{
80 long baseOffset = GetSize();
81
82 // コードバッファを追加
83 Put( nativeCode.GetBuffer(), nativeCode.GetSize() );
84
85 // スケジュールを追加
86 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules )
87 {
88 this->schedules.push_back(
89 Schedule(
90 schedule.GetType(),
91 baseOffset + schedule.GetOffset(),
92 schedule.GetLongPtrValue()
93 )
94 );
95 }
96
97 // ソースコード行番号とネイティブコード位置の対応情報を追加
98 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines )
99 {
100 this->sourceLines.push_back(
101 SourceLine(
102 baseOffset + sourceLine.GetNativeCodePos(),
103 sourceLine.GetCodeType(),
104 sourceLine.GetSourceCodePosition()
105 )
106 );
107 }
108}
109
110void NativeCode::PutEx( long l, Schedule::Type scheduleType )
111{
112 if( scheduleType != Schedule::None )
113 {
114 schedules.push_back( Schedule( scheduleType, GetSize() ) );
115 }
116
117 Put( l );
118}
119
120void NativeCode::PutUserProcSchedule( const UserProc *pUserProc, bool isCall )
121{
122 pUserProc->Using();
123
124 Schedule::Type type = isCall ? Schedule::UserProc : Schedule::AddressOf;
125
126 schedules.push_back( Schedule( type, pUserProc, GetSize() ) );
127
128 Put( (long)0 );
129}
130
131void NativeCode::PutCatchAddressSchedule( const UserProc *pUserProc, long codePos )
132{
133 pUserProc->Using();
134
135 schedules.push_back( Schedule( Schedule::CatchAddress, pUserProc, GetSize() ) );
136
137 Put( codePos );
138}
139
140void NativeCode::PutDllProcSchedule( const DllProc *pDllProc )
141{
142 pDllProc->Using();
143
144 schedules.push_back( Schedule( pDllProc, GetSize() ) );
145
146 Put( (long)0 );
147}
148
149void NativeCode::PutComVtblSchedule( const CClass *pClass )
150{
151 schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) );
152
153 Put( (long)0 );
154}
155
156void NativeCode::PutVtblSchedule( const CClass *pClass )
157{
158 schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) );
159
160 Put( (long)0 );
161}
162
163void NativeCode::NextSourceLine( const SourceCodePosition &sourceCodePosition, bool isInSystemProc )
164{
165 if( sourceLines.size() )
166 {
167 if( sourceLines.back().GetNativeCodePos() == GetSize() )
168 {
169 sourceLines.back().SetSourceCodePosition( sourceCodePosition );
170 return;
171 }
172 }
173
174 extern BOOL bDebugSupportProc;
175 DWORD sourceLineType = 0;
176 if( bDebugSupportProc )
177 {
178 sourceLineType |= CODETYPE_DEBUGPROC;
179 }
180 if( isInSystemProc )
181 {
182 sourceLineType |= CODETYPE_SYSTEMPROC;
183 }
184 sourceLines.push_back(
185 SourceLine(
186 GetSize(),
187 sourceLineType,
188 sourceCodePosition
189 )
190 );
191}
192
193void NativeCode::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
194{
195 BOOST_FOREACH( const Schedule &schedule, schedules )
196 {
197 if( schedule.GetType() == Schedule::DataTable )
198 {
199 Overwrite(
200 schedule.GetOffset(),
201 GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
202 );
203 }
204 }
205}
206void NativeCode::ResetRelationalObjectModuleIndex( const std::vector<int> &relationTable )
207{
208 BOOST_FOREACH( SourceLine &sourceLine, sourceLines )
209 {
210 sourceLine.GetSourceCodePosition().SetRelationalObjectModuleIndex(
211 relationTable[sourceLine.GetSourceCodePosition().GetRelationalObjectModuleIndex()]
212 );
213 }
214}
215
216void NativeCode::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
217{
218 BOOST_FOREACH( Schedule &schedule, schedules )
219 {
220 schedule.Resolve( resolver, resolveErrors );
221 }
222}
Note: See TracBrowser for help on using the repository browser.