DBG:: implement log expression-eval in breakpoint

git-svn-id: trunk@32431 -
This commit is contained in:
martin 2011-09-19 23:19:19 +00:00
parent a1e0eec879
commit ce6ac1c77c
6 changed files with 43 additions and 5 deletions

View File

@ -173,7 +173,7 @@ end;
function GetBreakPointActionsDescription(ABreakpoint: TBaseBreakpoint): string;
const
DEBUG_ACTION: array[TIDEBreakPointAction] of ShortString =
(lisBreak, lisEnableGroups, lisDisableGroups, lisLogMessage, lisLogCallStack, lisTakeSnapshot);
(lisBreak, lisEnableGroups, lisDisableGroups, lisLogMessage, lisLogEvalExpression, lisLogCallStack, lisTakeSnapshot);
var
CurBreakPoint: TIDEBreakPoint;
Action: TIDEBreakPointAction;

View File

@ -281,7 +281,6 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Eval expression'
Enabled = False
TabOrder = 5
end
object chkLogMessage: TCheckBox
@ -314,7 +313,6 @@ inherited BreakPropertyDlg: TBreakPropertyDlg
BorderSpacing.Top = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Enabled = False
TabOrder = 6
end
object edtLogMessage: TEdit

View File

@ -160,11 +160,12 @@ begin
if chkActionBreak.Checked then Include(Actions, bpaStop);
if chkDisableGroups.Checked then Include(Actions, bpaDisableGroup);
if chkEnableGroups.Checked then Include(Actions, bpaEnableGroup);
// if chkEvalExpression.Checked then Include(Actions, bpaEValExpression);
if chkEvalExpression.Checked then Include(Actions, bpaEValExpression);
if chkLogMessage.Checked then Include(Actions, bpaLogMessage);
if chkLogCallStack.Checked then Include(Actions, bpaLogCallStack);
if chkTakeSnap.Checked then include(Actions, bpaTakeSnapshot);
FBreakpoint.Actions := Actions;
FBreakpoint.LogEvalExpression := edtEvalExpression.Text;
FBreakpoint.LogMessage := edtLogMessage.Text;
FBreakpoint.LogCallStackLimit := edtLogCallStack.Value;
@ -225,9 +226,10 @@ begin
chkActionBreak.Checked := bpaStop in Actions;
chkDisableGroups.Checked := bpaDisableGroup in Actions;
chkEnableGroups.Checked := bpaEnableGroup in Actions;
// chkEvalExpression.Checked := bpaEValExpression in Actions;
chkEvalExpression.Checked := bpaEValExpression in Actions;
chkLogMessage.Checked := bpaLogMessage in Actions;
edtLogMessage.Text := FBreakpoint.LogMessage;
edtEvalExpression.Text := FBreakpoint.LogEvalExpression;
chkLogCallStack.Checked := bpaLogCallStack in Actions;
edtLogCallStack.Value := FBreakpoint.LogCallStackLimit;
chkTakeSnap.Checked := bpaTakeSnapshot in Actions;

View File

@ -477,6 +477,7 @@ type
bpaEnableGroup,
bpaDisableGroup,
bpaLogMessage,
bpaEValExpression,
bpaLogCallStack,
bpaTakeSnapshot
);
@ -579,6 +580,7 @@ type
TIDEBreakPoint = class(TBaseBreakPoint)
private
FLogEvalExpression: String;
FMaster: TDBGBreakPoint;
FAutoContinueTime: Cardinal;
FActions: TIDEBreakPointActions;
@ -618,6 +620,7 @@ type
procedure SetActions(const AValue: TIDEBreakPointActions); virtual;
procedure SetGroup(const AValue: TIDEBreakPointGroup); virtual;
procedure SetAutoContinueTime(const AValue: Cardinal); virtual;
procedure SetLogEvalExpression(AValue: String);
procedure SetLogMessage(const AValue: String); virtual;
procedure SetLogCallStackLimit(const AValue: Integer);
public
@ -641,6 +644,7 @@ type
property Actions: TIDEBreakPointActions read GetActions write SetActions;
property AutoContinueTime: Cardinal read GetAutoContinueTime write SetAutoContinueTime;
property Group: TIDEBreakPointGroup read GetGroup write SetGroup;
property LogEvalExpression: String read FLogEvalExpression write SetLogEvalExpression;
property Loading: Boolean read FLoading;
property LogMessage: String read GetLogMessage write SetLogMessage;
property LogCallStackLimit: Integer read GetLogCallStackLimit write SetLogCallStackLimit;
@ -660,6 +664,7 @@ type
procedure DoStateChange(const AOldState: TDBGState); virtual;
procedure DoLogMessage(const AMessage: String); virtual;
procedure DoLogCallStack(const Limit: Integer); virtual;
procedure DoLogExpression(const AnExpression: String); virtual; // implemented in TGDBMIBreakpoint
property Debugger: TDebugger read GetDebugger;
public
constructor Create(ACollection: TCollection); override;
@ -2838,6 +2843,7 @@ const
'EnableGroup',
'DisableGroup',
'LogMessage',
'EvalExpression',
'LogCallStack',
'TakeSnapshot'
);
@ -6402,6 +6408,15 @@ begin
Changed;
end;
procedure TIDEBreakPoint.SetLogEvalExpression(AValue: String);
begin
if FLogEvalExpression <> AValue then
begin
FLogEvalExpression := AValue;
Changed;
end;
end;
procedure TIDEBreakPoint.SetLogMessage(const AValue: String);
begin
if FLogMessage <> AValue then
@ -6448,6 +6463,7 @@ begin
TIDEBreakPoint(Dest).Actions := FActions;
TIDEBreakPoint(Dest).AutoContinueTime := FAutoContinueTime;
TIDEBreakPoint(Dest).Group := FGroup;
TIDEBreakPoint(Dest).LogEvalExpression := FLogEvalExpression;
TIDEBreakPoint(Dest).LogMessage := FLogMessage;
TIDEBreakPoint(Dest).LogCallStackLimit := FLogCallStackLimit;
end;
@ -6590,6 +6606,8 @@ begin
AContinue := AContinue or not (bpaStop in Actions);
if bpaLogMessage in Actions
then FMaster.DoLogMessage(FLogMessage);
if (bpaEValExpression in Actions) and (Trim(FLogEvalExpression) <> '')
then FMaster.DoLogExpression(Trim(FLogEvalExpression));
if bpaLogCallStack in Actions
then FMaster.DoLogCallStack(FLogCallStackLimit);
// SnapShot is taken in TDebugManager.DebuggerChangeState
@ -6672,6 +6690,7 @@ begin
InitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
Enabled:=FInitialEnabled;
FLine:=XMLConfig.GetValue(Path+'Line/Value',-1);
FLogEvalExpression := XMLConfig.GetValue(Path+'LogEvalExpression/Value', '');
FLogMessage:=XMLConfig.GetValue(Path+'LogMessage/Value','');
FLogCallStackLimit:=XMLConfig.GetValue(Path+'LogCallStackLimit/Value',0);
NewActions:=[];
@ -6749,6 +6768,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+'LogEvalExpression/Value', FLogEvalExpression,'');
AConfig.SetDeleteValue(APath+'LogMessage/Value',LogMessage,'');
AConfig.SetDeleteValue(APath+'LogCallStackLimit/Value',LogCallStackLimit,0);
@ -6943,6 +6963,11 @@ begin
end;
end;
procedure TDBGBreakPoint.DoLogExpression(const AnExpression: String);
begin
// will be called while Debgger.State = dsRun => can not call Evaluate
end;
function TDBGBreakPoint.GetDebugger: TDebugger;
begin
Result := TDBGBreakPoints(Collection).FDebugger;

View File

@ -841,6 +841,7 @@ type
procedure DoEnableChange; override;
procedure DoExpressionChange; override;
procedure DoStateChange(const AOldState: TDBGState); override;
procedure DoLogExpression(const AnExpression: String); override;
procedure MakeInvalid;
procedure SetAddress(const AValue: TDBGPtr); override;
public
@ -7425,6 +7426,17 @@ begin
end;
end;
procedure TGDBMIBreakPoint.DoLogExpression(const AnExpression: String);
var
s: String;
t: TDBGType;
begin
if TGDBMIDebugger(Debugger).GDBEvaluate(AnExpression, s, t, [defNoTypeInfo])
then begin
Debugger.DoDbgEvent(ecBreakpoint, etBreakpointEvaluation, s);
end;
end;
procedure TGDBMIBreakPoint.MakeInvalid;
begin
BeginUpdate;

View File

@ -4648,6 +4648,7 @@ resourcestring
lisEnableGroups = 'Enable Groups';
lisDisableGroups = 'Disable Groups';
lisLogMessage = 'Log Message';
lisLogEvalExpression = 'Eval expression';
lisLogCallStack = 'Log Call Stack';
lisLogCallStackLimit = '(frames limit. 0 - no limits)';
lisAutoContinue = 'Auto Continue';