src/debugAdapter/goDebug: add extra check for remote path inference
Add check for remote path inference to make sure that this will only get called for remote debugging case.
Updates golang/vscode-go#45
Updates golang/vscode-go#107
Change-Id: I7c4c2154013d8631c0b294b124b05eaddf1991f7
GitHub-Last-Rev: 552c40304504da57b08ff3affe5caa90ba5f9bd8
GitHub-Pull-Request: golang/vscode-go#147
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/236017
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts
index 09075ba..099f6a7 100644
--- a/src/debugAdapter/goDebug.ts
+++ b/src/debugAdapter/goDebug.ts
@@ -918,14 +918,10 @@
if (this.delve.remotePath.length === 0) {
if (this.delve.isRemoteDebugging) {
// The user trusts us to infer the remote path mapping!
- try {
- await this.initializeRemotePackagesAndSources();
- const matchedRemoteFile = this.inferRemotePathFromLocalPath(filePath);
- if (matchedRemoteFile) {
- return matchedRemoteFile;
- }
- } catch (error) {
- log(`Failing to initialize remote sources: ${error}`);
+ await this.initializeRemotePackagesAndSources();
+ const matchedRemoteFile = this.inferRemotePathFromLocalPath(filePath);
+ if (matchedRemoteFile) {
+ return matchedRemoteFile;
}
}
return this.convertClientPathToDebugger(filePath);
@@ -1228,7 +1224,9 @@
const locations = this.delve.isApiV1 ? <DebugLocation[]>out : (<StacktraceOut>out).Locations;
log('locations', locations);
- await this.initializeRemotePackagesAndSources();
+ if (this.delve.isRemoteDebugging) {
+ await this.initializeRemotePackagesAndSources();
+ }
let stackFrames = locations.map((location, frameId) => {
const uniqueStackFrameId = this.stackFrameHandles.create([goroutineId, frameId]);
@@ -1739,16 +1737,24 @@
}
if (!this.remoteSourcesAndPackages.initializingRemoteSourceFiles) {
- await this.remoteSourcesAndPackages.initializeRemotePackagesAndSources(this.delve);
+ try {
+ await this.remoteSourcesAndPackages.initializeRemotePackagesAndSources(this.delve);
+ } catch (error) {
+ log(`Failing to initialize remote sources: ${error}`);
+ }
return;
}
if (this.remoteSourcesAndPackages.initializingRemoteSourceFiles) {
- await new Promise((resolve) => {
- this.remoteSourcesAndPackages.on(RemoteSourcesAndPackages.INITIALIZED, () => {
- resolve();
+ try {
+ await new Promise((resolve) => {
+ this.remoteSourcesAndPackages.on(RemoteSourcesAndPackages.INITIALIZED, () => {
+ resolve();
+ });
});
- });
+ } catch (error) {
+ log(`Failing to initialize remote sources: ${error}`);
+ }
}
}
@@ -1871,7 +1877,9 @@
if (!debugState.currentThread || !debugState.currentThread.file) {
return Promise.resolve(null);
}
- await this.initializeRemotePackagesAndSources();
+ if (this.delve.isRemoteDebugging) {
+ await this.initializeRemotePackagesAndSources();
+ }
const dir = path.dirname(
this.delve.remotePath.length || this.delve.isRemoteDebugging
? this.toLocalPath(debugState.currentThread.file)