提交 7376e986 编写于 作者: I isidor

debug: process keep a reference to configuration

fixes #18669
上级 625e69b4
......@@ -102,6 +102,7 @@ export interface ISession {
export interface IProcess extends ITreeElement {
name: string;
configuration: IConfig;
session: ISession;
getThread(threadId: number): IThread;
getAllThreads(): IThread[];
......
......@@ -492,7 +492,7 @@ export class Process implements debug.IProcess {
private threads: Map<number, Thread>;
constructor(public name: string, private _session: debug.ISession & debug.ITreeElement) {
constructor(public configuration: debug.IConfig, private _session: debug.ISession & debug.ITreeElement) {
this.threads = new Map<number, Thread>();
}
......@@ -500,6 +500,10 @@ export class Process implements debug.IProcess {
return this._session;
}
public get name(): string {
return this.configuration.name;
}
public getThread(threadId: number): Thread {
return this.threads.get(threadId);
}
......@@ -693,8 +697,8 @@ export class Model implements debug.IModel {
return this.processes;
}
public addProcess(name: string, session: debug.ISession & debug.ITreeElement): Process {
const process = new Process(name, session);
public addProcess(configuration: debug.IConfig, session: debug.ISession & debug.ITreeElement): Process {
const process = new Process(configuration, session);
this.processes.push(process);
return process;
......
......@@ -665,7 +665,7 @@ export class DebugService implements debug.IDebugService {
}
const session = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, adapter, this.customTelemetryService);
const process = this.model.addProcess(configuration.name, session);
const process = this.model.addProcess(configuration, session);
if (!this.viewModel.focusedProcess) {
this.focusStackFrameAndEvaluate(null, process);
......@@ -825,13 +825,13 @@ export class DebugService implements debug.IDebugService {
return process.session.disconnect(true).then(() =>
new TPromise<void>((c, e) => {
setTimeout(() => {
this.createProcess(process.name).then(() => c(null), err => e(err));
this.createProcess(process.configuration).then(() => c(null), err => e(err));
}, 300);
})
).then(() => {
if (preserveFocus) {
// Restart should preserve the focused process
const restartedProcess = this.model.getProcesses().filter(p => p.name === process.name).pop();
const restartedProcess = this.model.getProcesses().filter(p => p.getId() === process.getId()).pop();
if (restartedProcess && restartedProcess !== this.viewModel.focusedProcess) {
this.focusStackFrameAndEvaluate(null, restartedProcess);
}
......
......@@ -23,7 +23,7 @@ suite('Debug - View Model', () => {
assert.equal(model.focusedStackFrame, null);
assert.equal(model.focusedThread, null);
const mockSession = new MockSession();
const process = new Process('mockProcess', mockSession);
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, mockSession);
const thread = new Thread(process, 'myThread', 1);
const frame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
model.setFocusedStackFrame(frame, process);
......
......@@ -94,7 +94,7 @@ suite('Debug - Model', () => {
const threadId = 1;
const threadName = 'firstThread';
model.addProcess('mockProcess', rawSession);
model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
assert.equal(model.getProcesses().length, 1);
model.rawUpdate({
sessionId: rawSession.getId(),
......@@ -125,7 +125,7 @@ suite('Debug - Model', () => {
const stoppedReason = 'breakpoint';
// Add the threads
model.addProcess('mockProcess', rawSession);
model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
model.rawUpdate({
sessionId: rawSession.getId(),
threadId: threadId1,
......@@ -215,7 +215,7 @@ suite('Debug - Model', () => {
const runningThreadId = 2;
const runningThreadName = 'runningThread';
const stoppedReason = 'breakpoint';
model.addProcess('mockProcess', rawSession);
model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
// Add the threads
model.rawUpdate({
sessionId: rawSession.getId(),
......@@ -308,7 +308,7 @@ suite('Debug - Model', () => {
test('watch expressions', () => {
assert.equal(model.getWatchExpressions().length, 0);
const process = new Process('mockProcess', rawSession);
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
const thread = new Thread(process, 'mockthread', 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
model.addWatchExpression(process, stackFrame, 'console').done();
......@@ -336,7 +336,7 @@ suite('Debug - Model', () => {
test('repl expressions', () => {
assert.equal(model.getReplElements().length, 0);
const process = new Process('mockProcess', rawSession);
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
const thread = new Thread(process, 'mockthread', 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
model.addReplExpression(process, stackFrame, 'myVariable').done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册