fpdebug.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Debugger call routines for the IDE
  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. unit FPDebug;
  13. interface
  14. uses
  15. GDBCon;
  16. type
  17. PDebugController=^TDebugController;
  18. TDebugController=object(TGDBController)
  19. constructor Init(const exefn:string);
  20. destructor Done;
  21. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  22. { procedure DoStartSession;virtual;
  23. procedure DoBreakSession;virtual;
  24. procedure DoEndSession(code:longint);virtual; }
  25. procedure DoDebuggerScreen;virtual;
  26. procedure DoUserScreen;virtual;
  27. end;
  28. var
  29. Debugger : PDebugController;
  30. procedure InitDebugger;
  31. procedure DoneDebugger;
  32. implementation
  33. uses
  34. Dos,Mouse,Video,
  35. App,
  36. FPViews,FPVars,FPUtils,FPIntf,
  37. FPCompile,FPUsrScr;
  38. {****************************************************************************
  39. TDebugController
  40. ****************************************************************************}
  41. constructor TDebugController.Init(const exefn:string);
  42. var f: string;
  43. begin
  44. inherited Init;
  45. f := exefn;
  46. LoadFile(f);
  47. end;
  48. destructor TDebugController.Done;
  49. begin
  50. inherited Done;
  51. end;
  52. procedure TDebugController.DoSelectSourceLine(const fn:string;line:longint);
  53. var
  54. W: PSourceWindow;
  55. begin
  56. Desktop^.Lock;
  57. if Line>0 then
  58. dec(Line);
  59. W:=TryToOpenFile(nil,fn,0,Line);
  60. if assigned(W) then
  61. begin
  62. W^.Editor^.SetHighlightRow(Line);
  63. W^.Select;
  64. end;
  65. Desktop^.UnLock;
  66. end;
  67. procedure TDebugController.DoDebuggerScreen;
  68. begin
  69. if assigned(FPUsrScr.UserScreen) then
  70. FPUsrScr.UserScreen^.SwitchBack;
  71. end;
  72. procedure TDebugController.DoUserScreen;
  73. begin
  74. if assigned(FPUsrScr.UserScreen) then
  75. FPUsrScr.UserScreen^.SwitchTo;
  76. end;
  77. {****************************************************************************
  78. Initialize
  79. ****************************************************************************}
  80. procedure InitDebugger;
  81. begin
  82. if (not ExistsFile(ExeFile)) or (CompilationPhase<>cpDone) then
  83. DoCompile(cRun);
  84. if CompilationPhase<>cpDone then
  85. Exit;
  86. if (EXEFile='') then
  87. begin
  88. ErrorBox('Oooops, nothing to debug.',nil);
  89. Exit;
  90. end;
  91. { init debugcontroller }
  92. if assigned(Debugger) then
  93. dispose(Debugger,Done);
  94. new(Debugger,Init(ExeFile));
  95. end;
  96. procedure DoneDebugger;
  97. begin
  98. if assigned(Debugger) then
  99. dispose(Debugger,Done);
  100. end;
  101. end.
  102. {
  103. $Log$
  104. Revision 1.2 1999-01-22 18:14:09 pierre
  105. * adaptd to changes in gdbint and gdbcon for to /
  106. Revision 1.1 1999/01/22 10:24:03 peter
  107. * first debugger things
  108. }