debugger: save/load breakpoint log messages, log message on breakpoint hit

git-svn-id: trunk@30653 -
This commit is contained in:
paul 2011-05-10 03:52:45 +00:00
parent 7223934312
commit 4ae562d3db
5 changed files with 128 additions and 89 deletions

View File

@ -170,8 +170,7 @@ end;
function GetBreakPointActionsDescription(ABreakpoint: TBaseBreakpoint): string;
const
DEBUG_ACTION: array[TIDEBreakPointAction] of ShortString =
(lisBreak, lisEnableGroup, lisDisableGroup);
(lisBreak, lisEnableGroup, lisDisableGroup, lisLogMessage);
var
CurBreakPoint: TIDEBreakPoint;
Action: TIDEBreakPointAction;

View File

@ -20,9 +20,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtFilename
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Height = 16
Top = 9
Width = 47
Width = 52
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Filename:'
@ -33,9 +33,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtLine
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 36
Width = 24
Height = 16
Top = 38
Width = 26
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Line:'
@ -46,9 +46,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtCondition
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 63
Width = 50
Height = 16
Top = 67
Width = 57
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Condition:'
@ -59,9 +59,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtCounter
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 90
Width = 45
Height = 16
Top = 96
Width = 51
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Hitcount:'
@ -72,9 +72,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = cmbGroup
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 144
Width = 34
Height = 16
Top = 154
Width = 37
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Group:'
@ -85,9 +85,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtAutocontinueMS
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 117
Width = 95
Height = 16
Top = 125
Width = 104
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Auto continue after'
@ -98,10 +98,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblAutoContinue
AnchorSideTop.Side = asrCenter
Left = 197
Height = 14
Top = 117
Width = 22
Left = 206
Height = 16
Top = 125
Width = 25
BorderSpacing.Left = 6
Caption = '(ms)'
ParentColor = False
@ -112,9 +112,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtCounter
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Top = 114
Left = 140
Height = 23
Top = 122
Width = 60
BorderSpacing.Left = 24
BorderSpacing.Around = 6
@ -128,10 +128,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Top = 87
Width = 313
Left = 140
Height = 23
Top = 93
Width = 304
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Around = 6
@ -144,9 +144,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtFilename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Top = 33
Left = 140
Height = 23
Top = 35
Width = 60
BorderSpacing.Left = 24
BorderSpacing.Around = 6
@ -161,10 +161,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Left = 140
Height = 23
Top = 6
Width = 313
Width = 304
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Around = 6
@ -180,14 +180,14 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Top = 141
Width = 313
Left = 140
Height = 23
Top = 151
Width = 304
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Around = 6
ItemHeight = 13
ItemHeight = 15
TabOrder = 4
Text = 'cmbGroup'
end
@ -198,23 +198,23 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 155
Top = 168
Height = 165
Top = 180
Width = 438
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Actions'
ClientHeight = 137
ClientHeight = 147
ClientWidth = 434
TabOrder = 5
object chkActionBreak: TCheckBox
AnchorSideLeft.Control = gbActions
AnchorSideTop.Control = gbActions
Left = 6
Height = 17
Height = 19
Top = 6
Width = 45
Width = 49
BorderSpacing.Around = 6
Caption = 'Break'
TabOrder = 0
@ -224,9 +224,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtEnableGroups
AnchorSideTop.Side = asrCenter
Left = 6
Height = 17
Top = 31
Width = 82
Height = 19
Top = 33
Width = 91
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Enable goups'
@ -237,9 +237,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtDisableGroups
AnchorSideTop.Side = asrCenter
Left = 6
Height = 17
Top = 58
Width = 88
Height = 19
Top = 62
Width = 98
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Disable groups'
@ -251,10 +251,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = chkActionBreak
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 119
Height = 21
Top = 29
Width = 286
Left = 125
Height = 23
Top = 31
Width = 280
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
BorderSpacing.Top = 6
@ -272,10 +272,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtEnableGroups
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 119
Height = 21
Top = 56
Width = 286
Left = 125
Height = 23
Top = 60
Width = 280
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
BorderSpacing.Top = 6
@ -292,9 +292,9 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtEvalExpression
AnchorSideTop.Side = asrCenter
Left = 6
Height = 17
Top = 85
Width = 93
Height = 19
Top = 91
Width = 99
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Eval expression'
@ -306,13 +306,13 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Control = edtLogMessage
AnchorSideTop.Side = asrCenter
Left = 6
Height = 17
Top = 112
Width = 80
Height = 19
Top = 120
Width = 89
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Log message'
Enabled = False
OnChange = chkLogMessageChange
TabOrder = 4
end
object edtEvalExpression: TEdit
@ -322,10 +322,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbActions
AnchorSideRight.Side = asrBottom
Left = 119
Height = 21
Top = 83
Width = 309
Left = 125
Height = 23
Top = 89
Width = 303
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
BorderSpacing.Top = 6
@ -341,10 +341,10 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = gbActions
AnchorSideRight.Side = asrBottom
Left = 119
Height = 21
Top = 110
Width = 309
Left = 125
Height = 23
Top = 118
Width = 303
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
BorderSpacing.Top = 6
@ -359,8 +359,8 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 36
Top = 329
Height = 14
Top = 351
Width = 438
Anchors = [akTop, akLeft, akRight, akBottom]
OKButton.Name = 'OKButton'
@ -385,14 +385,14 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 131
Height = 21
Top = 60
Width = 313
Left = 140
Height = 23
Top = 64
Width = 304
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Around = 6
ItemHeight = 13
ItemHeight = 15
TabOrder = 7
Text = 'edtCondition'
end

View File

@ -45,6 +45,7 @@ type
const ABreakpoint: TIDEBreakPoint);
procedure BreakPointUpdate(const ASender: TIDEBreakPoints;
const ABreakpoint: TIDEBreakPoint);
procedure chkLogMessageChange(Sender: TObject);
private
FBreakpointsNotification : TIDEBreakPointsNotification;
FBreakpoint: TIDEBreakPoint;
@ -68,6 +69,11 @@ begin
UpdateInfo;
end;
procedure TBreakPropertyDlg.chkLogMessageChange(Sender: TObject);
begin
edtLogMessage.Enabled := chkLogMessage.Checked;
end;
procedure TBreakPropertyDlg.btnHelpClick(Sender: TObject);
begin
LazarusHelp.ShowHelpForIDEControl(Self);
@ -104,8 +110,9 @@ begin
if chkDisableGroups.Checked then Include(Actions, bpaDisableGroup);
if chkEnableGroups.Checked then Include(Actions, bpaEnableGroup);
// if chkEvalExpression.Checked then Include(Actions, bpaEValExpression);
// if chkLogMessage.Checked then Include(Actions, bpaLogMessage);
if chkLogMessage.Checked then Include(Actions, bpaLogMessage);
FBreakpoint.Actions := Actions;
FBreakpoint.LogMessage := edtLogMessage.Text;
InputHistories.HistoryLists.GetList('BreakPointExpression', True).Add(edtCondition.Text);
end;
@ -144,7 +151,8 @@ begin
chkDisableGroups.Checked := bpaDisableGroup in Actions;
chkEnableGroups.Checked := bpaEnableGroup in Actions;
// chkEvalExpression.Checked := bpaEValExpression in Actions;
// chkLogMessage.Checked := bpaLogMessage in Actions;
chkLogMessage.Checked := bpaLogMessage in Actions;
edtLogMessage.Text := FBreakpoint.LogMessage;
end;
constructor TBreakPropertyDlg.Create(AOwner: TComponent; ABreakPoint: TIDEBreakPoint);

View File

@ -275,7 +275,8 @@ type
TIDEBreakPointAction = (
bpaStop,
bpaEnableGroup,
bpaDisableGroup
bpaDisableGroup,
bpaLogMessage
);
TIDEBreakPointActions = set of TIDEBreakPointAction;
@ -341,11 +342,11 @@ type
FEnableGroupList: TList;
FGroup: TIDEBreakPointGroup;
FLoading: Boolean;
FLogMessage: String;
protected
procedure AssignLocationTo(Dest: TPersistent); override;
procedure AssignTo(Dest: TPersistent); override;
procedure DoChanged; override;
function GetHitCount: Integer; override;
function GetValid: TValidState; override;
procedure SetBreakHitCount(const AValue: Integer); override;
@ -367,9 +368,11 @@ type
function GetActions: TIDEBreakPointActions; virtual;
function GetGroup: TIDEBreakPointGroup; virtual;
function GetAutoContinueTime: Cardinal; virtual;
function GetLogMessage: String; virtual;
procedure SetActions(const AValue: TIDEBreakPointActions); virtual;
procedure SetGroup(const AValue: TIDEBreakPointGroup); virtual;
procedure SetAutoContinueTime(const AValue: Cardinal); virtual;
procedure SetLogMessage(const AValue: String); virtual;
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
@ -389,6 +392,7 @@ type
property AutoContinueTime: Cardinal read GetAutoContinueTime write SetAutoContinueTime;
property Group: TIDEBreakPointGroup read GetGroup write SetGroup;
property Loading: Boolean read FLoading;
property LogMessage: String read GetLogMessage write SetLogMessage;
end;
TIDEBreakPointClass = class of TIDEBreakPoint;
@ -402,6 +406,7 @@ type
protected
procedure DoChanged; override;
procedure DoStateChange(const AOldState: TDBGState); virtual;
procedure DoLogMessage(const AMessage: String); virtual;
property Debugger: TDebugger read GetDebugger;
public
constructor Create(ACollection: TCollection); override;
@ -2116,7 +2121,8 @@ const
DBGBreakPointActionNames: array[TIDEBreakPointAction] of string = (
'Stop',
'EnableGroup',
'DisableGroup'
'DisableGroup',
'LogMessage'
);
function DBGCommandNameToCommand(const s: string): TDBGCommand;
@ -3495,6 +3501,20 @@ begin
Changed;
end;
procedure TIDEBreakPoint.SetLogMessage(const AValue: String);
begin
if FLogMessage <> AValue then
begin
FLogMessage := AValue;
Changed;
end;
end;
function TIDEBreakPoint.GetLogMessage: String;
begin
Result := FLogMessage;
end;
procedure TIDEBreakPoint.AssignLocationTo(Dest: TPersistent);
var
DestBreakPoint: TBaseBreakPoint absolute Dest;
@ -3512,6 +3532,7 @@ begin
then begin
TIDEBreakPoint(Dest).Actions := FActions;
TIDEBreakPoint(Dest).AutoContinueTime := FAutoContinueTime;
TIDEBreakPoint(Dest).LogMessage := FLogMessage;
end;
if (Collection <> nil) and (TIDEBreakPoints(Collection).FMaster <> nil)
@ -3642,9 +3663,11 @@ begin
Changed;
end;
procedure TIDEBreakPoint.DoHit (const ACount: Integer; var AContinue: Boolean );
procedure TIDEBreakPoint.DoHit(const ACount: Integer; var AContinue: Boolean );
begin
inherited DoHit(ACount, AContinue);
if bpaLogMessage in Actions
then FMaster.DoLogMessage(FLogMessage);
if bpaEnableGroup in Actions
then EnableGroups;
if bpaDisableGroup in Actions
@ -3713,6 +3736,7 @@ begin
InitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
Enabled:=FInitialEnabled;
FLine:=XMLConfig.GetValue(Path+'Line/Value',-1);
FLogMessage:=XMLConfig.GetValue(Path+'LogMessage/Value','');
NewActions:=[];
for CurAction:=Low(TIDEBreakPointAction) to High(TIDEBreakPointAction) do
if XMLConfig.GetValue(
@ -3780,6 +3804,7 @@ begin
AConfig.SetDeleteValue(APath+'Source/Value',Filename,'');
AConfig.SetDeleteValue(APath+'InitialEnabled/Value',InitialEnabled,true);
AConfig.SetDeleteValue(APath+'Line/Value',Line,-1);
AConfig.SetDeleteValue(APath+'LogMessage/Value',LogMessage,'');
for CurAction := Low(TIDEBreakPointAction) to High(TIDEBreakPointAction) do
begin
@ -3889,6 +3914,8 @@ begin
if BreakHitcount > 0
then ACanContinue := cnt < BreakHitcount;
DoHit(cnt, ACanContinue);
if Assigned(FSlave)
then FSlave.DoHit(cnt, ACanContinue);
Debugger.DoBreakpointHit(Self, ACanContinue)
end;
@ -3914,6 +3941,11 @@ begin
end;
end;
procedure TDBGBreakPoint.DoLogMessage(const AMessage: String);
begin
Debugger.DoDbgEvent(ecBreakpoint, etBreakpointMessage, 'Breakpoint Message: ' + AMessage);
end;
function TDBGBreakPoint.GetDebugger: TDebugger;
begin
Result := TDBGBreakPoints(Collection).FDebugger;

View File

@ -4624,6 +4624,7 @@ resourcestring
lisBreak = 'Break';
lisEnableGroup = 'Enable Group';
lisDisableGroup = 'Disable Group';
lisLogMessage = 'Log Message';
lisAutoContinue = 'Auto Continue';
lisDisabled = 'Disabled';
lisInvalidOff = 'Invalid (Off)';
@ -4647,7 +4648,6 @@ resourcestring
lisMS = '(ms)';
lisActions = 'Actions:';
lisEvalExpression = 'Eval expression';
lisLogMessage = 'Log message';
// Debug Output Dialog
lisCopyAllOutputClipboard = 'Copy all output to clipboard';