mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
improved error DA error reporting; fixes #87196
This commit is contained in:
@@ -337,7 +337,7 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
}
|
||||
|
||||
// make sure that only one factory for this type is registered
|
||||
if (this.getAdapterFactoryByType(type)) {
|
||||
if (this.getAdapterDescriptorFactoryByType(type)) {
|
||||
throw new Error(`a DebugAdapterDescriptorFactory can only be registered once per a type.`);
|
||||
}
|
||||
|
||||
@@ -412,89 +412,92 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
|
||||
const session = await this.getSession(sessionDto);
|
||||
|
||||
return this.getAdapterDescriptor(this.getAdapterFactoryByType(session.type), session).then(daDescriptor => {
|
||||
return this.getAdapterDescriptor(this.getAdapterDescriptorFactoryByType(session.type), session).then(daDescriptor => {
|
||||
|
||||
const adapter = this.convertToDto(daDescriptor);
|
||||
if (!daDescriptor) {
|
||||
throw new Error(`Couldn't find a debug adapter descriptor for debug type '${session.type}' (extension might have failed to activate)`);
|
||||
}
|
||||
|
||||
const da: AbstractDebugAdapter | undefined = this.createDebugAdapter(adapter, session);
|
||||
const adapterDescriptor = this.convertToDto(daDescriptor);
|
||||
|
||||
const da = this.createDebugAdapter(adapterDescriptor, session);
|
||||
if (!da) {
|
||||
throw new Error(`Couldn't create a debug adapter for type '${session.type}'.`);
|
||||
}
|
||||
|
||||
const debugAdapter = da;
|
||||
|
||||
if (debugAdapter) {
|
||||
this._debugAdapters.set(debugAdapterHandle, debugAdapter);
|
||||
this._debugAdapters.set(debugAdapterHandle, debugAdapter);
|
||||
|
||||
return this.getDebugAdapterTrackers(session).then(tracker => {
|
||||
return this.getDebugAdapterTrackers(session).then(tracker => {
|
||||
|
||||
if (tracker) {
|
||||
this._debugAdaptersTrackers.set(debugAdapterHandle, tracker);
|
||||
}
|
||||
if (tracker) {
|
||||
this._debugAdaptersTrackers.set(debugAdapterHandle, tracker);
|
||||
}
|
||||
|
||||
debugAdapter.onMessage(async message => {
|
||||
debugAdapter.onMessage(async message => {
|
||||
|
||||
if (message.type === 'request' && (<DebugProtocol.Request>message).command === 'handshake') {
|
||||
if (message.type === 'request' && (<DebugProtocol.Request>message).command === 'handshake') {
|
||||
|
||||
const request = <DebugProtocol.Request>message;
|
||||
const request = <DebugProtocol.Request>message;
|
||||
|
||||
const response: DebugProtocol.Response = {
|
||||
type: 'response',
|
||||
seq: 0,
|
||||
command: request.command,
|
||||
request_seq: request.seq,
|
||||
success: true
|
||||
};
|
||||
const response: DebugProtocol.Response = {
|
||||
type: 'response',
|
||||
seq: 0,
|
||||
command: request.command,
|
||||
request_seq: request.seq,
|
||||
success: true
|
||||
};
|
||||
|
||||
if (!this._signService) {
|
||||
this._signService = this.createSignService();
|
||||
}
|
||||
if (!this._signService) {
|
||||
this._signService = this.createSignService();
|
||||
}
|
||||
|
||||
try {
|
||||
if (this._signService) {
|
||||
const signature = await this._signService.sign(request.arguments.value);
|
||||
response.body = {
|
||||
signature: signature
|
||||
};
|
||||
debugAdapter.sendResponse(response);
|
||||
} else {
|
||||
throw new Error('no signer');
|
||||
}
|
||||
} catch (e) {
|
||||
response.success = false;
|
||||
response.message = e.message;
|
||||
try {
|
||||
if (this._signService) {
|
||||
const signature = await this._signService.sign(request.arguments.value);
|
||||
response.body = {
|
||||
signature: signature
|
||||
};
|
||||
debugAdapter.sendResponse(response);
|
||||
} else {
|
||||
throw new Error('no signer');
|
||||
}
|
||||
} else {
|
||||
if (tracker && tracker.onDidSendMessage) {
|
||||
tracker.onDidSendMessage(message);
|
||||
}
|
||||
|
||||
// DA -> VS Code
|
||||
message = convertToVSCPaths(message, true);
|
||||
|
||||
mythis._debugServiceProxy.$acceptDAMessage(debugAdapterHandle, message);
|
||||
} catch (e) {
|
||||
response.success = false;
|
||||
response.message = e.message;
|
||||
debugAdapter.sendResponse(response);
|
||||
}
|
||||
});
|
||||
debugAdapter.onError(err => {
|
||||
if (tracker && tracker.onError) {
|
||||
tracker.onError(err);
|
||||
} else {
|
||||
if (tracker && tracker.onDidSendMessage) {
|
||||
tracker.onDidSendMessage(message);
|
||||
}
|
||||
this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack);
|
||||
});
|
||||
debugAdapter.onExit((code: number | null) => {
|
||||
if (tracker && tracker.onExit) {
|
||||
tracker.onExit(withNullAsUndefined(code), undefined);
|
||||
}
|
||||
this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, withNullAsUndefined(code), undefined);
|
||||
});
|
||||
|
||||
if (tracker && tracker.onWillStartSession) {
|
||||
tracker.onWillStartSession();
|
||||
// DA -> VS Code
|
||||
message = convertToVSCPaths(message, true);
|
||||
|
||||
mythis._debugServiceProxy.$acceptDAMessage(debugAdapterHandle, message);
|
||||
}
|
||||
|
||||
return debugAdapter.startSession();
|
||||
});
|
||||
debugAdapter.onError(err => {
|
||||
if (tracker && tracker.onError) {
|
||||
tracker.onError(err);
|
||||
}
|
||||
this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack);
|
||||
});
|
||||
debugAdapter.onExit((code: number | null) => {
|
||||
if (tracker && tracker.onExit) {
|
||||
tracker.onExit(withNullAsUndefined(code), undefined);
|
||||
}
|
||||
this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, withNullAsUndefined(code), undefined);
|
||||
});
|
||||
|
||||
}
|
||||
return undefined;
|
||||
if (tracker && tracker.onWillStartSession) {
|
||||
tracker.onWillStartSession();
|
||||
}
|
||||
|
||||
return debugAdapter.startSession();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -663,13 +666,18 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
});
|
||||
}
|
||||
|
||||
public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
|
||||
const adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
|
||||
if (!adapterProvider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
public async $provideDebugAdapter(adapterFactoryHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
|
||||
const adapterDescriptorFactory = this.getAdapterDescriptorFactoryByHandle(adapterFactoryHandle);
|
||||
if (!adapterDescriptorFactory) {
|
||||
return Promise.reject(new Error('no adapter descriptor factory found for handle'));
|
||||
}
|
||||
const session = await this.getSession(sessionDto);
|
||||
return this.getAdapterDescriptor(adapterProvider, session).then(x => this.convertToDto(x));
|
||||
return this.getAdapterDescriptor(adapterDescriptorFactory, session).then(adapterDescriptor => {
|
||||
if (!adapterDescriptor) {
|
||||
throw new Error(`Couldn't find a debug adapter descriptor for debug type '${session.type}'`);
|
||||
}
|
||||
return this.convertToDto(adapterDescriptor);
|
||||
});
|
||||
}
|
||||
|
||||
public async $acceptDebugSessionStarted(sessionDto: IDebugSessionDto): Promise<void> {
|
||||
@@ -709,7 +717,7 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
|
||||
// private & dto helpers
|
||||
|
||||
private convertToDto(x: vscode.DebugAdapterDescriptor | undefined): IAdapterDescriptor {
|
||||
private convertToDto(x: vscode.DebugAdapterDescriptor): IAdapterDescriptor {
|
||||
|
||||
if (x instanceof DebugAdapterExecutable) {
|
||||
return <IDebugAdapterExecutable>{
|
||||
@@ -734,7 +742,7 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
}
|
||||
}
|
||||
|
||||
private getAdapterFactoryByType(type: string): vscode.DebugAdapterDescriptorFactory | undefined {
|
||||
private getAdapterDescriptorFactoryByType(type: string): vscode.DebugAdapterDescriptorFactory | undefined {
|
||||
const results = this._adapterFactories.filter(p => p.type === type);
|
||||
if (results.length > 0) {
|
||||
return results[0].factory;
|
||||
@@ -742,7 +750,7 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private getAdapterProviderByHandle(handle: number): vscode.DebugAdapterDescriptorFactory | undefined {
|
||||
private getAdapterDescriptorFactoryByHandle(handle: number): vscode.DebugAdapterDescriptorFactory | undefined {
|
||||
const results = this._adapterFactories.filter(p => p.handle === handle);
|
||||
if (results.length > 0) {
|
||||
return results[0].factory;
|
||||
@@ -804,7 +812,7 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
});
|
||||
}
|
||||
|
||||
private async getAdapterDescriptor(adapterProvider: vscode.DebugAdapterDescriptorFactory | undefined, session: ExtHostDebugSession): Promise<vscode.DebugAdapterDescriptor | undefined> {
|
||||
private async getAdapterDescriptor(adapterDescriptorFactory: vscode.DebugAdapterDescriptorFactory | undefined, session: ExtHostDebugSession): Promise<vscode.DebugAdapterDescriptor | undefined> {
|
||||
|
||||
// a "debugServer" attribute in the launch config takes precedence
|
||||
const serverPort = session.configuration.debugServer;
|
||||
@@ -824,9 +832,9 @@ export class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDeb
|
||||
});
|
||||
}
|
||||
|
||||
if (adapterProvider) {
|
||||
if (adapterDescriptorFactory) {
|
||||
const extensionRegistry = await this._extensionService.getExtensionRegistry();
|
||||
return asPromise(() => adapterProvider.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry))).then(daDescriptor => {
|
||||
return asPromise(() => adapterDescriptorFactory.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry))).then(daDescriptor => {
|
||||
if (daDescriptor) {
|
||||
return daDescriptor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user