fpmdebug.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. {
  2. This file is part of the Free Pascal Integrated Development Environment
  3. Copyright (c) 1998 by Berczi Gabor
  4. Debug menu entries
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$ifdef SUPPORT_REMOTE}
  12. function GetRemoteString : string;
  13. var
  14. St : string;
  15. begin
  16. St:=RemoteSendCommand;
  17. If RemoteConfig<>'' then
  18. ReplaceStrI(St,'$CONFIG','-F '+RemoteConfig)
  19. else
  20. ReplaceStrI(St,'$CONFIG','');
  21. If RemoteIdent<>'' then
  22. ReplaceStrI(St,'$IDENT','-i '+RemoteIdent)
  23. else
  24. ReplaceStrI(St,'$IDENT','');
  25. ReplaceStrI(St,'$LOCALFILE',GDBFileName(ExeFile));
  26. ReplaceStrI(St,'$REMOTEDIR',RemoteDir);
  27. ReplaceStrI(St,'$REMOTEMACHINE',RemoteMachine);
  28. GetRemoteString:=st;
  29. end;
  30. procedure TIDEApp.TransferRemote;
  31. var
  32. S,SendCommand : string;
  33. Executed : boolean;
  34. begin
  35. SendCommand:=GetRemoteString;
  36. if SendCommand<>'' then
  37. begin
  38. s:='scp'+exeext;
  39. if LocateExeFile(s) then
  40. Executed:=DoExecute(s,SendCommand,'','','',exNormal)
  41. else
  42. Executed:=DoExecute('scp',SendCommand,'','','',exNormal);
  43. if Executed then
  44. begin
  45. if (DosError<>0) or (DosExitCode<>0) then
  46. ErrorBox(#3'Execution of'#13#3+s+' '+SendCommand+#13#3+
  47. 'returned ('+inttostr(DosError)+','+inttostr(DosExitCode)+')',nil);
  48. end
  49. else
  50. ErrorBox(#3'Unable to execute'#13#3+s+' '+SendCommand,nil);
  51. end
  52. else
  53. ErrorBox(#3'Unable to transfer executable',nil);
  54. end;
  55. {$endif SUPPORT_REMOTE}
  56. procedure TIDEApp.DoUserScreenWindow;
  57. begin
  58. {$ifdef HASAMIGA}
  59. Exit; // Do not open the Userscreen on AMIGA systems, its not closeable
  60. {$endif}
  61. if UserScreenWindow=nil then
  62. begin
  63. New(UserScreenWindow, Init(UserScreen, SearchFreeWindowNo));
  64. Desktop^.Insert(UserScreenWindow);
  65. end;
  66. UserScreenWindow^.MakeFirst;
  67. end;
  68. procedure TIDEApp.DoCloseUserScreenWindow;
  69. begin
  70. if Assigned(UserScreenWindow) then
  71. Message(UserScreenWindow,evCommand,cmClose,nil);
  72. end;
  73. procedure TIDEApp.DoUserScreen;
  74. var Event : TEvent;
  75. ev : TMouseEvent;
  76. Clear : Boolean;
  77. begin
  78. if UserScreen=nil then
  79. begin
  80. ErrorBox(msg_userscreennotavailable,nil);
  81. Exit;
  82. end;
  83. ShowUserScreen;
  84. InitKeyBoard;
  85. { closing the user screen on mouse events makes copy paste impossible }
  86. repeat
  87. repeat
  88. GiveUpTimeSlice;
  89. Drivers.GetKeyEvent(Event);
  90. until Event.What=evKeyboard;
  91. Clear:=true;
  92. if not UserScreen^.CanScroll then
  93. Clear:=false
  94. else
  95. case Event.keycode of
  96. kbPgUp : UserScreen^.Scroll(-20);
  97. kbPgDn : UserScreen^.Scroll(20);
  98. kbUp : UserScreen^.Scroll(-1);
  99. kbDown : UserScreen^.Scroll(1);
  100. kbHome : UserScreen^.Scroll(-1024);
  101. kbEnd : UserScreen^.Scroll(+1024);
  102. else
  103. Clear:=false;
  104. end;
  105. if Clear then
  106. ClearEvent(Event);
  107. until Event.what=evKeyboard;
  108. while (Keyboard.PollKeyEvent<>0) do
  109. Keyboard.GetKeyEvent;
  110. DoneKeyboard;
  111. ShowIDEScreen;
  112. end;
  113. procedure TIDEApp.DoShowCallStack;
  114. begin
  115. {$ifdef NODEBUG}
  116. NoDebugger;
  117. {$else}
  118. If not assigned(StackWindow) then
  119. InitStackWindow
  120. else
  121. StackWindow^.MakeFirst;
  122. {$endif NODEBUG}
  123. end;
  124. procedure TIDEApp.DoShowDisassembly;
  125. begin
  126. {$ifdef NODEBUG}
  127. NoDebugger;
  128. {$else}
  129. If not assigned(DisassemblyWindow) then
  130. InitDisassemblyWindow
  131. else
  132. DisassemblyWindow^.MakeFirst;
  133. DisassemblyWindow^.LoadFunction('');
  134. {$endif NODEBUG}
  135. end;
  136. procedure TIDEApp.DoShowRegisters;
  137. begin
  138. {$ifdef NODEBUG}
  139. NoDebugger;
  140. {$else}
  141. If not assigned(RegistersWindow) then
  142. InitRegistersWindow
  143. else
  144. RegistersWindow^.MakeFirst;
  145. {$endif NODEBUG}
  146. end;
  147. procedure TIDEApp.DoShowFPU;
  148. begin
  149. {$ifdef NODEBUG}
  150. NoDebugger;
  151. {$else}
  152. If not assigned(FPUWindow) then
  153. InitFPUWindow
  154. else
  155. FPUWindow^.MakeFirst;
  156. {$endif NODEBUG}
  157. end;
  158. procedure TIDEApp.DoShowVector;
  159. begin
  160. {$ifdef NODEBUG}
  161. NoDebugger;
  162. {$else}
  163. If not assigned(VectorWindow) then
  164. InitVectorWindow
  165. else
  166. VectorWindow^.MakeFirst;
  167. {$endif NODEBUG}
  168. end;
  169. procedure TIDEApp.DoShowBreakpointList;
  170. begin
  171. {$ifdef NODEBUG}
  172. NoDebugger;
  173. {$else}
  174. If assigned(BreakpointsWindow) then
  175. begin
  176. BreakpointsWindow^.Update;
  177. BreakpointsWindow^.Show;
  178. BreakpointsWindow^.MakeFirst;
  179. end
  180. else
  181. begin
  182. New(BreakpointsWindow,Init);
  183. Desktop^.Insert(BreakpointsWindow);
  184. end;
  185. {$endif NODEBUG}
  186. end;
  187. procedure TIDEApp.DoShowWatches;
  188. begin
  189. {$ifdef NODEBUG}
  190. NoDebugger;
  191. {$else}
  192. If assigned(WatchesWindow) then
  193. begin
  194. WatchesWindow^.Update;
  195. WatchesWindow^.MakeFirst;
  196. end
  197. else
  198. begin
  199. New(WatchesWindow,Init);
  200. Desktop^.Insert(WatchesWindow);
  201. end;
  202. {$endif NODEBUG}
  203. end;
  204. procedure TIDEApp.DoAddWatch;
  205. {$ifdef NODEBUG}
  206. begin
  207. NoDebugger;
  208. end;
  209. {$else}
  210. var
  211. P: PWatch;
  212. EditorWindow : PSourceWindow;
  213. EditorWasFirst : boolean;
  214. S : string;
  215. begin
  216. EditorWindow:=FirstEditorWindow;
  217. { Leave the editor first, but only if there was already an WatchesWindow }
  218. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  219. assigned(WatchesWindow);
  220. If assigned(EditorWindow) then
  221. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  222. else
  223. S:='';
  224. P:=New(PWatch,Init(S));
  225. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  226. begin
  227. WatchesCollection^.Insert(P);
  228. WatchesCollection^.Update;
  229. DoShowWatches;
  230. if EditorWasFirst then
  231. EditorWindow^.MakeFirst;
  232. end
  233. else
  234. dispose(P,Done);
  235. end;
  236. {$endif NODEBUG}
  237. {$ifdef NODEBUG}
  238. procedure TIDEapp.do_evaluate;
  239. begin
  240. nodebugger;
  241. end;
  242. {$else}
  243. procedure TIDEapp.do_evaluate;
  244. var d:Pevaluate_dialog;
  245. r:Trect;
  246. begin
  247. desktop^.getextent(r);
  248. r.b.x:=r.b.x*3 div 4;
  249. r.b.y:=12;
  250. new(d,init(r));
  251. desktop^.execview(d);
  252. dispose(d,done);
  253. end;
  254. {$endif}