Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/DukDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ export class DukDebugSession extends DebugSession {
this.logToClient(`Protocol ID: ${version.id}\n`);

if (version.major === 2 || (version.major === 1 && version.minor >= 5)) {
if (this._args.sourceMaps) {
this._sourceMaps = new SourceMaps(this._outDir);
}
this.initDukDbgProtocol(conn, buf);
this.finalizeInit(response);
} else {
Expand All @@ -550,10 +553,6 @@ export class DukDebugSession extends DebugSession {
private finalizeInit(response: DebugProtocol.Response): void {
this.dbgLog("Finalized Initialization.");

if (this._args.sourceMaps) {
this._sourceMaps = new SourceMaps(this._outDir);
}

// Make sure that any breakpoints that were left set in
// case of a broken connection are cleared
this.removeAllTargetBreakpoints()
Expand Down Expand Up @@ -2065,7 +2064,7 @@ export class DukDebugSession extends DebugSession {
private unmapSourceFile(path: string): SourceFile {
this.dbgLog(`[unmapSourceFile] Unmapping file: ${path}`);
path = Path.normalize(path);
let name = Path.basename(path);
let name = this.normPath(Path.basename(path));

// Grab the relative path under the source root if this is located there,
// or just keep the full path if it's not
Expand Down
18 changes: 12 additions & 6 deletions src/sourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,15 @@ export class SourceMap {
* Any url schemes are removed.
*/
private absolutePath(path: string): string {
const prefix = "file://";
if (!util.isAbsolute(path)) {
let candidatePath = util.join(this._sourcemapLocation, path);
if (candidatePath.indexOf(prefix) === 0) {
candidatePath = candidatePath.substr(prefix.length);
if (/^\/[a-zA-Z]\:\//.test(candidatePath)) {
candidatePath = candidatePath.substr(1);
}
}
if (FS.existsSync(candidatePath)) {
path = candidatePath;
} else {
Expand All @@ -463,13 +470,17 @@ export class SourceMap {
}
}
}
const prefix = "file://";
if (path.indexOf(prefix) === 0) {
path = path.substr(prefix.length);
if (/^\/[a-zA-Z]\:\//.test(path)) {
path = path.substr(1);
}
}
// on Windows change forward slashes back to back slashes
if (process.platform === "win32") {
// path = path.replace(/\//g, "\\");
path = path.replace(/\\/g, "/");
}
return path;
}

Expand Down Expand Up @@ -498,11 +509,6 @@ export class SourceMap {

// map result back to absolute path
mp.source = this.absolutePath(mp.source);

// on Windows change forward slashes back to back slashes
if (process.platform === "win32") {
mp.source = mp.source.replace(/\//g, "\\");
}
}

return mp;
Expand Down