mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-20 03:52:50 +02:00
* Breakpoint line in Source Window better handled
This commit is contained in:
parent
72c961f0f5
commit
0e09b3a168
@ -26,6 +26,10 @@ type
|
|||||||
PDebugController=^TDebugController;
|
PDebugController=^TDebugController;
|
||||||
TDebugController=object(TGDBController)
|
TDebugController=object(TGDBController)
|
||||||
InvalidSourceLine : boolean;
|
InvalidSourceLine : boolean;
|
||||||
|
|
||||||
|
{ if true the current debugger raw will stay in middle of
|
||||||
|
editor window when debugging PM }
|
||||||
|
CenterDebuggerRow : boolean;
|
||||||
LastFileName : string;
|
LastFileName : string;
|
||||||
LastSource : PView; {PsourceWindow !! }
|
LastSource : PView; {PsourceWindow !! }
|
||||||
HiddenStepsCount : longint;
|
HiddenStepsCount : longint;
|
||||||
@ -83,6 +87,7 @@ type
|
|||||||
procedure Remove;
|
procedure Remove;
|
||||||
procedure Enable;
|
procedure Enable;
|
||||||
procedure Disable;
|
procedure Disable;
|
||||||
|
procedure UpdateSource;
|
||||||
procedure ResetValues;
|
procedure ResetValues;
|
||||||
destructor Done;virtual;
|
destructor Done;virtual;
|
||||||
end;
|
end;
|
||||||
@ -91,9 +96,10 @@ type
|
|||||||
function At(Index: Integer): PBreakpoint;
|
function At(Index: Integer): PBreakpoint;
|
||||||
function GetGDB(index : longint) : PBreakpoint;
|
function GetGDB(index : longint) : PBreakpoint;
|
||||||
function GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
|
function GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
|
||||||
function ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
|
function ToggleFileLine(FileName: String;LineNr : Longint) : boolean;
|
||||||
procedure Update;
|
procedure Update;
|
||||||
procedure ShowBreakpoints(W : PSourceWindow);
|
procedure ShowBreakpoints(W : PSourceWindow);
|
||||||
|
procedure ShowAllBreakpoints;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PBreakpointItem = ^TBreakpointItem;
|
PBreakpointItem = ^TBreakpointItem;
|
||||||
@ -300,6 +306,7 @@ const
|
|||||||
procedure InitRegistersWindow;
|
procedure InitRegistersWindow;
|
||||||
procedure DoneRegistersWindow;
|
procedure DoneRegistersWindow;
|
||||||
function ActiveBreakpoints : boolean;
|
function ActiveBreakpoints : boolean;
|
||||||
|
function GDBFileName(st : string) : string;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -437,6 +444,27 @@ const
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
function GDBFileName(st : string) : string;
|
||||||
|
{$ifndef Linux}
|
||||||
|
var i : longint;
|
||||||
|
{$endif Linux}
|
||||||
|
begin
|
||||||
|
{$ifdef Linux}
|
||||||
|
GDBFileName:=st;
|
||||||
|
{$else}
|
||||||
|
{ should we also use / chars ? }
|
||||||
|
for i:=1 to Length(st) do
|
||||||
|
if st[i]='\' then
|
||||||
|
st[i]:='/';
|
||||||
|
{$ifdef win32}
|
||||||
|
{ for win32 we should conver e:\ into //e/ PM }
|
||||||
|
if (length(st)>2) and (st[2]=':') and (st[3]='/') then
|
||||||
|
st:='//'+st[1]+copy(st,3,length(st));
|
||||||
|
{$endif win32}
|
||||||
|
GDBFileName:=LowerCaseStr(st);
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
TDebugController
|
TDebugController
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
@ -458,7 +486,8 @@ constructor TDebugController.Init(const exefn:string);
|
|||||||
var f: string;
|
var f: string;
|
||||||
begin
|
begin
|
||||||
inherited Init;
|
inherited Init;
|
||||||
f := GetShortName(exefn);
|
CenterDebuggerRow:=IniCenterDebuggerRow;
|
||||||
|
f := GetShortName(GDBFileName(exefn));
|
||||||
NoSwitch:=False;
|
NoSwitch:=False;
|
||||||
LoadFile(f);
|
LoadFile(f);
|
||||||
SetArgs(GetRunParameters);
|
SetArgs(GetRunParameters);
|
||||||
@ -669,12 +698,13 @@ begin
|
|||||||
if assigned(W) then
|
if assigned(W) then
|
||||||
begin
|
begin
|
||||||
W^.Editor^.SetCurPtr(0,Line);
|
W^.Editor^.SetCurPtr(0,Line);
|
||||||
W^.Editor^.TrackCursor(true);
|
W^.Editor^.TrackCursor(CenterDebuggerRow);
|
||||||
W^.Editor^.SetDebuggerRow(Line);
|
W^.Editor^.SetDebuggerRow(Line);
|
||||||
UpdateDebugViews;
|
UpdateDebugViews;
|
||||||
|
|
||||||
if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
{if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
||||||
W^.Select;
|
handled by SelectInDebugSession}
|
||||||
|
W^.SelectInDebugSession;
|
||||||
InvalidSourceLine:=false;
|
InvalidSourceLine:=false;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -686,10 +716,11 @@ begin
|
|||||||
if assigned(W) then
|
if assigned(W) then
|
||||||
begin
|
begin
|
||||||
W^.Editor^.SetDebuggerRow(Line);
|
W^.Editor^.SetDebuggerRow(Line);
|
||||||
W^.Editor^.TrackCursor(true);
|
W^.Editor^.TrackCursor(CenterDebuggerRow);
|
||||||
UpdateDebugViews;
|
UpdateDebugViews;
|
||||||
if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
{if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
||||||
W^.Select;
|
handled by SelectInDebugSession}
|
||||||
|
W^.SelectInDebugSession;
|
||||||
LastSource:=W;
|
LastSource:=W;
|
||||||
InvalidSourceLine:=false;
|
InvalidSourceLine:=false;
|
||||||
end
|
end
|
||||||
@ -709,10 +740,11 @@ begin
|
|||||||
{ should now be open }
|
{ should now be open }
|
||||||
W:=TryToOpenFile(nil,fn,0,Line,true);
|
W:=TryToOpenFile(nil,fn,0,Line,true);
|
||||||
W^.Editor^.SetDebuggerRow(Line);
|
W^.Editor^.SetDebuggerRow(Line);
|
||||||
W^.Editor^.TrackCursor(true);
|
W^.Editor^.TrackCursor(CenterDebuggerRow);
|
||||||
UpdateDebugViews;
|
UpdateDebugViews;
|
||||||
if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
{if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
|
||||||
W^.Select;
|
handled by SelectInDebugSession}
|
||||||
|
W^.SelectInDebugSession;
|
||||||
LastSource:=W;
|
LastSource:=W;
|
||||||
InvalidSourceLine:=false;
|
InvalidSourceLine:=false;
|
||||||
end;
|
end;
|
||||||
@ -756,7 +788,6 @@ end;
|
|||||||
|
|
||||||
procedure TDebugController.DoEndSession(code:longint);
|
procedure TDebugController.DoEndSession(code:longint);
|
||||||
var P :Array[1..2] of longint;
|
var P :Array[1..2] of longint;
|
||||||
W : PSourceWindow;
|
|
||||||
begin
|
begin
|
||||||
IDEApp.SetCmdState([cmResetDebugger],false);
|
IDEApp.SetCmdState([cmResetDebugger],false);
|
||||||
ResetDebuggerRows;
|
ResetDebuggerRows;
|
||||||
@ -848,7 +879,7 @@ begin
|
|||||||
if (Length(AFile)>1) and (AFile[2]=':') then
|
if (Length(AFile)>1) and (AFile[2]=':') then
|
||||||
AFile:=Copy(AFile,3,255);
|
AFile:=Copy(AFile,3,255);
|
||||||
Only use base name for now !! PM }
|
Only use base name for now !! PM }
|
||||||
FileName:=NewStr(AFile);
|
FileName:=NewStr(GDBFileName(NameAndExtOf(AFile)));
|
||||||
Name:=nil;
|
Name:=nil;
|
||||||
Line:=ALine;
|
Line:=ALine;
|
||||||
IgnoreCount:=0;
|
IgnoreCount:=0;
|
||||||
@ -937,8 +968,12 @@ begin
|
|||||||
{ Here there was a problem !! }
|
{ Here there was a problem !! }
|
||||||
begin
|
begin
|
||||||
GDBIndex:=0;
|
GDBIndex:=0;
|
||||||
ErrorBox(#3'Could not set Breakpoint'#13+
|
if (typ=bt_file_line) and assigned(FileName) then
|
||||||
#3+BreakpointTypeStr[typ]+' '+GetStr(Name),nil);
|
ErrorBox(#3'Could not set Breakpoint'#13+
|
||||||
|
#3+NameAndExtOf(FileName^)+':'+IntToStr(Line),nil)
|
||||||
|
else
|
||||||
|
ErrorBox(#3'Could not set Breakpoint'#13+
|
||||||
|
#3+BreakpointTypeStr[typ]+' '+GetStr(Name),nil);
|
||||||
state:=bs_disabled;
|
state:=bs_disabled;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
@ -985,6 +1020,24 @@ begin
|
|||||||
CurrentValue:=nil;
|
CurrentValue:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBreakpoint.UpdateSource;
|
||||||
|
var W: PSourceWindow;
|
||||||
|
b : boolean;
|
||||||
|
begin
|
||||||
|
if typ=bt_file_line then
|
||||||
|
begin
|
||||||
|
W:=SearchOnDesktop(GetStr(FileName),false);
|
||||||
|
If assigned(W) then
|
||||||
|
begin
|
||||||
|
if state=bs_enabled then
|
||||||
|
b:=true
|
||||||
|
else
|
||||||
|
b:=false;
|
||||||
|
W^.Editor^.SetLineBreakState(Line,b);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
destructor TBreakpoint.Done;
|
destructor TBreakpoint.Done;
|
||||||
begin
|
begin
|
||||||
Remove;
|
Remove;
|
||||||
@ -1038,7 +1091,7 @@ procedure TBreakpointCollection.ShowBreakpoints(W : PSourceWindow);
|
|||||||
|
|
||||||
procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
|
procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
|
||||||
begin
|
begin
|
||||||
If assigned(P^.FileName) and (P^.FileName^=W^.Editor^.FileName) then
|
If assigned(P^.FileName) and (P^.FileName^=NameAndExtOf(W^.Editor^.FileName)) then
|
||||||
W^.Editor^.SetLineBreakState(P^.Line,P^.state=bs_enabled);
|
W^.Editor^.SetLineBreakState(P^.Line,P^.state=bs_enabled);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1046,6 +1099,24 @@ begin
|
|||||||
ForEach(@SetInSource);
|
ForEach(@SetInSource);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBreakpointCollection.ShowAllBreakpoints;
|
||||||
|
|
||||||
|
procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
|
||||||
|
var
|
||||||
|
W : PSourceWindow;
|
||||||
|
begin
|
||||||
|
If assigned(P^.FileName) then
|
||||||
|
begin
|
||||||
|
W:=SearchOnDesktop(P^.FileName^,false);
|
||||||
|
if assigned(W) then
|
||||||
|
W^.Editor^.SetLineBreakState(P^.Line,P^.state=bs_enabled);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ForEach(@SetInSource);
|
||||||
|
end;
|
||||||
|
|
||||||
function TBreakpointCollection.GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
|
function TBreakpointCollection.GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
|
||||||
|
|
||||||
function IsThis(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
|
function IsThis(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
|
||||||
@ -1057,15 +1128,16 @@ begin
|
|||||||
GetType:=FirstThat(@IsThis);
|
GetType:=FirstThat(@IsThis);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBreakpointCollection.ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
|
function TBreakpointCollection.ToggleFileLine(FileName: String;LineNr : Longint) : boolean;
|
||||||
|
|
||||||
var PB : PBreakpoint;
|
var PB : PBreakpoint;
|
||||||
|
|
||||||
function IsThere(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
|
function IsThere(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
|
||||||
begin
|
begin
|
||||||
IsThere:=(P^.typ=bt_file_line) and (P^.FileName^=FileName) and (P^.Line=LineNr);
|
IsThere:=(P^.typ=bt_file_line) and (GDBFileName(P^.FileName^)=FileName) and (P^.Line=LineNr);
|
||||||
end;
|
end;
|
||||||
begin
|
begin
|
||||||
|
FileName:=GDBFileName(FileName);
|
||||||
PB:=FirstThat(@IsThere);
|
PB:=FirstThat(@IsThere);
|
||||||
ToggleFileLine:=false;
|
ToggleFileLine:=false;
|
||||||
If Assigned(PB) then
|
If Assigned(PB) then
|
||||||
@ -1085,6 +1157,8 @@ begin
|
|||||||
ToggleFileLine:=true;
|
ToggleFileLine:=true;
|
||||||
End;
|
End;
|
||||||
end;
|
end;
|
||||||
|
if assigned(PB) then
|
||||||
|
PB^.UpdateSource;
|
||||||
Update;
|
Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1179,6 +1253,10 @@ begin
|
|||||||
case Event.KeyCode of
|
case Event.KeyCode of
|
||||||
kbEnter :
|
kbEnter :
|
||||||
Message(@Self,evCommand,cmMsgGotoSource,nil);
|
Message(@Self,evCommand,cmMsgGotoSource,nil);
|
||||||
|
kbIns :
|
||||||
|
Message(@Self,evCommand,cmNewBreakpoint,nil);
|
||||||
|
kbDel :
|
||||||
|
Message(@Self,evCommand,cmDeleteBreakpoint,nil);
|
||||||
else
|
else
|
||||||
DontClear:=true;
|
DontClear:=true;
|
||||||
end;
|
end;
|
||||||
@ -1233,6 +1311,7 @@ begin
|
|||||||
SetRange(List^.Count);
|
SetRange(List^.Count);
|
||||||
if Focused=List^.Count-1-1 then
|
if Focused=List^.Count-1-1 then
|
||||||
FocusItem(List^.Count-1);
|
FocusItem(List^.Count-1);
|
||||||
|
P^.Breakpoint^.UpdateSource;
|
||||||
DrawView;
|
DrawView;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1302,10 +1381,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBreakpointsListBox.ToggleCurrent;
|
procedure TBreakpointsListBox.ToggleCurrent;
|
||||||
var W: PSourceWindow;
|
var
|
||||||
P: PBreakpointItem;
|
P: PBreakpointItem;
|
||||||
b : boolean;
|
|
||||||
(* Row,Col: sw_integer; *)
|
|
||||||
begin
|
begin
|
||||||
if Range=0 then Exit;
|
if Range=0 then Exit;
|
||||||
P:=List^.At(Focused);
|
P:=List^.At(Focused);
|
||||||
@ -1314,19 +1391,8 @@ begin
|
|||||||
P^.Breakpoint^.state:=bs_disabled
|
P^.Breakpoint^.state:=bs_disabled
|
||||||
else if P^.Breakpoint^.state=bs_disabled then
|
else if P^.Breakpoint^.state=bs_disabled then
|
||||||
P^.Breakpoint^.state:=bs_enabled;
|
P^.Breakpoint^.state:=bs_enabled;
|
||||||
|
P^.Breakpoint^.UpdateSource;
|
||||||
BreakpointsCollection^.Update;
|
BreakpointsCollection^.Update;
|
||||||
if P^.Breakpoint^.typ=bt_file_line then
|
|
||||||
begin
|
|
||||||
W:=TryToOpenFile(nil,GetStr(P^.Breakpoint^.FileName),1,P^.Breakpoint^.Line,false);
|
|
||||||
If assigned(W) then
|
|
||||||
begin
|
|
||||||
if P^.Breakpoint^.state=bs_enabled then
|
|
||||||
b:=true
|
|
||||||
else
|
|
||||||
b:=false;
|
|
||||||
W^.Editor^.SetLineBreakState(P^.Breakpoint^.Line,b);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBreakpointsListBox.EditCurrent;
|
procedure TBreakpointsListBox.EditCurrent;
|
||||||
@ -1337,6 +1403,7 @@ begin
|
|||||||
P:=List^.At(Focused);
|
P:=List^.At(Focused);
|
||||||
if P=nil then Exit;
|
if P=nil then Exit;
|
||||||
Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P^.Breakpoint)),nil);
|
Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P^.Breakpoint)),nil);
|
||||||
|
P^.Breakpoint^.UpdateSource;
|
||||||
BreakpointsCollection^.Update;
|
BreakpointsCollection^.Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1347,6 +1414,9 @@ begin
|
|||||||
if Range=0 then Exit;
|
if Range=0 then Exit;
|
||||||
P:=List^.At(Focused);
|
P:=List^.At(Focused);
|
||||||
if P=nil then Exit;
|
if P=nil then Exit;
|
||||||
|
{ delete it form source window }
|
||||||
|
P^.Breakpoint^.state:=bs_disabled;
|
||||||
|
P^.Breakpoint^.UpdateSource;
|
||||||
BreakpointsCollection^.free(P^.Breakpoint);
|
BreakpointsCollection^.free(P^.Breakpoint);
|
||||||
List^.free(P);
|
List^.free(P);
|
||||||
BreakpointsCollection^.Update;
|
BreakpointsCollection^.Update;
|
||||||
@ -1359,6 +1429,7 @@ begin
|
|||||||
P:=New(PBreakpoint,Init_Empty);
|
P:=New(PBreakpoint,Init_Empty);
|
||||||
if Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P)),nil)<>cmCancel then
|
if Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P)),nil)<>cmCancel then
|
||||||
begin
|
begin
|
||||||
|
P^.UpdateSource;
|
||||||
BreakpointsCollection^.Insert(P);
|
BreakpointsCollection^.Insert(P);
|
||||||
BreakpointsCollection^.Update;
|
BreakpointsCollection^.Update;
|
||||||
end
|
end
|
||||||
@ -2879,6 +2950,7 @@ var s : string;
|
|||||||
{$endif DEBUG}
|
{$endif DEBUG}
|
||||||
begin
|
begin
|
||||||
{$ifdef DEBUG}
|
{$ifdef DEBUG}
|
||||||
|
PushStatus('Starting debugger');
|
||||||
Assign(gdb_file,GDBOutFileName);
|
Assign(gdb_file,GDBOutFileName);
|
||||||
{$I-}
|
{$I-}
|
||||||
Rewrite(gdb_file);
|
Rewrite(gdb_file);
|
||||||
@ -2923,11 +2995,17 @@ begin
|
|||||||
{$ifdef GDBWINDOW}
|
{$ifdef GDBWINDOW}
|
||||||
InitGDBWindow;
|
InitGDBWindow;
|
||||||
{$endif def GDBWINDOW}
|
{$endif def GDBWINDOW}
|
||||||
|
{$ifdef DEBUG}
|
||||||
|
PopStatus;
|
||||||
|
{$endif DEBUG}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure DoneDebugger;
|
procedure DoneDebugger;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef DEBUG}
|
||||||
|
PushStatus('Closing debugger');
|
||||||
|
{$endif}
|
||||||
if assigned(Debugger) then
|
if assigned(Debugger) then
|
||||||
dispose(Debugger,Done);
|
dispose(Debugger,Done);
|
||||||
Debugger:=nil;
|
Debugger:=nil;
|
||||||
@ -2935,7 +3013,8 @@ begin
|
|||||||
If Use_gdb_file then
|
If Use_gdb_file then
|
||||||
Close(GDB_file);
|
Close(GDB_file);
|
||||||
Use_gdb_file:=false;
|
Use_gdb_file:=false;
|
||||||
{$endif}
|
PopStatus;
|
||||||
|
{$endif DEBUG}
|
||||||
{DoneGDBWindow;}
|
{DoneGDBWindow;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3040,7 +3119,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.46 2000-02-01 10:59:58 pierre
|
Revision 1.47 2000-02-04 00:10:58 pierre
|
||||||
|
* Breakpoint line in Source Window better handled
|
||||||
|
|
||||||
|
Revision 1.46 2000/02/01 10:59:58 pierre
|
||||||
* allow FP to debug itself
|
* allow FP to debug itself
|
||||||
|
|
||||||
Revision 1.45 2000/01/28 22:38:21 pierre
|
Revision 1.45 2000/01/28 22:38:21 pierre
|
||||||
|
Loading…
Reference in New Issue
Block a user