| 164 | } |
| 165 | |
| 166 | void CDebugger::LineCallback(asIScriptContext *ctx) |
| 167 | { |
| 168 | assert( ctx ); |
| 169 | |
| 170 | // This should never happen, but it doesn't hurt to validate it |
| 171 | if( ctx == 0 ) |
| 172 | return; |
| 173 | |
| 174 | // By default we ignore callbacks when the context is not active. |
| 175 | // An application might override this to for example disconnect the |
| 176 | // debugger as the execution finished. |
| 177 | if( ctx->GetState() != asEXECUTION_ACTIVE ) |
| 178 | return; |
| 179 | |
| 180 | if( m_action == CONTINUE ) |
| 181 | { |
| 182 | if( !CheckBreakPoint(ctx) ) |
| 183 | return; |
| 184 | } |
| 185 | else if( m_action == STEP_OVER ) |
| 186 | { |
| 187 | if( ctx->GetCallstackSize() > m_lastCommandAtStackLevel ) |
| 188 | { |
| 189 | if( !CheckBreakPoint(ctx) ) |
| 190 | return; |
| 191 | } |
| 192 | } |
| 193 | else if( m_action == STEP_OUT ) |
| 194 | { |
| 195 | if( ctx->GetCallstackSize() >= m_lastCommandAtStackLevel ) |
| 196 | { |
| 197 | if( !CheckBreakPoint(ctx) ) |
| 198 | return; |
| 199 | } |
| 200 | } |
| 201 | else if( m_action == STEP_INTO ) |
| 202 | { |
| 203 | CheckBreakPoint(ctx); |
| 204 | |
| 205 | // Always break, but we call the check break point anyway |
| 206 | // to tell user when break point has been reached |
| 207 | } |
| 208 | |
| 209 | stringstream s; |
| 210 | const char *file = 0; |
| 211 | int lineNbr = ctx->GetLineNumber(0, 0, &file); |
| 212 | s << (file ? file : "{unnamed}") << ":" << lineNbr << "; " << ctx->GetFunction()->GetDeclaration() << endl; |
| 213 | Output(s.str()); |
| 214 | |
| 215 | TakeCommands(ctx); |
| 216 | } |
| 217 | |
| 218 | bool CDebugger::CheckBreakPoint(asIScriptContext *ctx) |
| 219 | { |
nothing calls this directly
no test coverage detected