From 47c208ecb0b969ea3de063d691d0e43b54b20677 Mon Sep 17 00:00:00 2001 From: Connor Peet <connor@peet.io> Date: Wed, 23 Jun 2021 11:13:26 -0700 Subject: [PATCH] feat: allow disabling sourcemap renames Fixes #1033 --- CHANGELOG.md | 2 +- OPTIONS.md | 24 ++++++++++++++++-------- src/build/generate-contributions.ts | 5 +++++ src/build/strings.ts | 2 ++ src/common/sourceMaps/renameProvider.ts | 14 +++++++++++++- src/configuration.ts | 7 +++++++ 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 520b1b797..63923adcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he ## Nightly -Nothing (yet) +- feat: allow disabling sourcemap renames ([#1033](https://github.com/microsoft/vscode-js-debug/issues/1033)) ## v1.58 (June 2021) diff --git a/OPTIONS.md b/OPTIONS.md index 6ef5ce2d1..181b27e3f 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -40,7 +40,8 @@ "webpack://?:*/*": "${workspaceFolder}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${workspaceFolder}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> <h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p> @@ -91,7 +92,8 @@ "webpack://?:*/*": "${workspaceFolder}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${workspaceFolder}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>stopOnEntry</h4><p>Automatically stop program after launch.</p> <h5>Default value:</h4><pre><code>false</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> @@ -135,7 +137,8 @@ "webpack://?:*/*": "${workspaceFolder}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${workspaceFolder}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> <h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p> @@ -181,7 +184,8 @@ "webpack://?:*/*": "${workspaceFolder}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${workspaceFolder}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> <h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p> @@ -224,7 +228,8 @@ "webpack://?:*/*": "${webRoot}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${webRoot}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> <h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p> @@ -269,7 +274,8 @@ "webpack://?:*/*": "${webRoot}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${webRoot}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>targetSelection</h4><p>Whether to attach to all targets that match the URL filter ("automatic") or ask to pick one ("pick").</p> <h5>Default value:</h4><pre><code>"automatic"</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> @@ -321,7 +327,8 @@ "webpack://?:*/*": "${webRoot}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${webRoot}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> <h5>Default value:</h4><pre><code>{}</pre></code><h4>trace</h4><p>Configures what diagnostic output is produced.</p> @@ -367,7 +374,8 @@ "webpack://?:*/*": "${webRoot}/*", "webpack:///([a-z]):/(.+)": "$1:/$2", "meteor://💻app/*": "${webRoot}/*" -}</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> +}</pre></code><h4>sourceMapRenames</h4><p>Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.</p> +<h5>Default value:</h4><pre><code>true</pre></code><h4>sourceMaps</h4><p>Use JavaScript source maps (if they exist).</p> <h5>Default value:</h4><pre><code>true</pre></code><h4>targetSelection</h4><p>Whether to attach to all targets that match the URL filter ("automatic") or ask to pick one ("pick").</p> <h5>Default value:</h4><pre><code>"automatic"</pre></code><h4>timeout</h4><p>Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.</p> <h5>Default value:</h4><pre><code>10000</pre></code><h4>timeouts</h4><p>Timeouts for several debugger operations.</p> diff --git a/src/build/generate-contributions.ts b/src/build/generate-contributions.ts index 3c4e66952..e32c22675 100644 --- a/src/build/generate-contributions.ts +++ b/src/build/generate-contributions.ts @@ -196,6 +196,11 @@ const baseConfigurationAttributes: ConfigurationAttributes<IBaseConfiguration> = description: refString('browser.sourceMaps.description'), default: true, }, + sourceMapRenames: { + type: 'boolean', + default: true, + description: refString('browser.sourceMapRenames.description'), + }, sourceMapPathOverrides: { type: 'object', description: refString('node.sourceMapPathOverrides.description'), diff --git a/src/build/strings.ts b/src/build/strings.ts index c75ad8a6b..89e0bdfc2 100644 --- a/src/build/strings.ts +++ b/src/build/strings.ts @@ -90,6 +90,8 @@ const strings = { 'browser.sourceMapPathOverrides.description': 'A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk. See README for details.', 'browser.sourceMaps.description': 'Use JavaScript source maps (if they exist).', + 'browser.sourceMapRenames.description': + 'Whether to use the "names" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.', 'browser.timeout.description': 'Retry for this number of milliseconds to connect to the browser. Default is 10000 ms.', 'browser.url.description': 'Will search for a tab with this exact url and attach to it, if found', diff --git a/src/common/sourceMaps/renameProvider.ts b/src/common/sourceMaps/renameProvider.ts index cec2a9784..895699fb9 100644 --- a/src/common/sourceMaps/renameProvider.ts +++ b/src/common/sourceMaps/renameProvider.ts @@ -5,6 +5,7 @@ import { inject, injectable } from 'inversify'; import { ISourceWithMap, Source, SourceFromMap } from '../../adapter/sources'; import { StackFrame } from '../../adapter/stackTrace'; +import { AnyLaunchConfiguration } from '../../configuration'; import { Base01Position, IPosition } from '../positions'; import { PositionToOffset } from '../stringUtils'; import { SourceMap } from './sourceMap'; @@ -37,12 +38,19 @@ export const IRenameProvider = Symbol('IRenameProvider'); export class RenameProvider implements IRenameProvider { private renames = new Map</* source uri */ string, Promise<RenameMapping>>(); - constructor(@inject(ISourceMapFactory) private readonly sourceMapFactory: ISourceMapFactory) {} + constructor( + @inject(ISourceMapFactory) private readonly sourceMapFactory: ISourceMapFactory, + @inject(AnyLaunchConfiguration) private readonly launchConfig: AnyLaunchConfiguration, + ) {} /** * @inheritdoc */ public provideOnStackframe(frame: StackFrame) { + if (!this.launchConfig.sourceMapRenames) { + return RenameMapping.None; + } + const location = frame.uiLocation(); if (location === undefined) { return RenameMapping.None; @@ -57,6 +65,10 @@ export class RenameProvider implements IRenameProvider { * @inheritdoc */ public provideForSource(source: Source | undefined) { + if (!this.launchConfig.sourceMapRenames) { + return RenameMapping.None; + } + if (!(source instanceof SourceFromMap)) { return RenameMapping.None; } diff --git a/src/configuration.ts b/src/configuration.ts index 216adc677..3fce8991b 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -126,6 +126,12 @@ export interface IBaseConfiguration extends IMandatedConfiguration { */ sourceMaps: boolean; + /** + * Whether to use the "names" mapping in sourcemaps. This requires requesting + * source content, which can be slow with certain debuggers. + */ + sourceMapRenames: boolean; + /** * A set of mappings for rewriting the locations of source files from what * the sourcemap says, to their locations on disk. @@ -802,6 +808,7 @@ export const baseDefaults: IBaseConfiguration = { skipFiles: [], smartStep: true, sourceMaps: true, + sourceMapRenames: true, pauseForSourceMap: true, resolveSourceMapLocations: null, rootPath: '${workspaceFolder}',