Changeset 114 for trunk/Target


Ignore:
Timestamp:
May 18, 2019, 12:13:44 AM (6 years ago)
Author:
chronos
Message:
  • Modified: Improved stepping through source and target code. Each step has source, program and target index.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Target/UTargetInterpretter.pas

    r112 r114  
    7676  end;
    7777
    78 const
    79   BrainFuckCommandText: array[TMachineCommand] of Char = (
    80     ' ', '+', '-', '>', '<', '.', ',', '[', ']', '@', '=', '*');
    81 
    8278
    8379implementation
     
    321317  Result := '';
    322318  for I := 0 to Length(FProgram) - 1 do begin
    323     Result := Result + BrainFuckCommandText[FProgram[I].Command];
    324     if FProgram[I].Command in [cmInc, cmDec, cmPointerInc, cmPointerDec,
    325       cmSet, cmMultipy] then begin
    326       if FProgram[I].Parameter <> 1 then
    327         Result := Result + IntToStr(FProgram[I].Parameter);
    328     end;
    329     if FProgram[I].RelIndex <> 0 then
    330       Result := Result + 'R' + IntToStr(FProgram[I].RelIndex);
     319    Result := Result + GetOperationText(FProgram[I]);
    331320  end;
    332321end;
     
    369358begin
    370359  if State = rsPaused then begin
    371     Step := DebugSteps.SearchByTargetPos(FProgramIndex);
     360    Step := DebugSteps.SearchByProgramPos(FProgramIndex);
    372361    if Step.Operation = soStepOut then begin
    373       BreakPoints.SetSystem(Step.TargetPosition + 1);
    374       Step := DebugSteps.SearchByTargetPos(FProgram[Step.TargetPosition].Parameter);
    375       BreakPoints.AddSystem(Step.TargetPosition);
     362      BreakPoints.SetSystem(Step.ProgramPosition + 1);
     363      Step := DebugSteps.SearchByProgramPos(FProgram[Step.ProgramPosition].Parameter);
     364      BreakPoints.AddSystem(Step.ProgramPosition);
    376365    end else
    377366    if Step.Operation = soStepIn then begin
    378       BreakPoints.SetSystem(Step.TargetPosition + 1);
    379       Step := DebugSteps.SearchByTargetPos(FProgram[Step.TargetPosition].Parameter);
    380       BreakPoints.AddSystem(Step.TargetPosition);
    381     end else BreakPoints.SetSystem(Step.TargetPosition + 1);
     367      BreakPoints.SetSystem(Step.ProgramPosition + 1);
     368      Step := DebugSteps.SearchByProgramPos(FProgram[Step.ProgramPosition].Parameter);
     369      BreakPoints.AddSystem(Step.ProgramPosition);
     370    end else BreakPoints.SetSystem(Step.ProgramPosition + 1);
    382371    Run;
    383372  end else raise Exception.Create(SProgramNotRunning);
     
    389378begin
    390379  if State = rsPaused then begin
    391     Step := DebugSteps.SearchByTargetPos(FProgramIndex);
     380    Step := DebugSteps.SearchByProgramPos(FProgramIndex);
    392381    if Step.Operation = soStepOut then begin
    393       BreakPoints.SetSystem(Step.TargetPosition + 1);
    394       Step := DebugSteps.SearchByTargetPos(FProgram[Step.TargetPosition].Parameter);
    395       BreakPoints.AddSystem(Step.TargetPosition);
     382      BreakPoints.SetSystem(Step.ProgramPosition + 1);
     383      Step := DebugSteps.SearchByProgramPos(FProgram[Step.ProgramPosition].Parameter);
     384      BreakPoints.AddSystem(Step.ProgramPosition);
    396385    end else
    397386    if Step.Operation = soStepIn then begin
    398       Step := DebugSteps.SearchByTargetPos(FProgram[Step.TargetPosition].Parameter);
    399       BreakPoints.SetSystem(Step.TargetPosition + 1);
    400     end else BreakPoints.SetSystem(Step.TargetPosition + 1);
     387      Step := DebugSteps.SearchByProgramPos(FProgram[Step.ProgramPosition].Parameter);
     388      BreakPoints.SetSystem(Step.ProgramPosition + 1);
     389    end else BreakPoints.SetSystem(Step.ProgramPosition + 1);
    401390    Run;
    402391  end else raise Exception.Create(SProgramNotRunning);
     
    410399begin
    411400  if State = rsPaused then begin
    412     Step := DebugSteps.SearchByTargetPos(FProgramIndex);
     401    Step := DebugSteps.SearchByProgramPos(FProgramIndex);
    413402    StepIndex := DebugSteps.IndexOf(Step);
    414403    Nesting := 1;
     
    419408    end;
    420409    if StepIndex < DebugSteps.Count then begin
    421       Breakpoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).TargetPosition);
     410      Breakpoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).ProgramPosition);
    422411    end;
    423412    Run;
Note: See TracChangeset for help on using the changeset viewer.