Changeset 39


Ignore:
Timestamp:
Feb 19, 2012, 12:41:25 PM (13 years ago)
Author:
chronos
Message:
  • Fixed: Step into, step over, step out, run to cursor debbuging actions.
  • Fixed: Updating interface from interpretter thread using synchronization.
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCPU.lfm

    r38 r39  
    44  Top = 127
    55  Width = 414
    6   Caption = 'Interpretter'
     6  Caption = 'CPU'
    77  ClientHeight = 287
    88  ClientWidth = 414
  • trunk/Forms/UFormCPU.lrt

    r38 r39  
    1 TFORMCPU.CAPTION=Interpretter
     1TFORMCPU.CAPTION=CPU
    22TFORMCPU.LABEL4.CAPTION=Step counter:
    33TFORMCPU.LABEL7.CAPTION=Speed:
  • trunk/Forms/UFormInput.lfm

    r38 r39  
    44  Top = 32
    55  Width = 320
    6   Caption = 'FormInput'
     6  Caption = 'Input'
    77  ClientHeight = 240
    88  ClientWidth = 320
  • trunk/Forms/UFormInput.lrt

    r38 r39  
    1 TFORMINPUT.CAPTION=FormInput
     1TFORMINPUT.CAPTION=Input
    22TFORMINPUT.LABEL1.CAPTION=Input:
  • trunk/Forms/UFormMain.lfm

    r38 r39  
    11object MainForm: TMainForm
    2   Left = 208
    3   Height = 609
    4   Top = 134
    5   Width = 790
     2  Left = 215
     3  Height = 414
     4  Top = 271
     5  Width = 665
    66  Caption = 'LazFuck'
    7   ClientHeight = 584
    8   ClientWidth = 790
     7  ClientHeight = 389
     8  ClientWidth = 665
    99  Menu = MainMenu1
    1010  OnCloseQuery = FormCloseQuery
     
    1717    Left = 0
    1818    Height = 21
    19     Top = 563
    20     Width = 790
     19    Top = 368
     20    Width = 665
    2121    Panels = <   
    2222      item
     
    3535    Height = 26
    3636    Top = 0
    37     Width = 790
     37    Width = 665
    3838    Images = ImageList1
    3939    ParentShowHint = False
     
    118118  end
    119119  object PageControlRight: TPageControl
    120     Left = 397
    121     Height = 537
     120    Left = 272
     121    Height = 342
    122122    Top = 26
    123123    Width = 393
     
    129129    object TabSheetDebug: TTabSheet
    130130      Caption = 'Debug'
    131       ClientHeight = 535
     131      ClientHeight = 340
    132132      ClientWidth = 341
    133133      object PanelInput: TPanel
    134134        Left = 0
    135         Height = 133
     135        Height = 64
    136136        Top = 0
    137137        Width = 341
     
    144144        Left = 0
    145145        Height = 5
    146         Top = 133
     146        Top = 64
    147147        Width = 341
    148148        Align = alTop
     
    151151      object PanelOutput: TPanel
    152152        Left = 0
    153         Height = 123
    154         Top = 138
     153        Height = 259
     154        Top = 69
    155155        Width = 341
    156156        Align = alTop
     
    162162        Left = 0
    163163        Height = 5
    164         Top = 261
     164        Top = 328
    165165        Width = 341
    166166        Align = alTop
     
    169169      object PanelCPU: TPanel
    170170        Left = 0
    171         Height = 139
    172         Top = 266
     171        Height = 86
     172        Top = 333
    173173        Width = 341
    174174        Align = alTop
     
    180180        Left = 0
    181181        Height = 5
    182         Top = 405
     182        Top = 340
    183183        Width = 341
    184184        Align = alTop
     
    187187      object PanelMemory: TPanel
    188188        Left = 0
    189         Height = 125
    190         Top = 410
     189        Height = 1
     190        Top = 340
    191191        Width = 341
    192192        Align = alClient
     
    197197  end
    198198  object Splitter1: TSplitter
    199     Left = 392
    200     Height = 537
     199    Left = 267
     200    Height = 342
    201201    Top = 26
    202202    Width = 5
     
    206206  object PanelLeft: TPanel
    207207    Left = 0
    208     Height = 537
     208    Height = 342
    209209    Top = 26
    210     Width = 392
     210    Width = 267
    211211    Align = alClient
    212212    BevelOuter = bvNone
    213     ClientHeight = 537
    214     ClientWidth = 392
     213    ClientHeight = 342
     214    ClientWidth = 267
    215215    TabOrder = 4
    216216    object PageControlMain: TPageControl
    217217      Left = 0
    218       Height = 414
     218      Height = 219
    219219      Top = 0
    220       Width = 392
     220      Width = 267
    221221      ActivePage = TabSheetSource
    222222      Align = alClient
     
    226226      object TabSheetSource: TTabSheet
    227227        Caption = 'Source code'
    228         ClientHeight = 387
    229         ClientWidth = 390
     228        ClientHeight = 192
     229        ClientWidth = 265
    230230        object MemoSource: TMemo
    231231          Left = 0
    232           Height = 387
     232          Height = 192
    233233          Top = 0
    234           Width = 390
     234          Width = 265
    235235          Align = alClient
    236236          Font.Height = -12
     
    249249      object TabSheetTarget: TTabSheet
    250250        Caption = 'Target code'
    251         ClientHeight = 387
    252         ClientWidth = 390
     251        ClientHeight = 192
     252        ClientWidth = 265
    253253        object MemoTarget: TMemo
    254254          Left = 0
     
    267267      Left = 0
    268268      Height = 118
    269       Top = 419
    270       Width = 392
     269      Top = 224
     270      Width = 267
    271271      ActivePage = TabSheetMessages
    272272      Align = alBottom
     
    282282      Left = 0
    283283      Height = 5
    284       Top = 414
    285       Width = 392
     284      Top = 219
     285      Width = 267
    286286      Align = alBottom
    287287      ResizeAnchor = akBottom
  • trunk/Forms/UFormMain.pas

    r38 r39  
    255255
    256256procedure TMainForm.TargetStateChanged(Sender: TObject);
    257 var
    258   DebugStep: TDebugStep;
    259 begin
     257begin
     258  UpdateInterface;
    260259  if CurrentTarget.State = rsPaused then
    261260    AProgramShowExecutionPoint.Execute;
    262   UpdateInterface;
    263261end;
    264262
     
    322320  FormMesssages.Align := alClient;
    323321  FormMesssages.Show;
     322  PageControlRight.Width := MainForm.Width div 2;
     323  PageControlBottom.Height := MainForm.Height div 5;
    324324end;
    325325
     
    440440procedure TMainForm.AProgramRunExecute(Sender: TObject);
    441441begin
    442   FormCPU.LastStepCounter := 0;
    443   FormCPU.Show;
    444442  if CurrentTarget is TTargetInterpretter then
    445443    TTargetInterpretter(CurrentTarget).Input := FormInput.MemoInput.Lines.Text;
     
    595593  DebugStep: TDebugStep;
    596594begin
    597   DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart);
    598595  if CurrentTarget.State = rsStopped then begin
    599596    if not CurrentTarget.Compiled then AProgramCompile.Execute;
     597    DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart);
    600598    CurrentTarget.BreakPoints.SetSystem(DebugStep.TargetPosition);
    601599    AProgramRun.Execute;
    602   end else CurrentTarget.RunToCursor(DebugStep.TargetPosition);
     600  end else begin
     601    DebugStep := CurrentTarget.DebugSteps.SearchBySourcePos(MemoSource.SelStart);
     602    CurrentTarget.RunToCursor(DebugStep.TargetPosition);
     603  end;
    603604end;
    604605
  • trunk/Forms/UFormMemory.lfm

    r38 r39  
    44  Top = 32
    55  Width = 391
    6   Caption = 'FormMemory'
     6  Caption = 'Memory'
    77  ClientHeight = 259
    88  ClientWidth = 391
  • trunk/Forms/UFormMemory.lrt

    r38 r39  
    1 TFORMMEMORY.CAPTION=FormMemory
     1TFORMMEMORY.CAPTION=Memory
    22TFORMMEMORY.LABEL6.CAPTION=Memory:
    33TFORMMEMORY.LISTVIEWMEMORY.COLUMNS[0].CAPTION=Address
  • trunk/Forms/UFormMessages.lfm

    r38 r39  
    44  Top = 32
    55  Width = 320
    6   Caption = 'FormMesssages'
     6  Caption = 'Messages'
    77  ClientHeight = 240
    88  ClientWidth = 320
  • trunk/Forms/UFormMessages.lrt

    r38 r39  
    1 TFORMMESSSAGES.CAPTION=FormMesssages
     1TFORMMESSSAGES.CAPTION=Messages
  • trunk/Forms/UFormOutput.lfm

    r38 r39  
    44  Top = 32
    55  Width = 320
    6   Caption = 'FormOutput'
     6  Caption = 'Output'
    77  ClientHeight = 240
    88  ClientWidth = 320
  • trunk/Forms/UFormOutput.lrt

    r38 r39  
    1 TFORMOUTPUT.CAPTION=FormOutput
     1TFORMOUTPUT.CAPTION=Output
    22TFORMOUTPUT.LABEL2.CAPTION=Output:
  • trunk/Languages/LazFuckIDE.cs.po

    r38 r39  
    4040
    4141#: tformcpu.caption
     42#| msgid "Interpretter"
    4243msgctxt "tformcpu.caption"
    43 msgid "Interpretter"
    44 msgstr "Interpreter"
     44msgid "CPU"
     45msgstr "CPU"
    4546
    4647#: tformcpu.label3.caption
     
    8586
    8687#: tforminput.caption
    87 msgid "FormInput"
    88 msgstr ""
     88msgid "Input"
     89msgstr "Vstup"
    8990
    9091#: tforminput.label1.caption
     
    9495
    9596#: tformmemory.caption
    96 msgid "FormMemory"
    97 msgstr ""
     97msgid "Memory"
     98msgstr "Paměť"
    9899
    99100#: tformmemory.label6.caption
     
    113114
    114115#: tformmesssages.caption
    115 msgid "FormMesssages"
    116 msgstr ""
     116#| msgid "Messsages"
     117msgctxt "tformmesssages.caption"
     118msgid "Messages"
     119msgstr "Zprávy"
    117120
    118121#: tformoutput.caption
    119 msgid "FormOutput"
    120 msgstr ""
     122msgid "Output"
     123msgstr "VÃœstup"
    121124
    122125#: tformoutput.label2.caption
     
    246249#: tmainform.aprogramshowexecutionpoint.caption
    247250msgid "Show execution point"
    248 msgstr ""
     251msgstr "Ukázat bod vykonání"
    249252
    250253#: tmainform.aprogramstepinto.caption
     
    356359msgctxt "tmainform.tabsheetdebug.caption"
    357360msgid "Debug"
    358 msgstr ""
     361msgstr "Ladění"
    359362
    360363#: tmainform.tabsheetmessages.caption
    361364msgctxt "tmainform.tabsheetmessages.caption"
    362365msgid "Messages"
    363 msgstr ""
     366msgstr "Zprávy"
    364367
    365368#: tmainform.tabsheetsource.caption
     
    537540#: utargetinterpretter.sprogramnotrunning
    538541msgid "Program not running"
    539 msgstr ""
     542msgstr "Program neběşí"
    540543
    541544#: utargetinterpretter.sprogramupperlimit
  • trunk/Languages/LazFuckIDE.po

    r38 r39  
    3333#: tformcpu.caption
    3434msgctxt "TFORMCPU.CAPTION"
    35 msgid "Interpretter"
     35msgid "CPU"
    3636msgstr ""
    3737
     
    7777
    7878#: tforminput.caption
    79 msgid "FormInput"
     79msgid "Input"
    8080msgstr ""
    8181
     
    8686
    8787#: tformmemory.caption
    88 msgid "FormMemory"
     88msgid "Memory"
    8989msgstr ""
    9090
     
    105105
    106106#: tformmesssages.caption
    107 msgid "FormMesssages"
     107msgctxt "tformmesssages.caption"
     108msgid "Messages"
    108109msgstr ""
    109110
    110111#: tformoutput.caption
    111 msgid "FormOutput"
     112msgid "Output"
    112113msgstr ""
    113114
  • trunk/Target/UTarget.pas

    r36 r39  
    4444    procedure AddItem(TargetAddress: Integer);
    4545    procedure SetSystem(TargetAddress: Integer);
     46    procedure AddSystem(TargetAddress: Integer);
    4647    procedure ClearSystem;
    4748    function SearchByTargetPos(Pos: Integer): TBreakPoint;
     
    126127
    127128procedure TBreakPointList.SetSystem(TargetAddress: Integer);
     129begin
     130  ClearSystem;
     131  AddSystem(TargetAddress);
     132end;
     133
     134procedure TBreakPointList.AddSystem(TargetAddress: Integer);
    128135var
    129136  NewItem: TBreakPoint;
    130137begin
    131   ClearSystem;
    132138  NewItem := TBreakPoint.Create;
    133139  NewItem.TargetAddress := TargetAddress;
  • trunk/Target/UTargetInterpretter.pas

    r36 r39  
    1414
    1515  TTargetInterpretterThread = class(TThread)
     16  private
     17    FNewState: TRunState;
     18    procedure DoSetState;
     19    procedure SetStateSafe(State: TRunState);
     20  public
    1621    Parent: TTargetInterpretter;
    1722    procedure Execute; override;
     
    98103
    99104procedure TTargetInterpretterThread.Execute;
     105var
     106  BreakPoint: TBreakPoint;
    100107begin
    101108  with Parent do
     
    104111      if State = rsRunning then begin
    105112        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);
    108116        end else begin
    109117          FCommandTable[FProgram[SourcePosition]];
     
    114122      if State = rsPaused then Sleep(1);
    115123    end;
    116     State := rsStopped;
     124    if State <> rsStopped then SetStateSafe(rsStopped);
    117125  until Terminated or (State = rsStopped);
     126end;
     127
     128procedure TTargetInterpretterThread.DoSetState;
     129begin
     130  Parent.State := FNewState;
     131end;
     132
     133procedure TTargetInterpretterThread.SetStateSafe(State: TRunState);
     134begin
     135  FNewState := State;
     136  Synchronize(DoSetState);
    118137end;
    119138
     
    307326    FProgramBreakpoints[I] := False;
    308327  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;
    310330end;
    311331
     
    326346procedure TTargetInterpretter.Run;
    327347begin
     348  PrepareBreakPoints;
    328349  if FState = rsStopped then begin
    329350    Reset;
     
    347368var
    348369  Step: TDebugStep;
     370  StepIndex: Integer;
     371  Nesting: Integer;
    349372begin
    350373  if State = rsPaused then begin
    351374    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);
    353385    Run;
    354386  end else raise Exception.Create(SProgramNotRunning);
     
    363395  if State = rsPaused then begin
    364396    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
    365402    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);
    375405    end else BreakPoints.SetSystem(Step.TargetPosition + 1);
    376406    Run;
     
    382412  Step: TDebugStep;
    383413  StepIndex: Integer;
     414  Nesting: Integer;
    384415begin
    385416  if State = rsPaused then begin
    386417    Step := DebugSteps.SearchByTargetPos(SourcePosition);
    387418    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;
    389425    if StepIndex < DebugSteps.Count then begin
    390426      Breakpoints.SetSystem(TDebugStep(DebugSteps[StepIndex]).TargetPosition);
    391       Run;
    392427    end;
     428    Run;
    393429  end else raise Exception.Create(SProgramNotRunning);
    394430end;
Note: See TracChangeset for help on using the changeset viewer.