fpmrun.inc 12 KB

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