fpmrun.inc 13 KB

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