提交 b2b465bb 编写于 作者: I isidor

debug: add a process to model as soon as created

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