* RestDebugger or multiple running of debugged program now works

+ added DoContToCursor(F4)
  * Breakpoints are now inserted correctly (was mainlyy a problem
    of directories)
This commit is contained in:
pierre 1999-02-08 17:43:43 +00:00
parent 2d6a949149
commit c99810d589
3 changed files with 149 additions and 28 deletions

View File

@ -25,6 +25,7 @@ type
InvalidSourceLine : boolean; InvalidSourceLine : boolean;
LastFileName : string; LastFileName : string;
LastSource : PView; {PsourceWindow !! } LastSource : PView; {PsourceWindow !! }
HiddenStepsCount : longint;
constructor Init(const exefn:string); constructor Init(const exefn:string);
destructor Done; destructor Done;
procedure DoSelectSourceline(const fn:string;line:longint);virtual; procedure DoSelectSourceline(const fn:string;line:longint);virtual;
@ -36,6 +37,9 @@ type
procedure RemoveBreakpoints; procedure RemoveBreakpoints;
procedure DoDebuggerScreen;virtual; procedure DoDebuggerScreen;virtual;
procedure DoUserScreen;virtual; procedure DoUserScreen;virtual;
procedure Reset;virtual;
procedure Run;virtual;
procedure Continue;virtual;
end; end;
BreakpointType = (bt_function,bt_file_line,bt_watch,bt_awatch,bt_rwatch,bt_invalid); BreakpointType = (bt_function,bt_file_line,bt_watch,bt_awatch,bt_rwatch,bt_invalid);
@ -56,7 +60,7 @@ type
GDBIndex : longint; GDBIndex : longint;
GDBState : BreakpointState; GDBState : BreakpointState;
constructor Init_function(Const AFunc : String); constructor Init_function(Const AFunc : String);
constructor Init_file_line(Const AFile : String; ALine : longint); constructor Init_file_line(AFile : String; ALine : longint);
constructor Init_type(atyp : BreakpointType;Const AFunc : String); constructor Init_type(atyp : BreakpointType;Const AFunc : String);
procedure Insert; procedure Insert;
procedure Remove; procedure Remove;
@ -68,6 +72,7 @@ type
TBreakpointCollection=object(TCollection) TBreakpointCollection=object(TCollection)
function At(Index: Integer): PBreakpoint; function At(Index: Integer): PBreakpoint;
function ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean; function ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
procedure Update;
procedure FreeItem(Item: Pointer); virtual; procedure FreeItem(Item: Pointer); virtual;
end; end;
@ -83,8 +88,8 @@ implementation
uses uses
Dos,Mouse,Video, Dos,Mouse,Video,
App,Strings, App,Strings,
FPViews,FPVars,FPUtils,FPIntf, FPViews,FPVars,FPUtils,FPConst,
FPCompile,FPIde; FPIntf,FPCompile,FPIde;
{**************************************************************************** {****************************************************************************
@ -97,6 +102,8 @@ begin
inherited Init; inherited Init;
f := exefn; f := exefn;
LoadFile(f); LoadFile(f);
SetArgs(GetRunParameters);
Debugger:=@self;
InsertBreakpoints; InsertBreakpoints;
end; end;
@ -128,6 +135,30 @@ begin
inherited Done; inherited Done;
end; end;
procedure TDebugController.Run;
begin
inherited Run;
MyApp.SetCmdState([cmResetDebugger],true);
end;
procedure TDebugController.Continue;
begin
if not debugger_started then
Run;
inherited Continue;
end;
procedure TDebugController.Reset;
var
W : PSourceWindow;
begin
inherited Reset;
MyApp.SetCmdState([cmResetDebugger],false);
W:=PSourceWindow(LastSource);
if assigned(W) then
W^.Editor^.SetHighlightRow(-1);
end;
procedure TDebugController.AnnotateError; procedure TDebugController.AnnotateError;
var errornb : longint; var errornb : longint;
begin begin
@ -201,8 +232,23 @@ begin
end; end;
procedure TDebugController.DoEndSession(code:longint); procedure TDebugController.DoEndSession(code:longint);
var P :Array[1..2] of longint;
W : PSourceWindow;
begin begin
InformationBox(#3'Program exited with '#13#3'exitcode = %d',@code); MyApp.SetCmdState([cmResetDebugger],false);
W:=PSourceWindow(LastSource);
if assigned(W) then
W^.Editor^.SetHighlightRow(-1);
If HiddenStepsCount=0 then
InformationBox(#3'Program exited with '#13#3'exitcode = %d',@code)
else
begin
P[1]:=code;
P[2]:=HiddenStepsCount;
WarningBox(#3'Program exited with '#13+
#3'exitcode = %d'#13+
#3'hidden steps = %d',@P);
end;
end; end;
@ -244,11 +290,17 @@ begin
Conditions:=nil; Conditions:=nil;
end; end;
constructor TBreakpoint.Init_file_line(Const AFile : String; ALine : longint); constructor TBreakpoint.Init_file_line(AFile : String; ALine : longint);
begin begin
typ:=bt_file_line; typ:=bt_file_line;
state:=bs_enabled; state:=bs_enabled;
GDBState:=bs_deleted; GDBState:=bs_deleted;
AFile:=NameAndExtOf(AFile);
{ d:test.pas:12 does not work !! }
{ I do not know how to solve this if
if (Length(AFile)>1) and (AFile[2]=':') then
AFile:=Copy(AFile,3,255);
Only use base name for now !! PM }
Name:=NewStr(AFile); Name:=NewStr(AFile);
Line:=ALine; Line:=ALine;
IgnoreCount:=0; IgnoreCount:=0;
@ -259,7 +311,7 @@ end;
procedure TBreakpoint.Insert; procedure TBreakpoint.Insert;
begin begin
If not assigned(Debugger) then Exit; If not assigned(Debugger) then Exit;
Remove;
Debugger^.last_breakpoint_number:=0; Debugger^.last_breakpoint_number:=0;
if (GDBState=bs_deleted) and (state=bs_enabled) then if (GDBState=bs_deleted) and (state=bs_enabled) then
begin begin
@ -324,6 +376,7 @@ end;
destructor TBreakpoint.Done; destructor TBreakpoint.Done;
begin begin
Remove;
if assigned(Name) then if assigned(Name) then
DisposeStr(Name); DisposeStr(Name);
if assigned(Conditions) then if assigned(Conditions) then
@ -344,7 +397,17 @@ end;
procedure TBreakpointCollection.FreeItem(Item: Pointer); procedure TBreakpointCollection.FreeItem(Item: Pointer);
begin begin
if Item<>nil then Dispose(PBreakpoint(Item),Done); if Item<>nil then
Dispose(PBreakpoint(Item),Done);
end;
procedure TBreakpointCollection.Update;
begin
if assigned(Debugger) then
begin
Debugger^.RemoveBreakpoints;
Debugger^.InsertBreakpoints;
end;
end; end;
function TBreakpointCollection.ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean; function TBreakpointCollection.ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
@ -375,8 +438,10 @@ begin
ToggleFileLine:=true; ToggleFileLine:=true;
End; End;
end; end;
Update;
end; end;
{**************************************************************************** {****************************************************************************
Initialize Initialize
****************************************************************************} ****************************************************************************}
@ -406,9 +471,10 @@ procedure DoneDebugger;
begin begin
if assigned(Debugger) then if assigned(Debugger) then
dispose(Debugger,Done); dispose(Debugger,Done);
If Use_gdb_file then Debugger:=nil;
Close(GDB_file); If Use_gdb_file then
Use_gdb_file:=false; Close(GDB_file);
Use_gdb_file:=false;
end; end;
begin begin
@ -417,7 +483,13 @@ end.
{ {
$Log$ $Log$
Revision 1.8 1999-02-05 17:21:52 pierre Revision 1.9 1999-02-08 17:43:43 pierre
* RestDebugger or multiple running of debugged program now works
+ added DoContToCursor(F4)
* Breakpoints are now inserted correctly (was mainlyy a problem
of directories)
Revision 1.8 1999/02/05 17:21:52 pierre
Invalid_line renamed InvalidSourceLine Invalid_line renamed InvalidSourceLine
Revision 1.7 1999/02/05 13:08:41 pierre Revision 1.7 1999/02/05 13:08:41 pierre

View File

@ -51,6 +51,7 @@ type
procedure DoTraceInto; procedure DoTraceInto;
procedure DoRun; procedure DoRun;
procedure DoResetDebugger; procedure DoResetDebugger;
procedure DoContToCursor;
procedure Target; procedure Target;
procedure PrimaryFile_; procedure PrimaryFile_;
procedure ClearPrimary; procedure ClearPrimary;
@ -184,9 +185,10 @@ begin
NewItem('~R~un','Ctrl+F9', kbCtrlF9, cmRun, hcRun, NewItem('~R~un','Ctrl+F9', kbCtrlF9, cmRun, hcRun,
NewItem('~S~tep over','F8', kbF8, cmStepOver, hcRun, NewItem('~S~tep over','F8', kbF8, cmStepOver, hcRun,
NewItem('~T~race into','F7', kbF7, cmTraceInto, hcRun, NewItem('~T~race into','F7', kbF7, cmTraceInto, hcRun,
NewItem('~G~oto Cursor','F4', kbF4, cmContToCursor, hcContToCursor,
NewItem('P~a~rameters...','', kbNoKey, cmParameters, hcParameters, NewItem('P~a~rameters...','', kbNoKey, cmParameters, hcParameters,
NewItem('~P~rogram reset','Ctrl+F2', kbCtrlF2, cmResetDebugger, hcResetDebugger, NewItem('~P~rogram reset','Ctrl+F2', kbCtrlF2, cmResetDebugger, hcResetDebugger,
nil)))))), nil))))))),
NewSubMenu('~C~ompile',hcCompileMenu, NewMenu( NewSubMenu('~C~ompile',hcCompileMenu, NewMenu(
NewItem('~C~ompile','Alt+F9', kbAltF9, cmCompile, hcCompile, NewItem('~C~ompile','Alt+F9', kbAltF9, cmCompile, hcCompile,
NewItem('~M~ake','F9', kbF9, cmMake, hcMake, NewItem('~M~ake','F9', kbF9, cmMake, hcMake,
@ -338,7 +340,7 @@ begin
cmTraceInto : DoTraceInto; cmTraceInto : DoTraceInto;
cmRun : DoRun; cmRun : DoRun;
cmResetDebugger : DoResetDebugger; cmResetDebugger : DoResetDebugger;
cmContToCursor : DoContToCursor;
{ -- Compile menu -- } { -- Compile menu -- }
cmCompile : DoCompile(cCompile); cmCompile : DoCompile(cCompile);
cmBuild : DoCompile(cBuild); cmBuild : DoCompile(cBuild);
@ -451,7 +453,7 @@ begin
WriteShellMsg; WriteShellMsg;
SwapVectors; SwapVectors;
Exec(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params); Dos.Exec(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params);
SwapVectors; SwapVectors;
ShowIDEScreen; ShowIDEScreen;
@ -463,6 +465,7 @@ begin
SetCmdState([cmSaveAll],IsThereAnyEditor); SetCmdState([cmSaveAll],IsThereAnyEditor);
SetCmdState([cmCloseAll,cmTile,cmCascade,cmWindowList],IsThereAnyWindow); SetCmdState([cmCloseAll,cmTile,cmCascade,cmWindowList],IsThereAnyWindow);
SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals{,cmInformation}],IsSymbolInfoAvailable); SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals{,cmInformation}],IsSymbolInfoAvailable);
SetCmdState([cmResetDebugger],assigned(debugger) and debugger^.debugger_started);
UpdatePrimaryFile; UpdatePrimaryFile;
UpdateINIFile; UpdateINIFile;
Message(MenuBar,evBroadcast,cmUpdate,nil); Message(MenuBar,evBroadcast,cmUpdate,nil);
@ -644,7 +647,13 @@ end;
END. END.
{ {
$Log$ $Log$
Revision 1.11 1999-02-08 10:37:44 peter Revision 1.12 1999-02-08 17:43:44 pierre
* RestDebugger or multiple running of debugged program now works
+ added DoContToCursor(F4)
* Breakpoints are now inserted correctly (was mainlyy a problem
of directories)
Revision 1.11 1999/02/08 10:37:44 peter
+ html helpviewer + html helpviewer
Revision 1.7 1999/02/04 13:32:03 pierre Revision 1.7 1999/02/04 13:32:03 pierre

View File

@ -22,14 +22,18 @@ begin
InitDebugger; InitDebugger;
if not assigned(Debugger) then if not assigned(Debugger) then
exit; exit;
Debugger^.StartTrace; end;
end if not debugger^.debugger_started then
Debugger^.StartTrace
else else
Debugger^.TraceNext; Debugger^.TraceNext;
While (Debugger^.InvalidSourceLine and While (Debugger^.InvalidSourceLine and
Debugger^.Debugger_started and Debugger^.Debugger_started and
not Debugger^.error) do not Debugger^.error) do
Debugger^.TraceNext; begin
Inc(Debugger^.HiddenStepsCount);
Debugger^.TraceNext;
end;
Debugger^.AnnotateError; Debugger^.AnnotateError;
end; end;
@ -40,17 +44,21 @@ begin
begin begin
InitDebugger; InitDebugger;
if not assigned(Debugger) then if not assigned(Debugger) then
exit; exit;
Debugger^.StartTrace; end;
end if not debugger^.debugger_started then
Debugger^.StartTrace
else else
Debugger^.TraceStep; Debugger^.TraceStep;
{ I think we should not try to go deeper ! { I think we should not try to go deeper !
if the source is not found PM } if the source is not found PM }
While (Debugger^.InvalidSourceLine and While (Debugger^.InvalidSourceLine and
Debugger^.Debugger_started and Debugger^.Debugger_started and
not Debugger^.error) do not Debugger^.error) do
Debugger^.TraceStep; begin
Inc(Debugger^.HiddenStepsCount);
Debugger^.TraceNext;
end;
Debugger^.AnnotateError; Debugger^.AnnotateError;
end; end;
@ -113,6 +121,32 @@ procedure TIDEApp.DoResetDebugger;
begin begin
if assigned(Debugger) then if assigned(Debugger) then
DoneDebugger; DoneDebugger;
UpdateScreen(true);
end;
procedure TIDEApp.DoContToCursor;
var
W : PSourceWindow;
FileName : string;
LineNr : longint;
begin
if not assigned(DeskTop^.First) or
(TypeOf(DeskTop^.First^)<>TypeOf(TSourceWindow)) then
Begin
ErrorBox('Impossible to reach current cursor',nil);
Exit;
End;
W:=PSourceWindow(DeskTop^.First);
If assigned(W) then
begin
FileName:=W^.Editor^.FileName;
LineNr:=W^.Editor^.CurPos.Y+1;
If not assigned(Debugger) then
InitDebugger;
Debugger^.Command('tbreak '+NameAndExtOf(FileName)+':'+IntToStr(LineNr));
Debugger^.Continue;
end;
end; end;
procedure TIDEApp.DoToggleBreak; procedure TIDEApp.DoToggleBreak;
@ -149,7 +183,13 @@ end;
{ {
$Log$ $Log$
Revision 1.9 1999-02-05 17:21:53 pierre Revision 1.10 1999-02-08 17:43:45 pierre
* RestDebugger or multiple running of debugged program now works
+ added DoContToCursor(F4)
* Breakpoints are now inserted correctly (was mainlyy a problem
of directories)
Revision 1.9 1999/02/05 17:21:53 pierre
Invalid_line renamed InvalidSourceLine Invalid_line renamed InvalidSourceLine
Revision 1.8 1999/02/04 17:56:17 pierre Revision 1.8 1999/02/04 17:56:17 pierre