fpmrun.inc 13 KB

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