Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Nodejs/Product/Nodejs/Debugger/DebugEngine/AD7Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public sealed class AD7Engine : IDebugEngine2, IDebugEngineLaunch2, IDebugProgra
private AD7Thread _mainThread;
private bool _sdmAttached;
private bool _processLoaded;
private bool _processLoadedRunning;
private bool _loadComplete;
private readonly object _syncLock = new object();
private bool _attached;
Expand Down Expand Up @@ -255,7 +254,7 @@ private void HandleLoadComplete() {
}

lock (_syncLock) {
if (_processLoadedRunning) {
if (_processLoaded && _process.IsRunning()) {
Send(new AD7LoadCompleteRunningEvent(), AD7LoadCompleteRunningEvent.IID, _mainThread);
} else {
Send(new AD7LoadCompleteEvent(), AD7LoadCompleteEvent.IID, _mainThread);
Expand Down Expand Up @@ -1125,10 +1124,9 @@ private void OnStepComplete(object sender, ThreadEventArgs e) {
Send(new AD7SteppingCompleteEvent(), AD7SteppingCompleteEvent.IID, _threads[e.Thread]);
}

private void OnProcessLoaded(object sender, ProcessLoadedEventArgs e) {
private void OnProcessLoaded(object sender, ThreadEventArgs e) {
lock (_syncLock) {
_processLoaded = true;
_processLoadedRunning = e.Running;
HandleLoadComplete();
}
}
Expand All @@ -1138,7 +1136,6 @@ private void OnProcessExited(object sender, ProcessExitedEventArgs e) {
_processExitedEvent.Set();
lock (_syncLock) {
_processLoaded = false;
_processLoadedRunning = false;
Send(new AD7ProgramDestroyEvent((uint)e.ExitCode), AD7ProgramDestroyEvent.IID, null);
}
} catch (InvalidOperationException) {
Expand All @@ -1152,6 +1149,7 @@ private void OnModuleLoaded(object sender, ModuleLoadedEventArgs e) {
if (_loadComplete) {
SendModuleLoad(adModule);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this line for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes it easier to read between the lines. I'll remove it 😃

}
}

Expand Down
25 changes: 16 additions & 9 deletions Nodejs/Product/Nodejs/Debugger/NodeDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,16 @@ public async Task BreakAllAsync() {
if (asyncBreakComplete != null) {
asyncBreakComplete(this, new ThreadEventArgs(MainThread));
}
}

}

internal bool IsRunning() {
var backtraceCommand = new BacktraceCommand(CommandId, _resultFactory, 0, 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are 0 & 1? Can we use named args to make the code clearer?

if (TrySendRequestAsync(backtraceCommand).GetAwaiter().GetResult()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some of the below commands have a timeout set. Is there potential this will block? For how long? Is there a chance this will be on the UI thread?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the same code as before, and I wasn't sure why it didn't have the timeout set before, so I just left it as is. I can add a timeout, though.

return backtraceCommand.Running;
}
return false;
}

private void DebugWriteCommand(string commandName) {
LiveLogger.WriteLine("NodeDebugger Called " + commandName);
}
Expand Down Expand Up @@ -492,18 +500,17 @@ public void StartListening() {
if (!backTraceTask.Wait((int)_timeout.TotalMilliseconds)) {
throw new TimeoutException("Timed out while performing initial backtrace.");
}
bool running = backTraceTask.GetAwaiter().GetResult();

// At this point we can fire events
EventHandler<ThreadEventArgs> newThread = ThreadCreated;
if (newThread != null) {
newThread(this, new ThreadEventArgs(mainThread));
}

EventHandler<ProcessLoadedEventArgs> procLoaded = ProcessLoaded;
}
EventHandler<ThreadEventArgs> procLoaded = ProcessLoaded;
if (procLoaded != null) {
procLoaded(this, new ProcessLoadedEventArgs(mainThread, running));
}
procLoaded(this, new ThreadEventArgs(MainThread));
}

}

private void OnConnectionClosed(object sender, EventArgs args) {
Expand Down Expand Up @@ -1170,7 +1177,7 @@ internal async Task<NodeEvaluationResult> SetVariableValueAsync(
/// <summary>
/// Fired when the process has started and is broken into the debugger, but before any user code is run.
/// </summary>
public event EventHandler<ProcessLoadedEventArgs> ProcessLoaded;
public event EventHandler<ThreadEventArgs> ProcessLoaded;

public event EventHandler<ThreadEventArgs> ThreadCreated;
public event EventHandler<ThreadEventArgs> ThreadExited;
Expand Down
33 changes: 0 additions & 33 deletions Nodejs/Product/Nodejs/Debugger/ProcessLoadedEventArgs.cs

This file was deleted.

1 change: 0 additions & 1 deletion Nodejs/Product/Nodejs/Nodejs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@
<Compile Include="Debugger\Extensions.cs" />
<Compile Include="Debugger\ModuleLoadedEventArgs.cs" />
<Compile Include="Debugger\OutputEventArgs.cs" />
<Compile Include="Debugger\ProcessLoadedEventArgs.cs" />
<Compile Include="Debugger\ProcessExitedEventArgs.cs" />
<Compile Include="Debugger\NodeBreakpoint.cs" />
<Compile Include="Debugger\NodeBreakpointBinding.cs" />
Expand Down