fpmrun.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Run 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. procedure TIDEApp.DoStepOver;
  13. begin
  14. {$ifndef NODEBUG}
  15. if not assigned(Debugger) then
  16. begin
  17. InitDebugger;
  18. if not assigned(Debugger) then
  19. exit;
  20. end;
  21. if not debugger^.debuggee_started then
  22. Debugger^.StartTrace
  23. else
  24. Debugger^.TraceNext;
  25. While (Debugger^.InvalidSourceLine and
  26. Debugger^.debuggee_started and
  27. not Debugger^.error) do
  28. begin
  29. Inc(Debugger^.HiddenStepsCount);
  30. Debugger^.TraceNext;
  31. end;
  32. Debugger^.AnnotateError;
  33. {$else NODEBUG}
  34. NoDebugger;
  35. {$endif NODEBUG}
  36. end;
  37. procedure TIDEApp.DoTraceInto;
  38. begin
  39. {$ifndef NODEBUG}
  40. if not assigned(Debugger) then
  41. begin
  42. InitDebugger;
  43. if not assigned(Debugger) then
  44. exit;
  45. end;
  46. if not debugger^.debuggee_started then
  47. Debugger^.StartTrace
  48. else
  49. Debugger^.TraceStep;
  50. { I think we should not try to go deeper !
  51. if the source is not found PM }
  52. While (Debugger^.InvalidSourceLine and
  53. Debugger^.debuggee_started and
  54. not Debugger^.error) do
  55. begin
  56. Inc(Debugger^.HiddenStepsCount);
  57. Debugger^.TraceNext;
  58. end;
  59. Debugger^.AnnotateError;
  60. {$else NODEBUG}
  61. NoDebugger;
  62. {$endif NODEBUG}
  63. end;
  64. procedure TIDEApp.DoContUntilReturn;
  65. begin
  66. {$ifndef NODEBUG}
  67. if not assigned(Debugger) then
  68. begin
  69. InitDebugger;
  70. if not assigned(Debugger) then
  71. exit;
  72. end;
  73. if not debugger^.debuggee_started then
  74. Debugger^.StartTrace
  75. else
  76. Debugger^.UntilReturn;
  77. Debugger^.AnnotateError;
  78. {$else NODEBUG}
  79. NoDebugger;
  80. {$endif NODEBUG}
  81. end;
  82. procedure TIDEApp.DoRun;
  83. begin
  84. {$ifndef NODEBUG}
  85. if not assigned(Debugger) or not Debugger^.debuggee_started then
  86. {$endif}
  87. begin
  88. if (not ExistsFile(ExeFile)) or (CompilationPhase<>cpDone) or NeedRecompile then
  89. DoCompile(cRun);
  90. if CompilationPhase<>cpDone then
  91. Exit;
  92. if (EXEFile='') then
  93. begin
  94. ErrorBox('Oooops, nothing to run.',nil);
  95. Exit;
  96. end;
  97. if not ExistsFile(ExeFile) then
  98. begin
  99. MsgParms[1].Ptr:=@EXEFile;
  100. ErrorBox('Invalid filename %s',@MsgParms);
  101. Exit;
  102. end;
  103. DoExecute(ExeFile,GetRunParameters,'','',exNormal);
  104. LastExitCode:=ExecuteResult;
  105. If IOStatus<>0 then
  106. begin
  107. MsgParms[1].Ptr:=@EXEFile;
  108. MsgParms[2].long:=IOStatus;
  109. InformationBox(#3'Program %s'#13#3'not run'#13#3'DosError = %d',@MsgParms);
  110. end
  111. else If LastExitCode<>0 then
  112. begin
  113. MsgParms[1].Ptr:=@EXEFile;
  114. MsgParms[2].long:=LastExitCode;
  115. InformationBox(#3'Program %s'#13#3'exited with '#13#3'exitcode = %d',@MsgParms);
  116. end;
  117. end
  118. {$ifndef NODEBUG}
  119. else
  120. Debugger^.Continue
  121. {$endif}
  122. ;
  123. end;
  124. procedure TIDEApp.Parameters;
  125. var R,R2: TRect;
  126. D: PCenterDialog;
  127. IL: PInputLine;
  128. begin
  129. R.Assign(0,0,54,4);
  130. New(D, Init(R, 'Program parameters'));
  131. with D^ do
  132. begin
  133. GetExtent(R); R.Grow(-2,-1); Inc(R.A.Y); R.B.Y:=R.A.Y+1;
  134. R2.Copy(R); R2.A.X:=14;
  135. New(IL, Init(R2, 255));
  136. IL^.Data^:=GetRunParameters;
  137. Insert(IL);
  138. R2.Copy(R); R2.B.X:=14;
  139. Insert(New(PLabel, Init(R2, '~P~arameter', IL)));
  140. end;
  141. InsertButtons(D);
  142. IL^.Select;
  143. if Desktop^.ExecView(D)=cmOK then
  144. begin
  145. SetRunParameters(IL^.Data^);
  146. end;
  147. Dispose(D, Done);
  148. end;
  149. procedure TIDEApp.DoResetDebugger;
  150. begin
  151. {$ifndef NODEBUG}
  152. if assigned(Debugger) then
  153. DoneDebugger;
  154. UpdateScreen(true);
  155. {$else NODEBUG}
  156. NoDebugger;
  157. {$endif NODEBUG}
  158. end;
  159. procedure TIDEApp.DoContToCursor;
  160. var
  161. W : PSourceWindow;
  162. FileName : string;
  163. LineNr : longint;
  164. begin
  165. {$ifndef NODEBUG}
  166. if (DeskTop^.First=nil) or
  167. (TypeOf(DeskTop^.First^)<>TypeOf(TSourceWindow)) then
  168. Begin
  169. ErrorBox('Impossible to reach current cursor',nil);
  170. Exit;
  171. End;
  172. W:=PSourceWindow(DeskTop^.First);
  173. If assigned(W) then
  174. begin
  175. FileName:=W^.Editor^.FileName;
  176. LineNr:=W^.Editor^.CurPos.Y+1;
  177. If not assigned(Debugger) then
  178. InitDebugger;
  179. Debugger^.Command('tbreak '+LowCaseStr(NameAndExtOf(FileName))+':'+IntToStr(LineNr));
  180. Debugger^.Continue;
  181. end;
  182. {$else NODEBUG}
  183. NoDebugger;
  184. {$endif NODEBUG}
  185. end;
  186. procedure TIDEApp.DoOpenGDBWindow;
  187. begin
  188. {$ifndef NODEBUG}
  189. InitGDBWindow;
  190. If assigned(GDBWindow) then
  191. GDBWindow^.MakeFirst;
  192. {$else NODEBUG}
  193. NoDebugger;
  194. {$endif NODEBUG}
  195. end;
  196. procedure TIDEApp.DoToggleBreak;
  197. var
  198. W : PSourceWindow;
  199. FileName : string;
  200. b : boolean;
  201. LineNr : longint;
  202. begin
  203. {$ifndef NODEBUG}
  204. if (DeskTop^.First=nil) or
  205. (TypeOf(DeskTop^.First^)<>TypeOf(TSourceWindow)) then
  206. Begin
  207. ErrorBox('Impossible to set breakpoints here',nil);
  208. Exit;
  209. End;
  210. W:=PSourceWindow(DeskTop^.First);
  211. If assigned(W) then
  212. begin
  213. FileName:=W^.Editor^.FileName;
  214. LineNr:=W^.Editor^.CurPos.Y+1;
  215. b:=BreakpointsCollection^.ToggleFileLine(FileName,LineNr);
  216. W^.Editor^.SetLineBreakState(LineNr,b);
  217. end;
  218. {$else NODEBUG}
  219. NoDebugger;
  220. {$endif NODEBUG}
  221. end;
  222. {
  223. $Log$
  224. Revision 1.23 1999-12-10 13:01:01 pierre
  225. * do not recompile a program inside Debugging session
  226. Revision 1.22 1999/11/10 17:17:02 pierre
  227. + Information box if exit code <> 0 or DosError
  228. Revision 1.21 1999/09/16 14:34:59 pierre
  229. + TBreakpoint and TWatch registering
  230. + WatchesCollection and BreakpointsCollection stored in desk file
  231. * Syntax highlighting was broken
  232. Revision 1.20 1999/09/09 14:11:56 pierre
  233. * GDB needs lowercase filenames for tbreak
  234. Revision 1.19 1999/08/31 16:20:37 pierre
  235. * DoContUntilReturn call Step instead of UnitlReturn
  236. Revision 1.18 1999/08/16 18:25:23 peter
  237. * Adjusting the selection when the editor didn't contain any line.
  238. * Reserved word recognition redesigned, but this didn't affect the overall
  239. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  240. The syntax scanner loop is a bit slow but the main problem is the
  241. recognition of special symbols. Switching off symbol processing boosts
  242. the performance up to ca. 200%...
  243. * The editor didn't allow copying (for ex to clipboard) of a single character
  244. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  245. * Compiler Messages window (actually the whole desktop) did not act on any
  246. keypress when compilation failed and thus the window remained visible
  247. + Message windows are now closed upon pressing Esc
  248. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  249. only when neccessary
  250. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  251. + LineSelect (Ctrl+K+L) implemented
  252. * The IDE had problems closing help windows before saving the desktop
  253. Revision 1.17 1999/07/28 23:11:20 peter
  254. * fixes from gabor
  255. Revision 1.16 1999/07/12 13:14:19 pierre
  256. * LineEnd bug corrected, now goes end of text even if selected
  257. + Until Return for debugger
  258. + Code for Quit inside GDB Window
  259. Revision 1.15 1999/04/07 21:55:50 peter
  260. + object support for browser
  261. * html help fixes
  262. * more desktop saving things
  263. * NODEBUG directive to exclude debugger
  264. Revision 1.14 1999/03/01 15:41:58 peter
  265. + Added dummy entries for functions not yet implemented
  266. * MenuBar didn't update itself automatically on command-set changes
  267. * Fixed Debugging/Profiling options dialog
  268. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  269. set
  270. * efBackSpaceUnindents works correctly
  271. + 'Messages' window implemented
  272. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  273. + Added TP message-filter support (for ex. you can call GREP thru
  274. GREP2MSG and view the result in the messages window - just like in TP)
  275. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  276. so topic search didn't work...
  277. * In FPHELP.PAS there were still context-variables defined as word instead
  278. of THelpCtx
  279. * StdStatusKeys() was missing from the statusdef for help windows
  280. + Topic-title for index-table can be specified when adding a HTML-files
  281. Revision 1.13 1999/02/18 13:44:33 peter
  282. * search fixed
  283. + backward search
  284. * help fixes
  285. * browser updates
  286. Revision 1.12 1999/02/11 19:07:24 pierre
  287. * GDBWindow redesigned :
  288. normal editor apart from
  289. that any kbEnter will send the line (for begin to cursor)
  290. to GDB command !
  291. GDBWindow opened in Debugger Menu
  292. still buggy :
  293. -echo should not be present if at end of text
  294. -GDBWindow becomes First after each step (I don't know why !)
  295. Revision 1.11 1999/02/10 09:51:59 pierre
  296. small cleanup
  297. Revision 1.10 1999/02/08 17:43:45 pierre
  298. * RestDebugger or multiple running of debugged program now works
  299. + added DoContToCursor(F4)
  300. * Breakpoints are now inserted correctly (was mainlyy a problem
  301. of directories)
  302. Revision 1.9 1999/02/05 17:21:53 pierre
  303. Invalid_line renamed InvalidSourceLine
  304. Revision 1.8 1999/02/04 17:56:17 pierre
  305. * Set breakpoint only possible if source window
  306. Revision 1.7 1999/02/04 13:32:07 pierre
  307. * Several things added (I cannot commit them independently !)
  308. + added TBreakpoint and TBreakpointCollection
  309. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  310. + Breakpoint list in INIFile
  311. * Select items now also depend of SwitchMode
  312. * Reading of option '-g' was not possible !
  313. + added search for -Fu args pathes in TryToOpen
  314. + added code for automatic opening of FileDialog
  315. if source not found
  316. Revision 1.6 1999/01/22 10:24:05 peter
  317. * first debugger things
  318. Revision 1.5 1999/01/21 11:54:20 peter
  319. + tools menu
  320. + speedsearch in symbolbrowser
  321. * working run command
  322. Revision 1.4 1999/01/14 21:42:22 peter
  323. * source tracking from Gabor
  324. Revision 1.3 1999/01/12 14:29:36 peter
  325. + Implemented still missing 'switch' entries in Options menu
  326. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  327. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  328. ASCII chars and inserted directly in the text.
  329. + Added symbol browser
  330. * splitted fp.pas to fpide.pas
  331. Revision 1.2 1999/01/04 11:49:48 peter
  332. * 'Use tab characters' now works correctly
  333. + Syntax highlight now acts on File|Save As...
  334. + Added a new class to syntax highlight: 'hex numbers'.
  335. * There was something very wrong with the palette managment. Now fixed.
  336. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  337. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  338. process revised
  339. Revision 1.1 1998/12/28 15:47:50 peter
  340. + Added user screen support, display & window
  341. + Implemented Editor,Mouse Options dialog
  342. + Added location of .INI and .CFG file
  343. + Option (INI) file managment implemented (see bottom of Options Menu)
  344. + Switches updated
  345. + Run program
  346. }