fpmdebug.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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.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. {
  235. $Log$
  236. Revision 1.8 2005-01-08 11:43:18 florian
  237. + vector unit window
  238. Revision 1.7 2005/01/07 21:52:23 florian
  239. * proper stepping in disassembler window now possible
  240. + disassembler window to menu added
  241. Revision 1.6 2002/11/28 12:57:00 pierre
  242. + TransferRemote method added
  243. Revision 1.5 2002/10/30 22:07:11 pierre
  244. * only handle direction keys specially if buffer is bigger than window
  245. Revision 1.4 2002/09/07 15:40:43 peter
  246. * old logs removed and tabs fixed
  247. Revision 1.3 2002/09/03 13:59:09 pierre
  248. * don't use LowerCaseStr for AddWatch as it confuses line completion
  249. Revision 1.2 2002/09/02 09:27:35 pierre
  250. * avoid 100 CPU usage when AltF5 is used
  251. }