Skip to content

Commit 13118cd

Browse files
committed
Responding to debugger actions
1 parent a4a225a commit 13118cd

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

source/containers/Container.DataSet.Debugger.pas

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ TDebuggerDataSetContainer = class(TDataModule)
6262
FDebugSessionStopped: IDisconnectable;
6363
FSetupDebugger: IDisconnectable;
6464
FSetupDebuggerDone: IDisconnectable;
65+
FDebugAction: IDisconnectable;
6566
//Debugger events
6667
FContinuedEvent: IUnsubscribable;
6768
FExitedEvent: IUnsubscribable;
@@ -103,6 +104,8 @@ TDebuggerDataSetContainer = class(TDataModule)
103104
procedure AddBreakpoint(const ASourceName: string; const ALine: integer);
104105
procedure RemoveBreakpoint(const ASourceName: string; const ALine: integer);
105106
procedure ClearBreakpoints(const ASourceName: string);
107+
//Clear active source line and indicator values
108+
procedure ClearSourceLineAndIndicator();
106109
end;
107110

108111
var
@@ -153,6 +156,25 @@ procedure TDebuggerDataSetContainer.DataModuleCreate(Sender: TObject);
153156
begin
154157
SetupDebuggerDone(AEventNotification.Body.Debugger);
155158
end);
159+
160+
FDebugAction := TGlobalBuilderChain.SubscribeToEvent<TDebugActionEvent>(
161+
procedure(const AEventNotification: TDebugActionEvent)
162+
const
163+
DANGLE_INDICATOR_STATES = [
164+
TDebugAction.Stop,
165+
TDebugAction.StepIn,
166+
TDebugAction.StepOver,
167+
TDebugAction.StepOut,
168+
TDebugAction.Continue];
169+
begin
170+
if not (AEventNotification.Body.Action in DANGLE_INDICATOR_STATES) then
171+
Exit;
172+
173+
if fdmtActiveSource.IsEmpty then
174+
Exit;
175+
176+
ClearSourceLineAndIndicator();
177+
end);
156178
end;
157179

158180
procedure TDebuggerDataSetContainer.DataModuleDestroy(Sender: TObject);
@@ -238,14 +260,7 @@ procedure TDebuggerDataSetContainer.DebugSessionStarted(
238260
'Thread %d continued.', [
239261
AEventNotification.Body.ThreadId]));
240262

241-
System.Classes.TThread.Synchronize(System.Classes.TThread.Current,
242-
procedure()
243-
begin
244-
fdmtActiveSource.Edit();
245-
fdmtActiveSourceactive_source_line.AsInteger := 0;
246-
fdmtActiveSourceactive_source_line_indicator.AsBoolean := false;
247-
fdmtActiveSource.Post();
248-
end);
263+
ClearSourceLineAndIndicator();
249264
end);
250265

251266
FBreakpointEvent := ABaseProtocolClient.SubscribeToEvent<TBreakpointEvent>(
@@ -827,4 +842,16 @@ procedure TDebuggerDataSetContainer.ClearBreakpoints(const ASourceName: string);
827842
end);
828843
end;
829844

845+
procedure TDebuggerDataSetContainer.ClearSourceLineAndIndicator;
846+
begin
847+
System.Classes.TThread.Synchronize(System.Classes.TThread.Current,
848+
procedure()
849+
begin
850+
fdmtActiveSource.Edit();
851+
fdmtActiveSourceactive_source_line.AsInteger := 0;
852+
fdmtActiveSourceactive_source_line_indicator.AsBoolean := false;
853+
fdmtActiveSource.Post();
854+
end);
855+
end;
856+
830857
end.

0 commit comments

Comments
 (0)