fpmrun.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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(msg_nothingtorun,nil);
  98. Exit;
  99. end;
  100. if not ExistsFile(ExeFile) then
  101. begin
  102. MsgParms[1].Ptr:=@EXEFile;
  103. ErrorBox(msg_invalidfilename,@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(msg_programnotrundoserroris,@MsgParms);
  130. end
  131. else If LastExitCode<>0 then
  132. begin
  133. MsgParms[1].Ptr:=@EXEFile;
  134. MsgParms[2].long:=LastExitCode;
  135. InformationBox(msg_programfileexitedwithexitcode,@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,round(ScreenWidth*54/80),4);
  150. New(D, Init(R, dialog_programparameters));
  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:=16;
  155. New(IL, Init(R2, 255));
  156. IL^.Data^:=GetRunParameters;
  157. Insert(IL);
  158. R2.Copy(R); R2.B.X:=16;
  159. Insert(New(PLabel, Init(R2, label_parameters_parameter, 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(msg_impossibletoreachcursor,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(msg_impossibletosetbreakpoint,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.1 2000-07-13 09:48:35 michael
  254. + Initial import
  255. Revision 1.32 2000/05/02 08:42:28 pierre
  256. * new set of Gabor changes: see fixes.txt
  257. Revision 1.31 2000/04/18 11:42:37 pierre
  258. lot of Gabor changes : see fixes.txt
  259. Revision 1.30 2000/03/21 23:27:35 pierre
  260. Gabor fixes to avoid unused vars
  261. Revision 1.29 2000/03/08 16:58:12 pierre
  262. Uses Debugger^.IsRunning
  263. Revision 1.28 2000/02/04 00:15:31 pierre
  264. * adapted to change in fpdebug unit
  265. Revision 1.27 2000/02/02 22:48:25 pierre
  266. * Use desktop^.current instead of desktop^.first
  267. * Avoid stopping at main if debugger started with CrtlF9
  268. Revision 1.26 2000/01/31 16:02:08 pierre
  269. * avoid the Impossible to set breakpoints here
  270. Revision 1.25 2000/01/28 22:38:21 pierre
  271. * CrtlF9 starts debugger if there are active breakpoints
  272. Revision 1.24 2000/01/10 13:23:28 pierre
  273. * Debugger test missing in ContTo
  274. Revision 1.23 1999/12/10 13:01:01 pierre
  275. * do not recompile a program inside Debugging session
  276. Revision 1.22 1999/11/10 17:17:02 pierre
  277. + Information box if exit code <> 0 or DosError
  278. Revision 1.21 1999/09/16 14:34:59 pierre
  279. + TBreakpoint and TWatch registering
  280. + WatchesCollection and BreakpointsCollection stored in desk file
  281. * Syntax highlighting was broken
  282. Revision 1.20 1999/09/09 14:11:56 pierre
  283. * GDB needs lowercase filenames for tbreak
  284. Revision 1.19 1999/08/31 16:20:37 pierre
  285. * DoContUntilReturn call Step instead of UnitlReturn
  286. Revision 1.18 1999/08/16 18:25:23 peter
  287. * Adjusting the selection when the editor didn't contain any line.
  288. * Reserved word recognition redesigned, but this didn't affect the overall
  289. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  290. The syntax scanner loop is a bit slow but the main problem is the
  291. recognition of special symbols. Switching off symbol processing boosts
  292. the performance up to ca. 200%...
  293. * The editor didn't allow copying (for ex to clipboard) of a single character
  294. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  295. * Compiler Messages window (actually the whole desktop) did not act on any
  296. keypress when compilation failed and thus the window remained visible
  297. + Message windows are now closed upon pressing Esc
  298. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  299. only when neccessary
  300. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  301. + LineSelect (Ctrl+K+L) implemented
  302. * The IDE had problems closing help windows before saving the desktop
  303. Revision 1.17 1999/07/28 23:11:20 peter
  304. * fixes from gabor
  305. Revision 1.16 1999/07/12 13:14:19 pierre
  306. * LineEnd bug corrected, now goes end of text even if selected
  307. + Until Return for debugger
  308. + Code for Quit inside GDB Window
  309. Revision 1.15 1999/04/07 21:55:50 peter
  310. + object support for browser
  311. * html help fixes
  312. * more desktop saving things
  313. * NODEBUG directive to exclude debugger
  314. Revision 1.14 1999/03/01 15:41:58 peter
  315. + Added dummy entries for functions not yet implemented
  316. * MenuBar didn't update itself automatically on command-set changes
  317. * Fixed Debugging/Profiling options dialog
  318. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  319. set
  320. * efBackSpaceUnindents works correctly
  321. + 'Messages' window implemented
  322. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  323. + Added TP message-filter support (for ex. you can call GREP thru
  324. GREP2MSG and view the result in the messages window - just like in TP)
  325. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  326. so topic search didn't work...
  327. * In FPHELP.PAS there were still context-variables defined as word instead
  328. of THelpCtx
  329. * StdStatusKeys() was missing from the statusdef for help windows
  330. + Topic-title for index-table can be specified when adding a HTML-files
  331. Revision 1.13 1999/02/18 13:44:33 peter
  332. * search fixed
  333. + backward search
  334. * help fixes
  335. * browser updates
  336. Revision 1.12 1999/02/11 19:07:24 pierre
  337. * GDBWindow redesigned :
  338. normal editor apart from
  339. that any kbEnter will send the line (for begin to cursor)
  340. to GDB command !
  341. GDBWindow opened in Debugger Menu
  342. still buggy :
  343. -echo should not be present if at end of text
  344. -GDBWindow becomes First after each step (I don't know why !)
  345. Revision 1.11 1999/02/10 09:51:59 pierre
  346. small cleanup
  347. Revision 1.10 1999/02/08 17:43:45 pierre
  348. * RestDebugger or multiple running of debugged program now works
  349. + added DoContToCursor(F4)
  350. * Breakpoints are now inserted correctly (was mainlyy a problem
  351. of directories)
  352. Revision 1.9 1999/02/05 17:21:53 pierre
  353. Invalid_line renamed InvalidSourceLine
  354. Revision 1.8 1999/02/04 17:56:17 pierre
  355. * Set breakpoint only possible if source window
  356. Revision 1.7 1999/02/04 13:32:07 pierre
  357. * Several things added (I cannot commit them independently !)
  358. + added TBreakpoint and TBreakpointCollection
  359. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  360. + Breakpoint list in INIFile
  361. * Select items now also depend of SwitchMode
  362. * Reading of option '-g' was not possible !
  363. + added search for -Fu args pathes in TryToOpen
  364. + added code for automatic opening of FileDialog
  365. if source not found
  366. Revision 1.6 1999/01/22 10:24:05 peter
  367. * first debugger things
  368. Revision 1.5 1999/01/21 11:54:20 peter
  369. + tools menu
  370. + speedsearch in symbolbrowser
  371. * working run command
  372. Revision 1.4 1999/01/14 21:42:22 peter
  373. * source tracking from Gabor
  374. Revision 1.3 1999/01/12 14:29:36 peter
  375. + Implemented still missing 'switch' entries in Options menu
  376. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  377. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  378. ASCII chars and inserted directly in the text.
  379. + Added symbol browser
  380. * splitted fp.pas to fpide.pas
  381. Revision 1.2 1999/01/04 11:49:48 peter
  382. * 'Use tab characters' now works correctly
  383. + Syntax highlight now acts on File|Save As...
  384. + Added a new class to syntax highlight: 'hex numbers'.
  385. * There was something very wrong with the palette managment. Now fixed.
  386. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  387. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  388. process revised
  389. Revision 1.1 1998/12/28 15:47:50 peter
  390. + Added user screen support, display & window
  391. + Implemented Editor,Mouse Options dialog
  392. + Added location of .INI and .CFG file
  393. + Option (INI) file managment implemented (see bottom of Options Menu)
  394. + Switches updated
  395. + Run program
  396. }