fpmdebug.inc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. ev : TMouseEvent;
  74. Clear : Boolean;
  75. begin
  76. if UserScreen=nil then
  77. begin
  78. ErrorBox(msg_userscreennotavailable,nil);
  79. Exit;
  80. end;
  81. ShowUserScreen;
  82. InitKeyBoard;
  83. if UseMouse Then
  84. InitMouse;
  85. repeat
  86. repeat
  87. Drivers.GetKeyEvent(Event);
  88. if (Event.What and EvKeyboard)=evNothing then
  89. Begin
  90. If UseMouse Then
  91. Begin
  92. Drivers.GetMouseEvent(Event);
  93. if (Event.What and evMouse)=evNothing then
  94. GiveUpTimeSlice
  95. else
  96. Event.what:=evMouse;
  97. End;
  98. End
  99. else
  100. Event.what:=evkeyboard;
  101. until Event.What in [evKeyboard,evmouse];
  102. if event.what=evmouse then
  103. Clear:=false
  104. else
  105. begin
  106. Clear:=true;
  107. if not UserScreen^.CanScroll then
  108. Clear:=false
  109. else
  110. case Event.keycode of
  111. kbPgUp : UserScreen^.Scroll(-20);
  112. kbPgDn : UserScreen^.Scroll(20);
  113. kbUp : UserScreen^.Scroll(-1);
  114. kbDown : UserScreen^.Scroll(1);
  115. kbHome : UserScreen^.Scroll(-1024);
  116. kbEnd : UserScreen^.Scroll(+1024);
  117. else
  118. Clear:=false;
  119. end;
  120. end;
  121. if Clear then
  122. ClearEvent(Event);
  123. until Event.what in [evKeyboard,evmouse];
  124. while (Keyboard.PollKeyEvent<>0) do
  125. Keyboard.GetKeyEvent;
  126. if UseMouse Then
  127. Begin
  128. while PollMouseEvent(Ev) do
  129. GetMouseEvent(ev);
  130. donemouse;
  131. End;
  132. DoneKeyboard;
  133. ShowIDEScreen;
  134. end;
  135. procedure TIDEApp.DoShowCallStack;
  136. begin
  137. {$ifdef NODEBUG}
  138. NoDebugger;
  139. {$else}
  140. If not assigned(StackWindow) then
  141. InitStackWindow
  142. else
  143. StackWindow^.MakeFirst;
  144. {$endif NODEBUG}
  145. end;
  146. procedure TIDEApp.DoShowDisassembly;
  147. begin
  148. {$ifdef NODEBUG}
  149. NoDebugger;
  150. {$else}
  151. If not assigned(DisassemblyWindow) then
  152. InitDisassemblyWindow
  153. else
  154. DisassemblyWindow^.MakeFirst;
  155. DisassemblyWindow^.LoadFunction('');
  156. {$endif NODEBUG}
  157. end;
  158. procedure TIDEApp.DoShowRegisters;
  159. begin
  160. {$ifdef NODEBUG}
  161. NoDebugger;
  162. {$else}
  163. If not assigned(RegistersWindow) then
  164. InitRegistersWindow
  165. else
  166. RegistersWindow^.MakeFirst;
  167. {$endif NODEBUG}
  168. end;
  169. procedure TIDEApp.DoShowFPU;
  170. begin
  171. {$ifdef NODEBUG}
  172. NoDebugger;
  173. {$else}
  174. If not assigned(FPUWindow) then
  175. InitFPUWindow
  176. else
  177. FPUWindow^.MakeFirst;
  178. {$endif NODEBUG}
  179. end;
  180. procedure TIDEApp.DoShowVector;
  181. begin
  182. {$ifdef NODEBUG}
  183. NoDebugger;
  184. {$else}
  185. If not assigned(VectorWindow) then
  186. InitVectorWindow
  187. else
  188. VectorWindow^.MakeFirst;
  189. {$endif NODEBUG}
  190. end;
  191. procedure TIDEApp.DoShowBreakpointList;
  192. begin
  193. {$ifdef NODEBUG}
  194. NoDebugger;
  195. {$else}
  196. If assigned(BreakpointsWindow) then
  197. begin
  198. BreakpointsWindow^.Update;
  199. BreakpointsWindow^.Show;
  200. BreakpointsWindow^.MakeFirst;
  201. end
  202. else
  203. begin
  204. New(BreakpointsWindow,Init);
  205. Desktop^.Insert(BreakpointsWindow);
  206. end;
  207. {$endif NODEBUG}
  208. end;
  209. procedure TIDEApp.DoShowWatches;
  210. begin
  211. {$ifdef NODEBUG}
  212. NoDebugger;
  213. {$else}
  214. If assigned(WatchesWindow) then
  215. begin
  216. WatchesWindow^.Update;
  217. WatchesWindow^.MakeFirst;
  218. end
  219. else
  220. begin
  221. New(WatchesWindow,Init);
  222. Desktop^.Insert(WatchesWindow);
  223. end;
  224. {$endif NODEBUG}
  225. end;
  226. procedure TIDEApp.DoAddWatch;
  227. {$ifdef NODEBUG}
  228. begin
  229. NoDebugger;
  230. end;
  231. {$else}
  232. var
  233. P: PWatch;
  234. EditorWindow : PSourceWindow;
  235. EditorWasFirst : boolean;
  236. S : string;
  237. begin
  238. EditorWindow:=FirstEditorWindow;
  239. { Leave the editor first, but only if there was already an WatchesWindow }
  240. EditorWasFirst:=(PWindow(Desktop^.First)=PWindow(EditorWindow)) and
  241. assigned(WatchesWindow);
  242. If assigned(EditorWindow) then
  243. S:={LowerCaseStr(}EditorWindow^.Editor^.GetCurrentWord
  244. else
  245. S:='';
  246. P:=New(PWatch,Init(S));
  247. if ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  248. begin
  249. WatchesCollection^.Insert(P);
  250. WatchesCollection^.Update;
  251. DoShowWatches;
  252. if EditorWasFirst then
  253. EditorWindow^.MakeFirst;
  254. end
  255. else
  256. dispose(P,Done);
  257. end;
  258. {$endif NODEBUG}
  259. {
  260. $Log$
  261. Revision 1.10 2005-04-04 03:59:13 marco
  262. * fix for 3194: Use mouse to exit output screen
  263. Revision 1.9 2005/02/14 17:13:18 peter
  264. * truncate log
  265. Revision 1.8 2005/01/08 11:43:18 florian
  266. + vector unit window
  267. Revision 1.7 2005/01/07 21:52:23 florian
  268. * proper stepping in disassembler window now possible
  269. + disassembler window to menu added
  270. }