~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to debugger/test/debugtestform.pp

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{ $Id: debugtestform.pp 23967 2010-03-12 16:04:05Z vincents $ }
2
 
{                        ----------------------------------------
3
 
                          debugtestform.pp  -  Debugger test app
4
 
                         ----------------------------------------
5
 
 
6
 
 @created(Wed Feb 25st WET 2001)
7
 
 @lastmod($Date: 2010-03-12 16:04:05 +0000 (Fri, 12 Mar 2010) $)
8
 
 @author(Marc Weustink <marc@@dommelstein.net>)
9
 
 
10
 
***************************************************************************
11
 
 *                                                                         *
12
 
 *   This program is free software; you can redistribute it and/or modify  *
13
 
 *   it under the terms of the GNU General Public License as published by  *
14
 
 *   the Free Software Foundation; either version 2 of the License, or     *
15
 
 *   (at your option) any later version.                                   *
16
 
 *                                                                         *
17
 
 ***************************************************************************/
18
 
}
19
 
unit debugtestform;
20
 
 
21
 
{$mode objfpc}
22
 
{$H+}
23
 
 
24
 
interface
25
 
 
26
 
uses
27
 
  Classes, Graphics, Controls, Forms, Dialogs, LResources,
28
 
  Buttons, StdCtrls, Debugger, DebugOutputForm, BreakpointsDlg,
29
 
  LocalsDlg, WatchesDlg, CallStackDlg;
30
 
 
31
 
 
32
 
type
33
 
  TDebugTestForm = class(TForm)
34
 
    cmdInit : TButton;
35
 
    cmdDone : TButton;
36
 
    cmdRun : TButton;
37
 
    cmdPause : TButton;
38
 
    cmdStop : TButton;
39
 
    cmdStep : TButton;
40
 
    cmdStepInto : TButton;
41
 
    cmdSetBreak : TButton;
42
 
    cmdResetBreak : TButton;
43
 
    lblFileName: TLabel;
44
 
    lblAdress: TLabel;
45
 
    lblSource: TLabel;
46
 
    lblLine: TLabel;
47
 
    lblFunc: TLabel;
48
 
    lblState: TLabel;
49
 
    lblBreak: TLabel;
50
 
    lblEvaluate: TLabel;
51
 
    lblTest: TLabel;
52
 
    txtLog: TMemo;
53
 
    cmdCommand: TButton;
54
 
    cmdClear: TButton;
55
 
    txtCommand: TEdit;
56
 
    txtFileName: TEdit;
57
 
    txtBreakFile: TEdit;
58
 
    txtBreakLine: TEdit;
59
 
    chkBreakEnable: TCheckBox;
60
 
    txtEvaluate: TEdit;
61
 
    lblEvalResult: TLabel;
62
 
    cmdEvaluate: TButton;
63
 
    procedure FormCreate(Sender: TObject);
64
 
    procedure FormDestroy(Sender: TObject);
65
 
    procedure cmdInitClick(Sender: TObject);
66
 
    procedure cmdDoneClick(Sender: TObject);
67
 
    procedure cmdRunClick(Sender: TObject);
68
 
    procedure cmdPauseClick(Sender: TObject);
69
 
    procedure cmdStopClick(Sender: TObject);
70
 
    procedure cmdStepClick(Sender: TObject);
71
 
    procedure cmdStepIntoClick(Sender: TObject);
72
 
    procedure cmdCommandClick(Sender: TObject);
73
 
    procedure cmdClearClick(Sender: TObject);
74
 
    procedure cmdSetBreakClick(Sender: TObject);
75
 
    procedure cmdResetBreakClick(Sender: TObject);
76
 
    procedure cmdEvaluateClick(Sender: TObject);
77
 
    procedure chkBreakEnableClick(Sender: TObject);
78
 
  private
79
 
    FDebugger: TDebugger;
80
 
    FOutputForm: TDBGOutputForm;
81
 
    FBreakpointDlg: TBreakpointsDlg;
82
 
    FLocalsDlg: TLocalsDlg;
83
 
    FWatchesDlg: TWatchesDlg;
84
 
    FCallStackDlg: TCallStackDlg;
85
 
    FDummy: Boolean;
86
 
    procedure DBGState(Sender: TObject);
87
 
    procedure DBGCurrent(Sender: TObject; const ALocation: TDBGLocationRec);
88
 
    procedure DBGOutput(Sender: TObject; const AText: String);
89
 
    procedure DBGTargetOutput(Sender: TObject; const AText: String);
90
 
    procedure OutputFormDestroy(Sender: TObject);
91
 
  protected
92
 
    procedure Loaded; override;
93
 
  public
94
 
    destructor Destroy; override;
95
 
  published
96
 
    property Dummy: Boolean read FDummy write FDummy; // insert some dummies until fpcbug #1888 is fixed
97
 
    property Dummy1: Boolean read FDummy write FDummy; // insert some dummies until fpcbug #1888 is fixed
98
 
    property Dummy2: Boolean read FDummy write FDummy; // insert some dummies until fpcbug #1888 is fixed
99
 
    property Dummy3: Boolean read FDummy write FDummy; // insert some dummies until fpcbug #1888 is fixed
100
 
  end;
101
 
 
102
 
var
103
 
  DebugTestFrm: TDebugTestForm;
104
 
 
105
 
implementation
106
 
 
107
 
uses
108
 
  SysUtils,
109
 
  GDBMIDebugger;
110
 
 
111
 
procedure TDebugTestForm.Loaded;
112
 
begin
113
 
  inherited Loaded;
114
 
 
115
 
  // Not yet through resources
116
 
  //txtLog.Scrollbars := ssBoth;
117
 
end;
118
 
 
119
 
destructor TDebugTestForm.Destroy;
120
 
begin
121
 
  // This shouldn't be needed, but the OnDestroy event isn't called
122
 
  inherited;
123
 
//  FormDestroy(Self);
124
 
end;
125
 
 
126
 
procedure TDebugTestForm.FormCreate(Sender: TObject);
127
 
begin
128
 
  txtLog.Lines.Clear;
129
 
  FDebugger := nil;
130
 
  FBreakpointDlg := TBreakpointsDlg.Create(Application);
131
 
  FBreakpointDlg.Show;
132
 
 
133
 
  FLocalsDlg := TLocalsDlg.Create(Application);
134
 
  FLocalsDlg.Show;
135
 
 
136
 
  FWatchesDlg := TWatchesDlg.Create(Application);
137
 
  FWatchesDlg.Show;
138
 
 
139
 
  FOutputForm := TDBGOutputForm.Create(Application);
140
 
  FOutputForm.Show;
141
 
  
142
 
  FCallStackDlg := TCallStackDlg.Create(Application);
143
 
  FCallStackDlg.Show;
144
 
end;
145
 
 
146
 
procedure TDebugTestForm.FormDestroy(Sender: TObject);
147
 
begin  
148
 
  try
149
 
    FBreakpointDlg.Debugger := nil;
150
 
    FLocalsDlg.Debugger := nil;
151
 
    FWatchesDlg.Debugger := nil;
152
 
    FOutputForm.Debugger := nil;
153
 
    FCallStackDlg.Debugger := nil;
154
 
  except
155
 
    on Exception do;
156
 
  end;
157
 
  FDebugger.Free;
158
 
  FDebugger := nil;
159
 
end;
160
 
 
161
 
procedure TDebugTestForm.cmdInitClick(Sender: TObject);
162
 
begin
163
 
  if FDebugger = nil
164
 
  then begin
165
 
    FDebugger := TGDBMIDebugger.Create('/usr/bin/gdb');
166
 
    FDebugger.OnDbgOutput := @DBGOutput;
167
 
    FDebugger.OnOutput := @DBGTargetOutput;
168
 
    FDebugger.OnCurrent := @DBGCurrent;
169
 
    FDebugger.OnState := @DBGState;
170
 
    TDBGBreakPointGroup(FDebugger.BreakPointGroups.Add).Name := 'Default';
171
 
 
172
 
    FBreakpointDlg.Debugger := FDebugger;
173
 
    FLocalsDlg.Debugger := FDebugger;
174
 
    FWatchesDlg.Debugger := FDebugger;
175
 
    FOutputForm.Debugger := FDebugger;
176
 
    FCallStackDlg.Debugger := FDebugger;   
177
 
  end;
178
 
  FDebugger.Init;
179
 
  FDebugger.FileName := txtFileName.Text;
180
 
end;
181
 
 
182
 
procedure TDebugTestForm.cmdDoneClick(Sender: TObject);
183
 
begin
184
 
  if FDebugger <> nil
185
 
  then begin
186
 
    FDebugger.Done;
187
 
    FBreakpointDlg.Debugger := nil;
188
 
    FLocalsDlg.Debugger := nil;
189
 
    FWatchesDlg.Debugger := nil;
190
 
    FOutputForm.Debugger := nil;
191
 
    FWatchesDlg.Debugger := nil;
192
 
    FDebugger.Free;
193
 
    FDebugger := nil;
194
 
  end;
195
 
end;
196
 
 
197
 
procedure TDebugTestForm.cmdRunClick(Sender: TObject);
198
 
begin
199
 
  if FDebugger <> nil
200
 
  then begin
201
 
    FDebugger.FileName := txtFileName.Text;
202
 
    FDebugger.Run;
203
 
  end;
204
 
end;
205
 
 
206
 
procedure TDebugTestForm.cmdPauseClick(Sender: TObject);
207
 
begin
208
 
  if FDebugger <> nil
209
 
  then begin
210
 
    FDebugger.Pause;
211
 
  end;
212
 
end;
213
 
 
214
 
procedure TDebugTestForm.cmdStepClick(Sender: TObject);
215
 
begin
216
 
  if FDebugger <> nil
217
 
  then begin
218
 
    FDebugger.StepOver;
219
 
  end;
220
 
end;
221
 
 
222
 
procedure TDebugTestForm.cmdStepIntoClick(Sender: TObject);
223
 
begin
224
 
  if FDebugger <> nil
225
 
  then begin
226
 
    FDebugger.StepInto;
227
 
  end;
228
 
end;
229
 
 
230
 
procedure TDebugTestForm.cmdStopClick(Sender: TObject);
231
 
begin
232
 
  if FDebugger <> nil
233
 
  then begin
234
 
    FDebugger.Stop;
235
 
  end;
236
 
end;
237
 
 
238
 
procedure TDebugTestForm.cmdCommandClick(Sender: TObject);
239
 
begin
240
 
  TGDBMIDebugger(FDebugger).TestCmd(txtCommand.Text);
241
 
end;
242
 
 
243
 
procedure TDebugTestForm.cmdClearClick(Sender: TObject);
244
 
begin
245
 
  txtLog.Lines.Clear;
246
 
end;
247
 
 
248
 
procedure TDebugTestForm.cmdSetBreakClick(Sender: TObject);
249
 
begin
250
 
  FDebugger.Breakpoints.Add(txtBreakFile.Text, StrToIntDef(txtBreakLine.Text, 1));
251
 
end;
252
 
 
253
 
procedure TDebugTestForm.cmdResetBreakClick(Sender: TObject);
254
 
begin
255
 
  if FDebugger.Breakpoints.Count > 0
256
 
  then FDebugger.Breakpoints[0].Free;
257
 
end;
258
 
 
259
 
procedure TDebugTestForm.chkBreakEnableClick(Sender: TObject);
260
 
begin
261
 
  if FDebugger.Breakpoints.Count > 0
262
 
  then FDebugger.Breakpoints[0].Enabled := chkBreakEnable.Checked;
263
 
end;
264
 
 
265
 
procedure TDebugTestForm.cmdEvaluateClick(Sender: TObject);
266
 
var
267
 
  S: String;
268
 
  ATypeInfo: TDBGType;
269
 
begin
270
 
  ATypeInfo := nil;
271
 
  FDebugger.Evaluate(txtEvaluate.Text, S, ATypeInfo);
272
 
  lblEvalResult.Caption := S;
273
 
end;
274
 
 
275
 
procedure TDebugTestForm.OutputFormDestroy(Sender: TObject);
276
 
begin
277
 
  FOutputForm := nil;
278
 
end;
279
 
 
280
 
procedure TDebugTestForm.DBGOutput(Sender: TObject; const AText: String);
281
 
begin
282
 
  txtLog.Lines.Add(AText);
283
 
end;
284
 
 
285
 
procedure TDebugTestForm.DBGTargetOutput(Sender: TObject; const AText: String);
286
 
begin
287
 
  if FOutputForm <> nil
288
 
  then FOutputForm.AddText(AText);
289
 
end;
290
 
 
291
 
procedure TDebugTestForm.DBGCurrent(Sender: TObject; const ALocation: TDBGLocationRec);
292
 
begin
293
 
  lblAdress.Caption := Format('$%p', [ALocation.Address]);
294
 
  lblSource.Caption := ALocation.SrcFile;
295
 
  lblLine.Caption := IntToStr(ALocation.SrcLine);
296
 
  lblFunc.Caption := ALocation.FuncName;
297
 
end;
298
 
 
299
 
procedure TDebugTestForm.DBGState(Sender: TObject);
300
 
var
301
 
  n: Integer;
302
 
begin
303
 
  case FDebugger.State of
304
 
    dsNone :lblState.Caption := 'dsNone ';
305
 
    dsIdle :lblState.Caption := 'dsIdle ';
306
 
    dsStop :lblState.Caption := 'dsStop ';
307
 
    dsPause: begin
308
 
      lblState.Caption := 'dsPause';
309
 
      txtLog.Lines.Add('[locals]');
310
 
      for n := 0 to FDebugger.Locals.Count - 1 do
311
 
      begin
312
 
        txtLog.Lines.Add(FDebugger.Locals.Names[n] + ':'+ FDebugger.Locals.Values[n]);
313
 
      end;
314
 
    end;
315
 
    dsRun  :lblState.Caption := 'dsRun  ';
316
 
    dsError:lblState.Caption := 'dsError';
317
 
  else
318
 
    lblState.Caption := '?';
319
 
  end;
320
 
end;
321
 
 
322
 
initialization
323
 
  {$I debugtestform.lrs}
324
 
 
325
 
end.