fpmdebug.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. Drivers.GetKeyEvent(Event);
  86. until Event.What=evKeyboard;
  87. Clear:=true;
  88. if not UserScreen^.CanScroll then
  89. Clear:=false
  90. else
  91. case Event.keycode of
  92. kbPgUp : UserScreen^.Scroll(-20);
  93. kbPgDn : UserScreen^.Scroll(20);
  94. kbUp : UserScreen^.Scroll(-1);
  95. kbDown : UserScreen^.Scroll(1);
  96. kbHome : UserScreen^.Scroll(-1024);
  97. kbEnd : UserScreen^.Scroll(+1024);
  98. else
  99. Clear:=false;
  100. end;
  101. if Clear then
  102. ClearEvent(Event);
  103. until Event.what=evKeyboard;
  104. while (Keyboard.PollKeyEvent<>0) do
  105. Keyboard.GetKeyEvent;
  106. DoneKeyboard;
  107. ShowIDEScreen;
  108. end;
  109. procedure TIDEApp.DoShowCallStack;
  110. begin
  111. {$ifdef NODEBUG}
  112. NoDebugger;
  113. {$else}
  114. If not assigned(StackWindow) then
  115. InitStackWindow
  116. else
  117. StackWindow^.MakeFirst;
  118. {$endif NODEBUG}
  119. end;
  120. procedure TIDEApp.DoShowDisassembly;
  121. begin
  122. {$ifdef NODEBUG}
  123. NoDebugger;
  124. {$else}
  125. If not assigned(DisassemblyWindow) then
  126. InitDisassemblyWindow
  127. else
  128. DisassemblyWindow^.MakeFirst;
  129. DisassemblyWindow^.LoadFunction('');
  130. {$endif NODEBUG}
  131. end;
  132. procedure TIDEApp.DoShowRegisters;
  133. begin
  134. {$ifdef NODEBUG}
  135. NoDebugger;
  136. {$else}
  137. If not assigned(RegistersWindow) then
  138. InitRegistersWindow
  139. else
  140. RegistersWindow^.MakeFirst;
  141. {$endif NODEBUG}
  142. end;
  143. procedure TIDEApp.DoShowFPU;
  144. begin
  145. {$ifdef NODEBUG}
  146. NoDebugger;
  147. {$else}
  148. If not assigned(FPUWindow) then
  149. InitFPUWindow
  150. else
  151. FPUWindow^.MakeFirst;
  152. {$endif NODEBUG}
  153. end;
  154. procedure TIDEApp.DoShowVector;
  155. begin
  156. {$ifdef NODEBUG}
  157. NoDebugger;
  158. {$else}
  159. If not assigned(VectorWindow) then
  160. InitVectorWindow
  161. else
  162. VectorWindow^.MakeFirst;
  163. {$endif NODEBUG}
  164. end;
  165. procedure TIDEApp.DoShowBreakpointList;
  166. begin
  167. {$ifdef NODEBUG}
  168. NoDebugger;
  169. {$else}
  170. If assigned(BreakpointsWindow) then
  171. begin
  172. BreakpointsWindow^.Update;
  173. BreakpointsWindow^.Show;
  174. BreakpointsWindow^.MakeFirst;
  175. end
  176. else
  177. begin
  178. New(BreakpointsWindow,Init);
  179. Desktop^.Insert(BreakpointsWindow);
  180. end;
  181. {$endif NODEBUG}
  182. end;
  183. procedure TIDEApp.DoShowWatches;
  184. begin
  185. {$ifdef NODEBUG}
  186. NoDebugger;
  187. {$else}
  188. If assigned(WatchesWindow) then
  189. begin
  190. WatchesWindow^.Update;
  191. WatchesWindow^.MakeFirst;
  192. end
  193. else
  194. begin
  195. New(WatchesWindow,Init);
  196. Desktop^.Insert(WatchesWindow);
  197. end;
  198. {$endif NODEBUG}
  199. end;
  200. procedure TIDEApp.DoAddWatch;
  201. {$ifdef NODEBUG}
  202. begin
  203. NoDebugger;
  204. end;
  205. {$else}
  206. var
  207. P: PWatch;
  208. EditorWindow : PSourceWindow;
  209. EditorWasFirst : boolean;
  210. S : string;
  211. begin
  212. EditorWindow:=FirstEditorWindow;
  213. { Leave the editor first, but only if there was already an WatchesWindow }
  214. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  215. assigned(WatchesWindow);
  216. If assigned(EditorWindow) then
  217. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  218. else
  219. S:='';
  220. P:=New(PWatch,Init(S));
  221. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  222. begin
  223. WatchesCollection^.Insert(P);
  224. WatchesCollection^.Update;
  225. DoShowWatches;
  226. if EditorWasFirst then
  227. EditorWindow^.MakeFirst;
  228. end
  229. else
  230. dispose(P,Done);
  231. end;
  232. {$endif NODEBUG}