提交 b2b465bb 编写于 作者: I isidor

debug: add a process to model as soon as created

上级 b3592d3a
......@@ -31,7 +31,7 @@ export const DEBUG_SCHEME = 'debug';
export interface IRawModelUpdate {
threadId: number;
rawSession: ISession & ITreeElement;
sessionId: string;
thread?: DebugProtocol.Thread;
callStack?: DebugProtocol.StackFrame[];
stoppedDetails?: IRawStoppedDetails;
......
......@@ -644,6 +644,10 @@ export class Model implements debug.IModel {
return this.processes;
}
public addProcess(session: debug.ISession & debug.ITreeElement): void {
this.processes.push(new Process(session));
}
public removeProcess(id: string): void {
this.processes = this.processes.filter(p => p.getId() !== id);
this._onDidChangeCallStack.fire();
......@@ -666,18 +670,15 @@ export class Model implements debug.IModel {
}
public rawUpdate(data: debug.IRawModelUpdate): void {
let process = this.processes.filter(p => p.getId() === data.rawSession.getId()).pop();
if (!process) {
process = new Process(data.rawSession);
this.processes.push(process);
let process = this.processes.filter(p => p.getId() === data.sessionId).pop();
if (process) {
process.rawUpdate(data);
this._onDidChangeCallStack.fire();
}
process.rawUpdate(data);
this._onDidChangeCallStack.fire();
}
public clearThreads(processId: string, removeThreads: boolean, reference: number = undefined): void {
const process = this.processes.filter(p => p.getId() === processId).pop();
public clearThreads(id: string, removeThreads: boolean, reference: number = undefined): void {
const process = this.processes.filter(p => p.getId() === id).pop();
if (process) {
process.clearThreads(removeThreads, reference);
this._onDidChangeCallStack.fire();
......
......@@ -260,7 +260,7 @@ export class DebugService implements debug.IDebugService {
this.getThreadData(session).done(() => {
this.model.rawUpdate({
rawSession: session,
sessionId: session.getId(),
threadId,
stoppedDetails: event.body,
allThreadsStopped: event.body.allThreadsStopped
......@@ -351,7 +351,7 @@ export class DebugService implements debug.IDebugService {
private getThreadData(session: RawDebugSession): TPromise<void> {
return session.threads().then(response => {
if (response && response.body && response.body.threads) {
response.body.threads.forEach(thread => this.model.rawUpdate({ rawSession: session, threadId: thread.id, thread }));
response.body.threads.forEach(thread => this.model.rawUpdate({ sessionId: session.getId(), threadId: thread.id, thread }));
}
});
}
......@@ -605,6 +605,7 @@ export class DebugService implements debug.IDebugService {
}
const session = this.instantiationService.createInstance(RawDebugSession, configuration.debugServer, this.configurationManager.adapter, this.customTelemetryService);
this.model.addProcess(session);
this.toDisposeOnSessionEnd[session.getId()] = [];
if (client) {
this.toDisposeOnSessionEnd[session.getId()].push(client);
......
......@@ -81,8 +81,9 @@ suite('Debug - Model', () => {
var threadId = 1;
var threadName = 'firstThread';
model.addProcess(rawSession);
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: threadId,
thread: {
id: threadId,
......@@ -107,8 +108,9 @@ suite('Debug - Model', () => {
const stoppedReason = 'breakpoint';
// Add the threads
model.addProcess(rawSession);
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: threadId1,
thread: {
id: threadId1,
......@@ -117,7 +119,7 @@ suite('Debug - Model', () => {
});
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: threadId2,
thread: {
id: threadId2,
......@@ -127,7 +129,7 @@ suite('Debug - Model', () => {
// Stopped event with all threads stopped
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: threadId1,
stoppedDetails: {
reason: stoppedReason,
......@@ -196,10 +198,10 @@ suite('Debug - Model', () => {
const runningThreadId = 2;
const runningThreadName = 'runningThread';
const stoppedReason = 'breakpoint';
model.addProcess(rawSession);
// Add the threads
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: stoppedThreadId,
thread: {
id: stoppedThreadId,
......@@ -208,7 +210,7 @@ suite('Debug - Model', () => {
});
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: runningThreadId,
thread: {
id: runningThreadId,
......@@ -218,7 +220,7 @@ suite('Debug - Model', () => {
// Stopped event with only one thread stopped
model.rawUpdate({
rawSession,
sessionId: rawSession.getId(),
threadId: stoppedThreadId,
stoppedDetails: {
reason: stoppedReason,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册