fpmdebug.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. if UserScreenWindow=nil then
  59. begin
  60. New(UserScreenWindow, Init(UserScreen, SearchFreeWindowNo));
  61. Desktop^.Insert(UserScreenWindow);
  62. end;
  63. UserScreenWindow^.MakeFirst;
  64. end;
  65. procedure TIDEApp.DoCloseUserScreenWindow;
  66. begin
  67. if Assigned(UserScreenWindow) then
  68. Message(UserScreenWindow,evCommand,cmClose,nil);
  69. end;
  70. procedure TIDEApp.DoUserScreen;
  71. var Event : TEvent;
  72. ev : TMouseEvent;
  73. Clear : Boolean;
  74. begin
  75. if UserScreen=nil then
  76. begin
  77. ErrorBox(msg_userscreennotavailable,nil);
  78. Exit;
  79. end;
  80. ShowUserScreen;
  81. InitKeyBoard;
  82. { closing the user screen on mouse events makes copy paste impossible }
  83. repeat
  84. repeat
  85. GiveUpTimeSlice;
  86. Drivers.GetKeyEvent(Event);
  87. until Event.What=evKeyboard;
  88. Clear:=true;
  89. if not UserScreen^.CanScroll then
  90. Clear:=false
  91. else
  92. case Event.keycode of
  93. kbPgUp : UserScreen^.Scroll(-20);
  94. kbPgDn : UserScreen^.Scroll(20);
  95. kbUp : UserScreen^.Scroll(-1);
  96. kbDown : UserScreen^.Scroll(1);
  97. kbHome : UserScreen^.Scroll(-1024);
  98. kbEnd : UserScreen^.Scroll(+1024);
  99. else
  100. Clear:=false;
  101. end;
  102. if Clear then
  103. ClearEvent(Event);
  104. until Event.what=evKeyboard;
  105. while (Keyboard.PollKeyEvent<>0) do
  106. Keyboard.GetKeyEvent;
  107. DoneKeyboard;
  108. ShowIDEScreen;
  109. end;
  110. procedure TIDEApp.DoShowCallStack;
  111. begin
  112. {$ifdef NODEBUG}
  113. NoDebugger;
  114. {$else}
  115. If not assigned(StackWindow) then
  116. InitStackWindow
  117. else
  118. StackWindow^.MakeFirst;
  119. {$endif NODEBUG}
  120. end;
  121. procedure TIDEApp.DoShowDisassembly;
  122. begin
  123. {$ifdef NODEBUG}
  124. NoDebugger;
  125. {$else}
  126. If not assigned(DisassemblyWindow) then
  127. InitDisassemblyWindow
  128. else
  129. DisassemblyWindow^.MakeFirst;
  130. DisassemblyWindow^.LoadFunction('');
  131. {$endif NODEBUG}
  132. end;
  133. procedure TIDEApp.DoShowRegisters;
  134. begin
  135. {$ifdef NODEBUG}
  136. NoDebugger;
  137. {$else}
  138. If not assigned(RegistersWindow) then
  139. InitRegistersWindow
  140. else
  141. RegistersWindow^.MakeFirst;
  142. {$endif NODEBUG}
  143. end;
  144. procedure TIDEApp.DoShowFPU;
  145. begin
  146. {$ifdef NODEBUG}
  147. NoDebugger;
  148. {$else}
  149. If not assigned(FPUWindow) then
  150. InitFPUWindow
  151. else
  152. FPUWindow^.MakeFirst;
  153. {$endif NODEBUG}
  154. end;
  155. procedure TIDEApp.DoShowVector;
  156. begin
  157. {$ifdef NODEBUG}
  158. NoDebugger;
  159. {$else}
  160. If not assigned(VectorWindow) then
  161. InitVectorWindow
  162. else
  163. VectorWindow^.MakeFirst;
  164. {$endif NODEBUG}
  165. end;
  166. procedure TIDEApp.DoShowBreakpointList;
  167. begin
  168. {$ifdef NODEBUG}
  169. NoDebugger;
  170. {$else}
  171. If assigned(BreakpointsWindow) then
  172. begin
  173. BreakpointsWindow^.Update;
  174. BreakpointsWindow^.Show;
  175. BreakpointsWindow^.MakeFirst;
  176. end
  177. else
  178. begin
  179. New(BreakpointsWindow,Init);
  180. Desktop^.Insert(BreakpointsWindow);
  181. end;
  182. {$endif NODEBUG}
  183. end;
  184. procedure TIDEApp.DoShowWatches;
  185. begin
  186. {$ifdef NODEBUG}
  187. NoDebugger;
  188. {$else}
  189. If assigned(WatchesWindow) then
  190. begin
  191. WatchesWindow^.Update;
  192. WatchesWindow^.MakeFirst;
  193. end
  194. else
  195. begin
  196. New(WatchesWindow,Init);
  197. Desktop^.Insert(WatchesWindow);
  198. end;
  199. {$endif NODEBUG}
  200. end;
  201. procedure TIDEApp.DoAddWatch;
  202. {$ifdef NODEBUG}
  203. begin
  204. NoDebugger;
  205. end;
  206. {$else}
  207. var
  208. P: PWatch;
  209. EditorWindow : PSourceWindow;
  210. EditorWasFirst : boolean;
  211. S : string;
  212. begin
  213. EditorWindow:=FirstEditorWindow;
  214. { Leave the editor first, but only if there was already an WatchesWindow }
  215. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  216. assigned(WatchesWindow);
  217. If assigned(EditorWindow) then
  218. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  219. else
  220. S:='';
  221. P:=New(PWatch,Init(S));
  222. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  223. begin
  224. WatchesCollection^.Insert(P);
  225. WatchesCollection^.Update;
  226. DoShowWatches;
  227. if EditorWasFirst then
  228. EditorWindow^.MakeFirst;
  229. end
  230. else
  231. dispose(P,Done);
  232. end;
  233. {$endif NODEBUG}
  234. {$ifdef NODEBUG}
  235. procedure TIDEapp.do_evaluate;
  236. begin
  237. nodebugger;
  238. end;
  239. {$else}
  240. procedure TIDEapp.do_evaluate;
  241. var d:Pevaluate_dialog;
  242. r:Trect;
  243. begin
  244. desktop^.getextent(r);
  245. r.b.x:=r.b.x*3 div 4;
  246. r.b.y:=12;
  247. new(d,init(r));
  248. desktop^.execview(d);
  249. dispose(d,done);
  250. end;
  251. {$endif}