fpmdebug.inc 6.1 KB

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