2
0

fpmdebug.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Debug menu entries
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$ifdef SUPPORT_REMOTE}
  13. function GetRemoteString : string;
  14. var
  15. St : string;
  16. begin
  17. St:=RemoteSendCommand;
  18. If RemoteConfig<>'' then
  19. ReplaceStrI(St,'$CONFIG','-F '+RemoteConfig)
  20. else
  21. ReplaceStrI(St,'$CONFIG','');
  22. If RemoteIdent<>'' then
  23. ReplaceStrI(St,'$IDENT','-i '+RemoteIdent)
  24. else
  25. ReplaceStrI(St,'$IDENT','');
  26. ReplaceStrI(St,'$LOCALFILE',GDBFileName(ExeFile));
  27. ReplaceStrI(St,'$REMOTEDIR',RemoteDir);
  28. ReplaceStrI(St,'$REMOTEMACHINE',RemoteMachine);
  29. GetRemoteString:=st;
  30. end;
  31. procedure TIDEApp.TransferRemote;
  32. var
  33. S,SendCommand : string;
  34. Executed : boolean;
  35. begin
  36. SendCommand:=GetRemoteString;
  37. if SendCommand<>'' then
  38. begin
  39. s:='scp'+exeext;
  40. if LocateExeFile(s) then
  41. Executed:=DoExecute(s,SendCommand,'','','',exNormal)
  42. else
  43. Executed:=DoExecute('scp',SendCommand,'','','',exNormal);
  44. if Executed then
  45. begin
  46. if (DosError<>0) or (DosExitCode<>0) then
  47. ErrorBox(#3'Execution of'#13#3+s+' '+SendCommand+#13#3+
  48. 'returned ('+inttostr(DosError)+','+inttostr(DosExitCode)+')',nil);
  49. end
  50. else
  51. ErrorBox(#3'Unable to execute'#13#3+s+' '+SendCommand,nil);
  52. end
  53. else
  54. ErrorBox(#3'Unable to transfer executable',nil);
  55. end;
  56. {$endif SUPPORT_REMOTE}
  57. procedure TIDEApp.DoUserScreenWindow;
  58. begin
  59. if UserScreenWindow=nil then
  60. begin
  61. New(UserScreenWindow, Init(UserScreen, SearchFreeWindowNo));
  62. Desktop^.Insert(UserScreenWindow);
  63. end;
  64. UserScreenWindow^.MakeFirst;
  65. end;
  66. procedure TIDEApp.DoCloseUserScreenWindow;
  67. begin
  68. if Assigned(UserScreenWindow) then
  69. Message(UserScreenWindow,evCommand,cmClose,nil);
  70. end;
  71. procedure TIDEApp.DoUserScreen;
  72. var Event : TEvent;
  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. repeat
  83. repeat
  84. Drivers.GetKeyEvent(Event);
  85. if Event.What=evNothing then
  86. GiveUpTimeSlice;
  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.DoShowRegisters;
  122. begin
  123. {$ifdef NODEBUG}
  124. NoDebugger;
  125. {$else}
  126. If not assigned(RegistersWindow) then
  127. InitRegistersWindow
  128. else
  129. RegistersWindow^.MakeFirst;
  130. {$endif NODEBUG}
  131. end;
  132. procedure TIDEApp.DoShowFPU;
  133. begin
  134. {$ifdef NODEBUG}
  135. NoDebugger;
  136. {$else}
  137. If not assigned(FPUWindow) then
  138. InitFPUWindow
  139. else
  140. FPUWindow^.MakeFirst;
  141. {$endif NODEBUG}
  142. end;
  143. procedure TIDEApp.DoShowBreakpointList;
  144. begin
  145. {$ifdef NODEBUG}
  146. NoDebugger;
  147. {$else}
  148. If assigned(BreakpointsWindow) then
  149. begin
  150. BreakpointsWindow^.Update;
  151. BreakpointsWindow^.Show;
  152. BreakpointsWindow^.MakeFirst;
  153. end
  154. else
  155. begin
  156. New(BreakpointsWindow,Init);
  157. Desktop^.Insert(BreakpointsWindow);
  158. end;
  159. {$endif NODEBUG}
  160. end;
  161. procedure TIDEApp.DoShowWatches;
  162. begin
  163. {$ifdef NODEBUG}
  164. NoDebugger;
  165. {$else}
  166. If assigned(WatchesWindow) then
  167. begin
  168. WatchesWindow^.Update;
  169. WatchesWindow^.MakeFirst;
  170. end
  171. else
  172. begin
  173. New(WatchesWindow,Init);
  174. Desktop^.Insert(WatchesWindow);
  175. end;
  176. {$endif NODEBUG}
  177. end;
  178. procedure TIDEApp.DoAddWatch;
  179. {$ifdef NODEBUG}
  180. begin
  181. NoDebugger;
  182. end;
  183. {$else}
  184. var
  185. P: PWatch;
  186. EditorWindow : PSourceWindow;
  187. EditorWasFirst : boolean;
  188. S : string;
  189. begin
  190. EditorWindow:=FirstEditorWindow;
  191. { Leave the editor first, but only if there was already an WatchesWindow }
  192. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  193. assigned(WatchesWindow);
  194. If assigned(EditorWindow) then
  195. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  196. else
  197. S:='';
  198. P:=New(PWatch,Init(S));
  199. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  200. begin
  201. WatchesCollection^.Insert(P);
  202. WatchesCollection^.Update;
  203. DoShowWatches;
  204. if EditorWasFirst then
  205. EditorWindow^.MakeFirst;
  206. end
  207. else
  208. dispose(P,Done);
  209. end;
  210. {$endif NODEBUG}
  211. {
  212. $Log$
  213. Revision 1.6 2002-11-28 12:57:00 pierre
  214. + TransferRemote method added
  215. Revision 1.5 2002/10/30 22:07:11 pierre
  216. * only handle direction keys specially if buffer is bigger than window
  217. Revision 1.4 2002/09/07 15:40:43 peter
  218. * old logs removed and tabs fixed
  219. Revision 1.3 2002/09/03 13:59:09 pierre
  220. * don't use LowerCaseStr for AddWatch as it confuses line completion
  221. Revision 1.2 2002/09/02 09:27:35 pierre
  222. * avoid 100 CPU usage when AltF5 is used
  223. }