fpmdebug.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. procedure TIDEApp.TransferRemote;
  13. var
  14. DoSendCommand : string;
  15. Executed : boolean;
  16. begin
  17. DoSendCommand:=TransformRemoteString(RemoteSendCommand);
  18. if DoSendCommand<>'' then
  19. begin
  20. Executed:=DoExecute(DoSendCommand,'','','send___.out','send___.err',exNormal);
  21. if Executed then
  22. begin
  23. if (DosError<>0) or (DosExitCode<>0) then
  24. ErrorBox(#3'Execution of'#13#3+DoSendCommand+#13#3+
  25. 'returned ('+inttostr(DosError)+','+inttostr(DosExitCode)+')',nil);
  26. ProcessMessageFile('send___.out');
  27. ProcessMessageFile('send___.err');
  28. UpdateToolMessages;
  29. end
  30. else
  31. ErrorBox(#3'Unable to execute'#13#3+DoSendCommand,nil);
  32. end
  33. else
  34. ErrorBox(#3'Unable to transfer executable',nil);
  35. end;
  36. {$endif SUPPORT_REMOTE}
  37. procedure TIDEApp.DoUserScreenWindow;
  38. begin
  39. {$ifdef HASAMIGA}
  40. Exit; // Do not open the Userscreen on AMIGA systems, its not closeable
  41. {$endif}
  42. if UserScreenWindow=nil then
  43. begin
  44. New(UserScreenWindow, Init(UserScreen, SearchFreeWindowNo));
  45. Desktop^.Insert(UserScreenWindow);
  46. end;
  47. UserScreenWindow^.MakeFirst;
  48. end;
  49. procedure TIDEApp.DoCloseUserScreenWindow;
  50. begin
  51. if Assigned(UserScreenWindow) then
  52. Message(UserScreenWindow,evCommand,cmClose,nil);
  53. end;
  54. procedure TIDEApp.DoUserScreen;
  55. var Event : TEvent;
  56. ev : TMouseEvent;
  57. Clear : Boolean;
  58. begin
  59. if UserScreen=nil then
  60. begin
  61. ErrorBox(msg_userscreennotavailable,nil);
  62. Exit;
  63. end;
  64. ShowUserScreen;
  65. InitKeyBoard;
  66. { closing the user screen on mouse events makes copy paste impossible }
  67. repeat
  68. repeat
  69. GiveUpTimeSlice;
  70. Drivers.GetKeyEvent(Event);
  71. until Event.What=evKeyboard;
  72. Clear:=true;
  73. if not UserScreen^.CanScroll then
  74. Clear:=false
  75. else
  76. case Event.keycode of
  77. kbPgUp : UserScreen^.Scroll(-20);
  78. kbPgDn : UserScreen^.Scroll(20);
  79. kbUp : UserScreen^.Scroll(-1);
  80. kbDown : UserScreen^.Scroll(1);
  81. kbHome : UserScreen^.Scroll(-1024);
  82. kbEnd : UserScreen^.Scroll(+1024);
  83. else
  84. Clear:=false;
  85. end;
  86. if Clear then
  87. ClearEvent(Event);
  88. until Event.what=evKeyboard;
  89. while (Keyboard.PollKeyEvent<>0) do
  90. Keyboard.GetKeyEvent;
  91. DoneKeyboard;
  92. ShowIDEScreen;
  93. end;
  94. procedure TIDEApp.DoShowCallStack;
  95. begin
  96. {$ifdef NODEBUG}
  97. NoDebugger;
  98. {$else}
  99. If not assigned(StackWindow) then
  100. InitStackWindow
  101. else
  102. StackWindow^.MakeFirst;
  103. {$endif NODEBUG}
  104. end;
  105. procedure TIDEApp.DoShowDisassembly;
  106. begin
  107. {$ifdef NODEBUG}
  108. NoDebugger;
  109. {$else}
  110. If not assigned(DisassemblyWindow) then
  111. InitDisassemblyWindow
  112. else
  113. DisassemblyWindow^.MakeFirst;
  114. DisassemblyWindow^.LoadFunction('');
  115. {$endif NODEBUG}
  116. end;
  117. procedure TIDEApp.DoShowRegisters;
  118. begin
  119. {$ifdef NODEBUG}
  120. NoDebugger;
  121. {$else}
  122. If not assigned(RegistersWindow) then
  123. InitRegistersWindow
  124. else
  125. RegistersWindow^.MakeFirst;
  126. {$endif NODEBUG}
  127. end;
  128. procedure TIDEApp.DoShowFPU;
  129. begin
  130. {$ifdef NODEBUG}
  131. NoDebugger;
  132. {$else}
  133. If not assigned(FPUWindow) then
  134. InitFPUWindow
  135. else
  136. FPUWindow^.MakeFirst;
  137. {$endif NODEBUG}
  138. end;
  139. procedure TIDEApp.DoShowVector;
  140. begin
  141. {$ifdef NODEBUG}
  142. NoDebugger;
  143. {$else}
  144. If not assigned(VectorWindow) then
  145. InitVectorWindow
  146. else
  147. VectorWindow^.MakeFirst;
  148. {$endif NODEBUG}
  149. end;
  150. procedure TIDEApp.DoShowBreakpointList;
  151. begin
  152. {$ifdef NODEBUG}
  153. NoDebugger;
  154. {$else}
  155. If assigned(BreakpointsWindow) then
  156. begin
  157. BreakpointsWindow^.Update;
  158. BreakpointsWindow^.Show;
  159. BreakpointsWindow^.MakeFirst;
  160. end
  161. else
  162. begin
  163. New(BreakpointsWindow,Init);
  164. Desktop^.Insert(BreakpointsWindow);
  165. end;
  166. {$endif NODEBUG}
  167. end;
  168. procedure TIDEApp.DoShowWatches;
  169. begin
  170. {$ifdef NODEBUG}
  171. NoDebugger;
  172. {$else}
  173. If assigned(WatchesWindow) then
  174. begin
  175. WatchesWindow^.Update;
  176. WatchesWindow^.MakeFirst;
  177. end
  178. else
  179. begin
  180. New(WatchesWindow,Init);
  181. Desktop^.Insert(WatchesWindow);
  182. end;
  183. {$endif NODEBUG}
  184. end;
  185. procedure TIDEApp.DoAddWatch;
  186. {$ifdef NODEBUG}
  187. begin
  188. NoDebugger;
  189. end;
  190. {$else}
  191. var
  192. P: PWatch;
  193. EditorWindow : PSourceWindow;
  194. EditorWasFirst : boolean;
  195. S : string;
  196. begin
  197. EditorWindow:=FirstEditorWindow;
  198. { Leave the editor first, but only if there was already an WatchesWindow }
  199. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  200. assigned(WatchesWindow);
  201. If assigned(EditorWindow) then
  202. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  203. else
  204. S:='';
  205. P:=New(PWatch,Init(S));
  206. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  207. begin
  208. WatchesCollection^.Insert(P);
  209. WatchesCollection^.Update;
  210. DoShowWatches;
  211. if EditorWasFirst then
  212. EditorWindow^.MakeFirst;
  213. end
  214. else
  215. dispose(P,Done);
  216. end;
  217. {$endif NODEBUG}
  218. {$ifdef NODEBUG}
  219. procedure TIDEapp.do_evaluate;
  220. begin
  221. nodebugger;
  222. end;
  223. {$else}
  224. procedure TIDEapp.do_evaluate;
  225. var d:Pevaluate_dialog;
  226. r:Trect;
  227. begin
  228. desktop^.getextent(r);
  229. r.b.x:=r.b.x*3 div 4;
  230. r.b.y:=12;
  231. new(d,init(r));
  232. desktop^.execview(d);
  233. dispose(d,done);
  234. end;
  235. {$endif}