Changeset 39 for trunk/Target
- Timestamp:
- Feb 19, 2012, 12:41:25 PM (13 years ago)
- Location:
- trunk/Target
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Target/UTarget.pas
r36 r39 44 44 procedure AddItem(TargetAddress: Integer); 45 45 procedure SetSystem(TargetAddress: Integer); 46 procedure AddSystem(TargetAddress: Integer); 46 47 procedure ClearSystem; 47 48 function SearchByTargetPos(Pos: Integer): TBreakPoint; … … 126 127 127 128 procedure TBreakPointList.SetSystem(TargetAddress: Integer); 129 begin 130 ClearSystem; 131 AddSystem(TargetAddress); 132 end; 133 134 procedure TBreakPointList.AddSystem(TargetAddress: Integer); 128 135 var 129 136 NewItem: TBreakPoint; 130 137 begin 131 ClearSystem;132 138 NewItem := TBreakPoint.Create; 133 139 NewItem.TargetAddress := TargetAddress; -
trunk/Target/UTargetInterpretter.pas
r36 r39 14 14 15 15 TTargetInterpretterThread = class(TThread) 16 private 17 FNewState: TRunState; 18 procedure DoSetState; 19 procedure SetStateSafe(State: TRunState); 20 public 16 21 Parent: TTargetInterpretter; 17 22 procedure Execute; override; … … 98 103 99 104 procedure TTargetInterpretterThread.Execute; 105 var 106 BreakPoint: TBreakPoint; 100 107 begin 101 108 with Parent do … … 104 111 if State = rsRunning then begin 105 112 if FProgramBreakpoints[SourcePosition] then begin 106 FProgramBreakpoints[SourcePosition] := False; 107 State := rsPaused; 113 BreakPoint := BreakPoints.SearchByTargetPos(SourcePosition); 114 if BreakPoint.System then BreakPoints.Delete(BreakPoints.IndexOf(BreakPoint)); 115 SetStateSafe(rsPaused); 108 116 end else begin 109 117 FCommandTable[FProgram[SourcePosition]]; … … 114 122 if State = rsPaused then Sleep(1); 115 123 end; 116 State := rsStopped;124 if State <> rsStopped then SetStateSafe(rsStopped); 117 125 until Terminated or (State = rsStopped); 126 end; 127 128 procedure TTargetInterpretterThread.DoSetState; 129 begin 130 Parent.State := FNewState; 131 end; 132 133 procedure TTargetInterpretterThread.SetStateSafe(State: TRunState); 134 begin 135 FNewState := State; 136 Synchronize(DoSetState); 118 137 end; 119 138 … … 307 326 FProgramBreakpoints[I] := False; 308 327 for I := 0 to BreakPoints.Count - 1 do 309 FProgramBreakpoints[TBreakPoint(BreakPoints[I]).TargetAddress] := True; 328 if TBreakPoint(BreakPoints[I]).TargetAddress < Length(FProgramBreakpoints) then 329 FProgramBreakpoints[TBreakPoint(BreakPoints[I]).TargetAddress] := True; 310 330 end; 311 331 … … 326 346 procedure TTargetInterpretter.Run; 327 347 begin 348 PrepareBreakPoints; 328 349 if FState = rsStopped then begin 329 350 Reset; … … 347 368 var 348 369 Step: TDebugStep; 370 StepIndex: Integer; 371 Nesting: Integer; 349 372 begin 350 373 if State = rsPaused then begin 351 374 Step := DebugSteps.SearchByTargetPos(SourcePosition); 352 BreakPoints.SetSystem(Step.TargetPosition + 1); 375 if Step.Operation = soStepOut then begin 376 BreakPoints.SetSystem(Step.TargetPosition + 1); 377 Step := DebugSteps.SearchByTargetPos(SourceJump[Step.TargetPosition]); 378 BreakPoints.AddSystem(Step.TargetPosition); 379 end else 380 if Step.Operation = soStepIn then begin 381 BreakPoints.SetSystem(Step.TargetPosition + 1); 382 Step := DebugSteps.SearchByTargetPos(SourceJump[Step.TargetPosition]); 383 BreakPoints.AddSystem(Step.TargetPosition); 384 end else BreakPoints.SetSystem(Step.TargetPosition + 1); 353 385 Run; 354 386 end else raise Exception.Create(SProgramNotRunning); … … 363 395 if State = rsPaused then begin 364 396 Step := DebugSteps.SearchByTargetPos(SourcePosition); 397 if Step.Operation = soStepOut then begin 398 BreakPoints.SetSystem(Step.TargetPosition + 1); 399 Step := DebugSteps.SearchByTargetPos(SourceJump[Step.TargetPosition]); 400 BreakPoints.AddSystem(Step.TargetPosition); 401 end else 365 402 if Step.Operation = soStepIn then begin 366 StepIndex := DebugSteps.IndexOf(Step); 367 Inc(StepIndex); 368 Nesting := 1; 369 while (StepIndex < DebugSteps.Count) and (Nesting > 0) do begin 370 if TDebugStep(DebugSteps[StepIndex]).Operation <> soStepOut then Dec(Nesting); 371 if TDebugStep(DebugSteps[StepIndex]).Operation <> soStepIn then Inc(Nesting); 372 Inc(StepIndex); 373 end; 374 BreakPoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).TargetPosition); 403 Step := DebugSteps.SearchByTargetPos(SourceJump[Step.TargetPosition]); 404 BreakPoints.SetSystem(Step.TargetPosition + 1); 375 405 end else BreakPoints.SetSystem(Step.TargetPosition + 1); 376 406 Run; … … 382 412 Step: TDebugStep; 383 413 StepIndex: Integer; 414 Nesting: Integer; 384 415 begin 385 416 if State = rsPaused then begin 386 417 Step := DebugSteps.SearchByTargetPos(SourcePosition); 387 418 StepIndex := DebugSteps.IndexOf(Step); 388 while (StepIndex < DebugSteps.Count) and (TDebugStep(DebugSteps[StepIndex]).Operation <> soStepOut) do Inc(StepIndex); 419 Nesting := 1; 420 while (StepIndex < DebugSteps.Count) and (Nesting > 0) do begin 421 if TDebugStep(DebugSteps[StepIndex]).Operation = soStepIn then Inc(Nesting); 422 if TDebugStep(DebugSteps[StepIndex]).Operation = soStepOut then Dec(Nesting); 423 Inc(StepIndex); 424 end; 389 425 if StepIndex < DebugSteps.Count then begin 390 426 Breakpoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).TargetPosition); 391 Run;392 427 end; 428 Run; 393 429 end else raise Exception.Create(SProgramNotRunning); 394 430 end;
Note:
See TracChangeset
for help on using the changeset viewer.