summaryrefslogtreecommitdiff
path: root/fpcsrc/ide/fpmdebug.inc
blob: 8cad30cb25af951e7bbe281a71b0b105e0535903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
{
    This file is part of the Free Pascal Integrated Development Environment
    Copyright (c) 1998 by Berczi Gabor

    Debug menu entries

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{$ifdef SUPPORT_REMOTE}
function GetRemoteString : string;
var
  St : string;
begin
  St:=RemoteSendCommand;
  If RemoteConfig<>'' then
    ReplaceStrI(St,'$CONFIG','-F '+RemoteConfig)
  else
    ReplaceStrI(St,'$CONFIG','');
  If RemoteIdent<>'' then
    ReplaceStrI(St,'$IDENT','-i '+RemoteIdent)
  else
    ReplaceStrI(St,'$IDENT','');
  ReplaceStrI(St,'$LOCALFILE',GDBFileName(ExeFile));
  ReplaceStrI(St,'$REMOTEDIR',RemoteDir);
  ReplaceStrI(St,'$REMOTEMACHINE',RemoteMachine);
  GetRemoteString:=st;
end;

procedure TIDEApp.TransferRemote;
var
  S,SendCommand : string;
  Executed : boolean;
begin
  SendCommand:=GetRemoteString;
  if SendCommand<>'' then
    begin
      s:='scp'+exeext;
      if LocateExeFile(s) then
        Executed:=DoExecute(s,SendCommand,'','','',exNormal)
      else
        Executed:=DoExecute('scp',SendCommand,'','','',exNormal);
      if Executed then
        begin
         if (DosError<>0) or (DosExitCode<>0) then
          ErrorBox(#3'Execution of'#13#3+s+' '+SendCommand+#13#3+
            'returned ('+inttostr(DosError)+','+inttostr(DosExitCode)+')',nil);
        end
      else
        ErrorBox(#3'Unable to execute'#13#3+s+' '+SendCommand,nil);

    end
  else
    ErrorBox(#3'Unable to transfer executable',nil);
end;
{$endif SUPPORT_REMOTE}

procedure TIDEApp.DoUserScreenWindow;
begin
  if UserScreenWindow=nil then
    begin
     New(UserScreenWindow, Init(UserScreen, SearchFreeWindowNo));
     Desktop^.Insert(UserScreenWindow);
    end;
  UserScreenWindow^.MakeFirst;
end;

procedure TIDEApp.DoCloseUserScreenWindow;
begin
  if Assigned(UserScreenWindow) then
    Message(UserScreenWindow,evCommand,cmClose,nil);
end;

procedure TIDEApp.DoUserScreen;
var Event : TEvent;
    ev    : TMouseEvent;
    Clear : Boolean;
begin
  if UserScreen=nil then
   begin
     ErrorBox(msg_userscreennotavailable,nil);
     Exit;
   end;

  ShowUserScreen;

  InitKeyBoard;
  { closing the user screen on mouse events makes copy paste impossible }
  repeat
    repeat
      GiveUpTimeSlice;
      Drivers.GetKeyEvent(Event);
    until Event.What=evKeyboard;
    Clear:=true;
    if not UserScreen^.CanScroll then
      Clear:=false
    else
      case Event.keycode of
        kbPgUp : UserScreen^.Scroll(-20);
        kbPgDn : UserScreen^.Scroll(20);
        kbUp : UserScreen^.Scroll(-1);
        kbDown : UserScreen^.Scroll(1);
        kbHome : UserScreen^.Scroll(-1024);
        kbEnd : UserScreen^.Scroll(+1024);
      else
         Clear:=false;
      end;
    if Clear then
      ClearEvent(Event);
  until Event.what=evKeyboard;
  while (Keyboard.PollKeyEvent<>0) do
    Keyboard.GetKeyEvent;
  DoneKeyboard;

  ShowIDEScreen;
end;

procedure TIDEApp.DoShowCallStack;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If not assigned(StackWindow) then
    InitStackWindow
  else
    StackWindow^.MakeFirst;
{$endif NODEBUG}
end;


procedure TIDEApp.DoShowDisassembly;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If not assigned(DisassemblyWindow) then
    InitDisassemblyWindow
  else
    DisassemblyWindow^.MakeFirst;
  DisassemblyWindow^.LoadFunction('');
{$endif NODEBUG}
end;


procedure TIDEApp.DoShowRegisters;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If not assigned(RegistersWindow) then
    InitRegistersWindow
  else
    RegistersWindow^.MakeFirst;
{$endif NODEBUG}
end;

procedure TIDEApp.DoShowFPU;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If not assigned(FPUWindow) then
    InitFPUWindow
  else
    FPUWindow^.MakeFirst;
{$endif NODEBUG}
end;


procedure TIDEApp.DoShowVector;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If not assigned(VectorWindow) then
    InitVectorWindow
  else
    VectorWindow^.MakeFirst;
{$endif NODEBUG}
end;

procedure TIDEApp.DoShowBreakpointList;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If assigned(BreakpointsWindow) then
    begin
      BreakpointsWindow^.Update;
      BreakpointsWindow^.Show;
      BreakpointsWindow^.MakeFirst;
    end
  else
    begin
      New(BreakpointsWindow,Init);
      Desktop^.Insert(BreakpointsWindow);
    end;
{$endif NODEBUG}
end;

procedure TIDEApp.DoShowWatches;
begin
{$ifdef NODEBUG}
  NoDebugger;
{$else}
  If assigned(WatchesWindow) then
    begin
      WatchesWindow^.Update;
      WatchesWindow^.MakeFirst;
    end
  else
    begin
      New(WatchesWindow,Init);
      Desktop^.Insert(WatchesWindow);
    end;
{$endif NODEBUG}
end;

procedure TIDEApp.DoAddWatch;
{$ifdef NODEBUG}
begin
  NoDebugger;
end;
{$else}
var
  P: PWatch;
  EditorWindow : PSourceWindow;
  EditorWasFirst : boolean;
  S : string;
begin
  EditorWindow:=FirstEditorWindow;
  { Leave the editor first, but only if there was already an WatchesWindow }
  EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
                  assigned(WatchesWindow);
  If assigned(EditorWindow) then
    S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  else
    S:='';
  P:=New(PWatch,Init(S));
  if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
    begin
      WatchesCollection^.Insert(P);
      WatchesCollection^.Update;
      DoShowWatches;
      if EditorWasFirst then
       EditorWindow^.MakeFirst;
    end
  else
    dispose(P,Done);
end;
{$endif NODEBUG}

{$ifdef NODEBUG}
procedure TIDEapp.do_evaluate;

begin
  nodebugger;
end;
{$else}
procedure TIDEapp.do_evaluate;

var d:Pevaluate_dialog;
    r:Trect;

begin
  desktop^.getextent(r);
  r.b.x:=r.b.x*3 div 4;
  r.b.y:=12;
  new(d,init(r));
  desktop^.execview(d);
  dispose(d,done);
end;
{$endif}