@nimblesite/lsp-profiler-ui 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/out/src/bind-host.d.ts +3 -0
- package/out/src/bind-host.js +52 -0
- package/out/src/bind-host.js.map +1 -0
- package/out/src/context-keys.d.ts +4 -0
- package/out/src/context-keys.js +54 -0
- package/out/src/context-keys.js.map +1 -0
- package/out/src/dap-evaluate.d.ts +84 -0
- package/out/src/dap-evaluate.js +442 -0
- package/out/src/dap-evaluate.js.map +1 -0
- package/out/src/dap-output.d.ts +50 -0
- package/out/src/dap-output.js +177 -0
- package/out/src/dap-output.js.map +1 -0
- package/out/src/debug/adapter-resolution.d.ts +56 -0
- package/out/src/debug/adapter-resolution.js +112 -0
- package/out/src/debug/adapter-resolution.js.map +1 -0
- package/out/src/debug/dap-messages.d.ts +18 -0
- package/out/src/debug/dap-messages.js +71 -0
- package/out/src/debug/dap-messages.js.map +1 -0
- package/out/src/debug/index.d.ts +7 -0
- package/out/src/debug/index.js +27 -0
- package/out/src/debug/index.js.map +1 -0
- package/out/src/debug/launch-config.d.ts +42 -0
- package/out/src/debug/launch-config.js +73 -0
- package/out/src/debug/launch-config.js.map +1 -0
- package/out/src/debug/launch-lifecycle.d.ts +29 -0
- package/out/src/debug/launch-lifecycle.js +40 -0
- package/out/src/debug/launch-lifecycle.js.map +1 -0
- package/out/src/debug/poll.d.ts +25 -0
- package/out/src/debug/poll.js +70 -0
- package/out/src/debug/poll.js.map +1 -0
- package/out/src/debug/profiling.d.ts +34 -0
- package/out/src/debug/profiling.js +81 -0
- package/out/src/debug/profiling.js.map +1 -0
- package/out/src/debug/testing/assertions.d.ts +27 -0
- package/out/src/debug/testing/assertions.js +111 -0
- package/out/src/debug/testing/assertions.js.map +1 -0
- package/out/src/debug/testing/dap-client.d.ts +86 -0
- package/out/src/debug/testing/dap-client.js +204 -0
- package/out/src/debug/testing/dap-client.js.map +1 -0
- package/out/src/debug/testing/index.d.ts +7 -0
- package/out/src/debug/testing/index.js +31 -0
- package/out/src/debug/testing/index.js.map +1 -0
- package/out/src/debug/testing/vscode-harness.d.ts +44 -0
- package/out/src/debug/testing/vscode-harness.js +81 -0
- package/out/src/debug/testing/vscode-harness.js.map +1 -0
- package/out/src/debug/ui-stubs.d.ts +26 -0
- package/out/src/debug/ui-stubs.js +88 -0
- package/out/src/debug/ui-stubs.js.map +1 -0
- package/out/src/debug-link-setup.d.ts +4 -0
- package/out/src/debug-link-setup.js +19 -0
- package/out/src/debug-link-setup.js.map +1 -0
- package/out/src/debug-link-view.d.ts +4 -0
- package/out/src/debug-link-view.js +49 -0
- package/out/src/debug-link-view.js.map +1 -0
- package/out/src/debug-link.d.ts +6 -0
- package/out/src/debug-link.js +95 -0
- package/out/src/debug-link.js.map +1 -0
- package/out/src/debug-selection.d.ts +14 -0
- package/out/src/debug-selection.js +33 -0
- package/out/src/debug-selection.js.map +1 -0
- package/out/src/debuggee-pause.d.ts +11 -0
- package/out/src/debuggee-pause.js +109 -0
- package/out/src/debuggee-pause.js.map +1 -0
- package/out/src/editor-path-key.d.ts +52 -0
- package/out/src/editor-path-key.js +105 -0
- package/out/src/editor-path-key.js.map +1 -0
- package/out/src/failure.d.ts +5 -0
- package/out/src/failure.js +53 -0
- package/out/src/failure.js.map +1 -0
- package/out/src/file-log-sink.d.ts +20 -0
- package/out/src/file-log-sink.js +74 -0
- package/out/src/file-log-sink.js.map +1 -0
- package/out/src/flame-html.d.ts +8 -0
- package/out/src/flame-html.js +104 -0
- package/out/src/flame-html.js.map +1 -0
- package/out/src/flame-model.d.ts +93 -0
- package/out/src/flame-model.js +242 -0
- package/out/src/flame-model.js.map +1 -0
- package/out/src/flame-script-helpers.d.ts +26 -0
- package/out/src/flame-script-helpers.js +71 -0
- package/out/src/flame-script-helpers.js.map +1 -0
- package/out/src/flame-script.d.ts +1 -0
- package/out/src/flame-script.js +332 -0
- package/out/src/flame-script.js.map +1 -0
- package/out/src/flame-time-order.d.ts +14 -0
- package/out/src/flame-time-order.js +112 -0
- package/out/src/flame-time-order.js.map +1 -0
- package/out/src/flamegraph-artifact.d.ts +9 -0
- package/out/src/flamegraph-artifact.js +45 -0
- package/out/src/flamegraph-artifact.js.map +1 -0
- package/out/src/host.d.ts +31 -0
- package/out/src/host.js +6 -0
- package/out/src/host.js.map +1 -0
- package/out/src/ids.d.ts +27 -0
- package/out/src/ids.js +63 -0
- package/out/src/ids.js.map +1 -0
- package/out/src/index.d.ts +42 -0
- package/out/src/index.js +98 -0
- package/out/src/index.js.map +1 -0
- package/out/src/logger.d.ts +50 -0
- package/out/src/logger.js +86 -0
- package/out/src/logger.js.map +1 -0
- package/out/src/memory-autopilot.d.ts +64 -0
- package/out/src/memory-autopilot.js +306 -0
- package/out/src/memory-autopilot.js.map +1 -0
- package/out/src/memory-capture-ids.d.ts +17 -0
- package/out/src/memory-capture-ids.js +45 -0
- package/out/src/memory-capture-ids.js.map +1 -0
- package/out/src/memory-capture-ingest.d.ts +15 -0
- package/out/src/memory-capture-ingest.js +84 -0
- package/out/src/memory-capture-ingest.js.map +1 -0
- package/out/src/memory-capture-legs.d.ts +4 -0
- package/out/src/memory-capture-legs.js +55 -0
- package/out/src/memory-capture-legs.js.map +1 -0
- package/out/src/memory-capture-present.d.ts +32 -0
- package/out/src/memory-capture-present.js +71 -0
- package/out/src/memory-capture-present.js.map +1 -0
- package/out/src/memory-capture-roundtrip.d.ts +17 -0
- package/out/src/memory-capture-roundtrip.js +75 -0
- package/out/src/memory-capture-roundtrip.js.map +1 -0
- package/out/src/memory-capture-state.d.ts +23 -0
- package/out/src/memory-capture-state.js +89 -0
- package/out/src/memory-capture-state.js.map +1 -0
- package/out/src/memory-capture-types.d.ts +28 -0
- package/out/src/memory-capture-types.js +70 -0
- package/out/src/memory-capture-types.js.map +1 -0
- package/out/src/memory-capture.d.ts +24 -0
- package/out/src/memory-capture.js +51 -0
- package/out/src/memory-capture.js.map +1 -0
- package/out/src/memory-dashboard-html.d.ts +3 -0
- package/out/src/memory-dashboard-html.js +327 -0
- package/out/src/memory-dashboard-html.js.map +1 -0
- package/out/src/memory-dashboard-mapping.d.ts +34 -0
- package/out/src/memory-dashboard-mapping.js +135 -0
- package/out/src/memory-dashboard-mapping.js.map +1 -0
- package/out/src/memory-dashboard.d.ts +82 -0
- package/out/src/memory-dashboard.js +142 -0
- package/out/src/memory-dashboard.js.map +1 -0
- package/out/src/memory-decorations.d.ts +61 -0
- package/out/src/memory-decorations.js +247 -0
- package/out/src/memory-decorations.js.map +1 -0
- package/out/src/memory-finalize.d.ts +25 -0
- package/out/src/memory-finalize.js +207 -0
- package/out/src/memory-finalize.js.map +1 -0
- package/out/src/memory-guidance.d.ts +14 -0
- package/out/src/memory-guidance.js +36 -0
- package/out/src/memory-guidance.js.map +1 -0
- package/out/src/memory-inspect-commands.d.ts +20 -0
- package/out/src/memory-inspect-commands.js +114 -0
- package/out/src/memory-inspect-commands.js.map +1 -0
- package/out/src/memory-launch-direct.d.ts +12 -0
- package/out/src/memory-launch-direct.js +74 -0
- package/out/src/memory-launch-direct.js.map +1 -0
- package/out/src/memory-launch.d.ts +4 -0
- package/out/src/memory-launch.js +92 -0
- package/out/src/memory-launch.js.map +1 -0
- package/out/src/memory-leak-offer.d.ts +18 -0
- package/out/src/memory-leak-offer.js +51 -0
- package/out/src/memory-leak-offer.js.map +1 -0
- package/out/src/memory-profiler.d.ts +27 -0
- package/out/src/memory-profiler.js +71 -0
- package/out/src/memory-profiler.js.map +1 -0
- package/out/src/memory-ref-graph.d.ts +62 -0
- package/out/src/memory-ref-graph.js +248 -0
- package/out/src/memory-ref-graph.js.map +1 -0
- package/out/src/memory-ref-picker.d.ts +21 -0
- package/out/src/memory-ref-picker.js +103 -0
- package/out/src/memory-ref-picker.js.map +1 -0
- package/out/src/memory-registration.d.ts +4 -0
- package/out/src/memory-registration.js +63 -0
- package/out/src/memory-registration.js.map +1 -0
- package/out/src/memory-start-core.d.ts +8 -0
- package/out/src/memory-start-core.js +165 -0
- package/out/src/memory-start-core.js.map +1 -0
- package/out/src/memory-start-stop-commands.d.ts +10 -0
- package/out/src/memory-start-stop-commands.js +75 -0
- package/out/src/memory-start-stop-commands.js.map +1 -0
- package/out/src/memory-start.d.ts +6 -0
- package/out/src/memory-start.js +13 -0
- package/out/src/memory-start.js.map +1 -0
- package/out/src/memory-status.d.ts +24 -0
- package/out/src/memory-status.js +135 -0
- package/out/src/memory-status.js.map +1 -0
- package/out/src/palette-vscode.d.ts +2 -0
- package/out/src/palette-vscode.js +50 -0
- package/out/src/palette-vscode.js.map +1 -0
- package/out/src/palette.d.ts +70 -0
- package/out/src/palette.js +150 -0
- package/out/src/palette.js.map +1 -0
- package/out/src/process-bind-panel.d.ts +11 -0
- package/out/src/process-bind-panel.js +65 -0
- package/out/src/process-bind-panel.js.map +1 -0
- package/out/src/process-commands.d.ts +5 -0
- package/out/src/process-commands.js +112 -0
- package/out/src/process-commands.js.map +1 -0
- package/out/src/process-context-keys.d.ts +11 -0
- package/out/src/process-context-keys.js +48 -0
- package/out/src/process-context-keys.js.map +1 -0
- package/out/src/process-decoration.d.ts +18 -0
- package/out/src/process-decoration.js +76 -0
- package/out/src/process-decoration.js.map +1 -0
- package/out/src/process-explorer-rows.d.ts +59 -0
- package/out/src/process-explorer-rows.js +47 -0
- package/out/src/process-explorer-rows.js.map +1 -0
- package/out/src/process-explorer.d.ts +66 -0
- package/out/src/process-explorer.js +241 -0
- package/out/src/process-explorer.js.map +1 -0
- package/out/src/process-group-item.d.ts +8 -0
- package/out/src/process-group-item.js +55 -0
- package/out/src/process-group-item.js.map +1 -0
- package/out/src/process-launch-item.d.ts +12 -0
- package/out/src/process-launch-item.js +57 -0
- package/out/src/process-launch-item.js.map +1 -0
- package/out/src/process-launch.d.ts +47 -0
- package/out/src/process-launch.js +205 -0
- package/out/src/process-launch.js.map +1 -0
- package/out/src/process-message-item.d.ts +10 -0
- package/out/src/process-message-item.js +53 -0
- package/out/src/process-message-item.js.map +1 -0
- package/out/src/process-poll.d.ts +26 -0
- package/out/src/process-poll.js +125 -0
- package/out/src/process-poll.js.map +1 -0
- package/out/src/process-reactivity.d.ts +55 -0
- package/out/src/process-reactivity.js +188 -0
- package/out/src/process-reactivity.js.map +1 -0
- package/out/src/process-registration.d.ts +11 -0
- package/out/src/process-registration.js +55 -0
- package/out/src/process-registration.js.map +1 -0
- package/out/src/process-tree-item.d.ts +18 -0
- package/out/src/process-tree-item.js +219 -0
- package/out/src/process-tree-item.js.map +1 -0
- package/out/src/processes-state.d.ts +75 -0
- package/out/src/processes-state.js +76 -0
- package/out/src/processes-state.js.map +1 -0
- package/out/src/profile-on-launch.d.ts +4 -0
- package/out/src/profile-on-launch.js +16 -0
- package/out/src/profile-on-launch.js.map +1 -0
- package/out/src/profile-server.d.ts +24 -0
- package/out/src/profile-server.js +170 -0
- package/out/src/profile-server.js.map +1 -0
- package/out/src/profiler-attach.d.ts +19 -0
- package/out/src/profiler-attach.js +129 -0
- package/out/src/profiler-attach.js.map +1 -0
- package/out/src/profiler-commands.d.ts +8 -0
- package/out/src/profiler-commands.js +110 -0
- package/out/src/profiler-commands.js.map +1 -0
- package/out/src/profiler-decorations.d.ts +74 -0
- package/out/src/profiler-decorations.js +237 -0
- package/out/src/profiler-decorations.js.map +1 -0
- package/out/src/profiler-dispose.d.ts +6 -0
- package/out/src/profiler-dispose.js +20 -0
- package/out/src/profiler-dispose.js.map +1 -0
- package/out/src/profiler-flamegraph-html.d.ts +61 -0
- package/out/src/profiler-flamegraph-html.js +366 -0
- package/out/src/profiler-flamegraph-html.js.map +1 -0
- package/out/src/profiler-format.d.ts +10 -0
- package/out/src/profiler-format.js +28 -0
- package/out/src/profiler-format.js.map +1 -0
- package/out/src/profiler-launch-cooperative.d.ts +16 -0
- package/out/src/profiler-launch-cooperative.js +167 -0
- package/out/src/profiler-launch-cooperative.js.map +1 -0
- package/out/src/profiler-launch.d.ts +29 -0
- package/out/src/profiler-launch.js +123 -0
- package/out/src/profiler-launch.js.map +1 -0
- package/out/src/profiler-results.d.ts +22 -0
- package/out/src/profiler-results.js +104 -0
- package/out/src/profiler-results.js.map +1 -0
- package/out/src/profiler-session-core.d.ts +42 -0
- package/out/src/profiler-session-core.js +116 -0
- package/out/src/profiler-session-core.js.map +1 -0
- package/out/src/profiler-state.d.ts +87 -0
- package/out/src/profiler-state.js +83 -0
- package/out/src/profiler-state.js.map +1 -0
- package/out/src/profiler-status.d.ts +38 -0
- package/out/src/profiler-status.js +163 -0
- package/out/src/profiler-status.js.map +1 -0
- package/out/src/profiler-styles.d.ts +21 -0
- package/out/src/profiler-styles.js +160 -0
- package/out/src/profiler-styles.js.map +1 -0
- package/out/src/profiler-webview.d.ts +95 -0
- package/out/src/profiler-webview.js +243 -0
- package/out/src/profiler-webview.js.map +1 -0
- package/out/src/profiler.d.ts +23 -0
- package/out/src/profiler.js +113 -0
- package/out/src/profiler.js.map +1 -0
- package/out/src/progress-ops.d.ts +24 -0
- package/out/src/progress-ops.js +135 -0
- package/out/src/progress-ops.js.map +1 -0
- package/out/src/reactive-refresh.d.ts +24 -0
- package/out/src/reactive-refresh.js +33 -0
- package/out/src/reactive-refresh.js.map +1 -0
- package/out/src/sample-summary.d.ts +39 -0
- package/out/src/sample-summary.js +32 -0
- package/out/src/sample-summary.js.map +1 -0
- package/out/src/sampled-view.d.ts +15 -0
- package/out/src/sampled-view.js +56 -0
- package/out/src/sampled-view.js.map +1 -0
- package/out/src/server-command.d.ts +4 -0
- package/out/src/server-command.js +14 -0
- package/out/src/server-command.js.map +1 -0
- package/out/src/settings.d.ts +1 -0
- package/out/src/settings.js +22 -0
- package/out/src/settings.js.map +1 -0
- package/out/src/store.d.ts +34 -0
- package/out/src/store.js +64 -0
- package/out/src/store.js.map +1 -0
- package/out/src/testing/cpu-capture-assertions.d.ts +8 -0
- package/out/src/testing/cpu-capture-assertions.js +71 -0
- package/out/src/testing/cpu-capture-assertions.js.map +1 -0
- package/out/src/testing/cpu-capture-contract.d.ts +8 -0
- package/out/src/testing/cpu-capture-contract.js +123 -0
- package/out/src/testing/cpu-capture-contract.js.map +1 -0
- package/out/src/testing/webview-contract-helpers.d.ts +24 -0
- package/out/src/testing/webview-contract-helpers.js +125 -0
- package/out/src/testing/webview-contract-helpers.js.map +1 -0
- package/out/src/testing/webview-contract-leak.d.ts +2 -0
- package/out/src/testing/webview-contract-leak.js +80 -0
- package/out/src/testing/webview-contract-leak.js.map +1 -0
- package/out/src/testing/webview-contract-memory.d.ts +5 -0
- package/out/src/testing/webview-contract-memory.js +221 -0
- package/out/src/testing/webview-contract-memory.js.map +1 -0
- package/out/src/testing/webview-contract-palette.d.ts +6 -0
- package/out/src/testing/webview-contract-palette.js +121 -0
- package/out/src/testing/webview-contract-palette.js.map +1 -0
- package/out/src/testing/webview-contract-panel.d.ts +7 -0
- package/out/src/testing/webview-contract-panel.js +100 -0
- package/out/src/testing/webview-contract-panel.js.map +1 -0
- package/out/src/testing/webview-contract-results.d.ts +6 -0
- package/out/src/testing/webview-contract-results.js +136 -0
- package/out/src/testing/webview-contract-results.js.map +1 -0
- package/out/src/testing/webview-contract.d.ts +18 -0
- package/out/src/testing/webview-contract.js +23 -0
- package/out/src/testing/webview-contract.js.map +1 -0
- package/out/src/timeouts.d.ts +21 -0
- package/out/src/timeouts.js +30 -0
- package/out/src/timeouts.js.map +1 -0
- package/out/src/trace-actions.d.ts +33 -0
- package/out/src/trace-actions.js +135 -0
- package/out/src/trace-actions.js.map +1 -0
- package/out/src/unknown-shape.d.ts +58 -0
- package/out/src/unknown-shape.js +110 -0
- package/out/src/unknown-shape.js.map +1 -0
- package/out/src/wire-adapters.d.ts +18 -0
- package/out/src/wire-adapters.js +160 -0
- package/out/src/wire-adapters.js.map +1 -0
- package/out/src/wire-generated.d.ts +760 -0
- package/out/src/wire-generated.js +38 -0
- package/out/src/wire-generated.js.map +1 -0
- package/package.json +53 -4
- package/scripts/contributions.mjs +187 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nimblesite
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.bindHost = bindHost;
|
|
37
|
+
// Implements [PROF-UI-STATE]. Host binding for the profiler UI.
|
|
38
|
+
const vscode = __importStar(require("vscode"));
|
|
39
|
+
const palette_1 = require("./palette");
|
|
40
|
+
const ids_1 = require("./ids");
|
|
41
|
+
const logger_1 = require("./logger");
|
|
42
|
+
/** The host palette under the user's `profiler.palette` overrides, read on every render. */
|
|
43
|
+
function bindHostPalette(host) {
|
|
44
|
+
(0, palette_1.configurePalette)(() => (0, palette_1.resolvePalette)(host.palette ?? palette_1.DEFAULT_PALETTE, vscode.workspace.getConfiguration(host.configSection).get("profiler.palette")));
|
|
45
|
+
}
|
|
46
|
+
/** Install `host`'s ids, palette and logger for every module that reads them. */
|
|
47
|
+
function bindHost(host) {
|
|
48
|
+
(0, ids_1.installIds)(host);
|
|
49
|
+
bindHostPalette(host);
|
|
50
|
+
(0, logger_1.bindLogger)(() => host.logger);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=bind-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind-host.js","sourceRoot":"","sources":["../../src/bind-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAgE;AAChE,MAAY,MAAM,mCAAe;AACjC,uCAA8E;AAE9E,+BAAmC;AACnC,qCAAsC;AAEtC,4FAA4F;AAC5F,SAAS,eAAe,CAAC,IAAkB;IACzC,IAAA,0BAAgB,EAAC,GAAG,EAAE,CAAC,IAAA,wBAAc,EAAC,IAAI,CAAC,OAAO,IAAI,yBAAe,EACnE,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,iFAAiF;AACjF,kBAAyB,IAAkB;IACzC,IAAA,gBAAU,EAAC,IAAI,CAAC,CAAC;IACjB,eAAe,CAAC,IAAI,CAAC,CAAC;IACtB,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.setContextKey = setContextKey;
|
|
37
|
+
exports.contextKeyValues = contextKeyValues;
|
|
38
|
+
// Implements [PROF-UI-IDS] for context keys: every `setContext` the library
|
|
39
|
+
// performs goes through here, under the host's prefix, and the last value of
|
|
40
|
+
// each key is recorded so suites can prove the panel's `when` clauses see it.
|
|
41
|
+
const vscode = __importStar(require("vscode"));
|
|
42
|
+
const ids_1 = require("./ids");
|
|
43
|
+
const values = new Map();
|
|
44
|
+
/** Set `<prefix>.profiler.<name>` to `value`. */
|
|
45
|
+
function setContextKey(name, value) {
|
|
46
|
+
const key = (0, ids_1.ctx)(name);
|
|
47
|
+
values.set(key, value);
|
|
48
|
+
void vscode.commands.executeCommand("setContext", key, value);
|
|
49
|
+
}
|
|
50
|
+
/** The last value written per fully-qualified key (e2e seam). */
|
|
51
|
+
function contextKeyValues() {
|
|
52
|
+
return values;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=context-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-keys.js","sourceRoot":"","sources":["../../src/context-keys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,MAAY,MAAM,mCAAe;AACjC,+BAA4B;AAE5B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE1C,iDAAiD;AACjD,uBAA8B,IAAY,EAAE,KAAc;IACxD,MAAM,GAAG,GAAG,IAAA,SAAG,EAAC,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvB,KAAK,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,iEAAiE;AACjE;IACE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAP `evaluate` bridge for memory profiling.
|
|
3
|
+
*
|
|
4
|
+
* The LSP holds no DAP connection — the editor owns it — so memory profiling is
|
|
5
|
+
* a courier round-trip: the LSP hands us a Python injection script, we run it in
|
|
6
|
+
* the debuggee via DAP `evaluate`, and post the raw output back to the LSP
|
|
7
|
+
* (`<prefix>.lspProfiler.memory.ingest`). These are internal helpers, NOT registered
|
|
8
|
+
* commands: the LSP owns commands; the editor only shuttles bytes (CLAUDE.md
|
|
9
|
+
* command-ownership rule).
|
|
10
|
+
*
|
|
11
|
+
* debugpy can only `evaluate` against a *stopped* frame, so memory profiling
|
|
12
|
+
* requires the debuggee to be paused at a breakpoint — [`currentStoppedFrameId`]
|
|
13
|
+
* resolves that frame (or null when nothing is paused).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate a Python expression/statement in the active host debug session
|
|
17
|
+
* and return its textual output.
|
|
18
|
+
*
|
|
19
|
+
* Injection scripts `print()` their `__LSPPROF_MEM*__` marker payloads, and
|
|
20
|
+
* debugpy delivers that to DAP `output` events (the debuggee's stdout is
|
|
21
|
+
* redirected) — **not** in the `evaluate` response. So we snapshot the output
|
|
22
|
+
* cursor, run the evaluate, and then recover whatever the script printed (with
|
|
23
|
+
* a short wait, since the `output` event can land just after the response). The
|
|
24
|
+
* evaluate `result` is included too, in case an adapter does echo it. Returns
|
|
25
|
+
* null when there is no active host debug session or the request fails.
|
|
26
|
+
*/
|
|
27
|
+
export declare function evaluateInDebugSession(expression: string, frameId?: number, context?: "repl" | "watch" | "hover"): Promise<string | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a file-handoff payload. Large memory snapshots are written to a temp
|
|
30
|
+
* file by the injection script — which prints only `__LSPPROF_MEM_FILE__<path>`
|
|
31
|
+
* — because debugpy truncates a single `print()` at ~20 KB
|
|
32
|
+
* ([PROF-PY-MEMORY-COURIER]). When that marker is present, read the file (the
|
|
33
|
+
* real `__LSPPROF_MEM*__ + json` payload), delete it, and return its contents.
|
|
34
|
+
* Anything else (CPU acks, small OK markers) passes through untouched.
|
|
35
|
+
*
|
|
36
|
+
* The snapshot/diff scripts print the path while a debuggee worker thread is
|
|
37
|
+
* still rendering the payload (that render is seconds of pure Python on big
|
|
38
|
+
* heaps — running it inside the evaluate stalled the debugger past pydevd's
|
|
39
|
+
* 3 s budget, the original bug): the reserved file exists but is EMPTY until
|
|
40
|
+
* the worker atomically `os.replace`s the whole payload in. So an empty file
|
|
41
|
+
* means "still rendering" and is polled; any non-empty content is complete by
|
|
42
|
+
* construction. A missing file is still an immediate, honest failure.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveMarkerFilePayload(out: string): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a frameId for a currently-stopped thread, or null if nothing is
|
|
47
|
+
* paused. debugpy rejects `evaluate` without a stopped frame, so memory
|
|
48
|
+
* profiling requires the debuggee to be paused at a breakpoint.
|
|
49
|
+
*
|
|
50
|
+
* "Is anything paused?" cannot be probed with requests: debugpy answers
|
|
51
|
+
* `stackTrace` for a RUNNING thread with a sampled frame whose id is not
|
|
52
|
+
* evaluable (`evaluate` then fails with "Unable to find thread for
|
|
53
|
+
* evaluation"). So this gates on the tracker's `stopped`/`continued`
|
|
54
|
+
* bookkeeping (dap-output.ts) and only then asks for the top frame.
|
|
55
|
+
*/
|
|
56
|
+
export declare function currentStoppedFrameId(): Promise<number | null>;
|
|
57
|
+
/** A stopped, evaluable frame plus how to release it when the caller is done. */
|
|
58
|
+
export interface AcquiredFrame {
|
|
59
|
+
readonly frameId: number;
|
|
60
|
+
/** Resume the debuggee — only if acquiring paused it. */
|
|
61
|
+
readonly release: () => Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Acquire an evaluable stopped frame, transparently pausing the debuggee
|
|
65
|
+
* when it is running — IDE-grade memory snapshots must not demand a manual
|
|
66
|
+
* breakpoint ([PROF-UI-MEMORY]). When acquisition pauses the program,
|
|
67
|
+
* `release` resumes it; when the user was already stopped at a breakpoint,
|
|
68
|
+
* `release` is a no-op and their pause is preserved.
|
|
69
|
+
*
|
|
70
|
+
* A pause landing while the debuggee is still inside interpreter/debugger
|
|
71
|
+
* bootstrap (a launch is only milliseconds old) suspends it in frames
|
|
72
|
+
* `justMyCode` hides — `stackTrace` reports **zero frames**, and since the
|
|
73
|
+
* thread now sits parked there, it would stay unevaluable forever. So a
|
|
74
|
+
* transparent pause is a retry loop: pause, briefly wait for an evaluable
|
|
75
|
+
* frame, and when none appears resume and re-pause after a backoff — the
|
|
76
|
+
* program progresses into user code between attempts.
|
|
77
|
+
*/
|
|
78
|
+
export declare function acquireStoppedFrame(): Promise<AcquiredFrame | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Poll for a stopped frame until the startup budget runs out. Shared by the
|
|
81
|
+
* memory track-on-launch flow and the cooperative CPU sampler injection,
|
|
82
|
+
* both of which wait for the `stopOnEntry` pause before evaluating.
|
|
83
|
+
*/
|
|
84
|
+
export declare function waitForStoppedFrame(): Promise<number | null>;
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
3
|
+
/**
|
|
4
|
+
* DAP `evaluate` bridge for memory profiling.
|
|
5
|
+
*
|
|
6
|
+
* The LSP holds no DAP connection — the editor owns it — so memory profiling is
|
|
7
|
+
* a courier round-trip: the LSP hands us a Python injection script, we run it in
|
|
8
|
+
* the debuggee via DAP `evaluate`, and post the raw output back to the LSP
|
|
9
|
+
* (`<prefix>.lspProfiler.memory.ingest`). These are internal helpers, NOT registered
|
|
10
|
+
* commands: the LSP owns commands; the editor only shuttles bytes (CLAUDE.md
|
|
11
|
+
* command-ownership rule).
|
|
12
|
+
*
|
|
13
|
+
* debugpy can only `evaluate` against a *stopped* frame, so memory profiling
|
|
14
|
+
* requires the debuggee to be paused at a breakpoint — [`currentStoppedFrameId`]
|
|
15
|
+
* resolves that frame (or null when nothing is paused).
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.evaluateInDebugSession = evaluateInDebugSession;
|
|
52
|
+
exports.resolveMarkerFilePayload = resolveMarkerFilePayload;
|
|
53
|
+
exports.currentStoppedFrameId = currentStoppedFrameId;
|
|
54
|
+
exports.acquireStoppedFrame = acquireStoppedFrame;
|
|
55
|
+
exports.waitForStoppedFrame = waitForStoppedFrame;
|
|
56
|
+
const unknown_shape_1 = require("./unknown-shape");
|
|
57
|
+
const ids_1 = require("./ids");
|
|
58
|
+
const vscode = __importStar(require("vscode"));
|
|
59
|
+
const fs = __importStar(require("node:fs"));
|
|
60
|
+
const logger_1 = require("./logger");
|
|
61
|
+
const failure_1 = require("./failure");
|
|
62
|
+
const dap_output_1 = require("./dap-output");
|
|
63
|
+
const timeouts_1 = require("./timeouts");
|
|
64
|
+
/** Prefix shared by every injection-script output marker (`__LSPPROF_MEM*__`,
|
|
65
|
+
* `__LSPPROF_CPU_ACK__`). */
|
|
66
|
+
const MARKER_PREFIX = "__LSPPROF_";
|
|
67
|
+
/** Marker a memory script prints when it hands its (large) payload back via a
|
|
68
|
+
* temp file instead of stdout — see [PROF-PY-MEMORY-COURIER] and
|
|
69
|
+
* `scripts.rs::emit_via_file_helper`. The text after it is the file path. */
|
|
70
|
+
const FILE_PAYLOAD_MARKER = "__LSPPROF_MEM_FILE__";
|
|
71
|
+
/**
|
|
72
|
+
* How long to wait for a script's (possibly large, chunked) marker output.
|
|
73
|
+
*
|
|
74
|
+
* This budget is for DELIVERY, not for work: the evaluate has already returned,
|
|
75
|
+
* and we are waiting on the marker line to travel debuggee stdout -> debugpy ->
|
|
76
|
+
* adapter -> DAP `output` event -> extension host. The wait loop below returns
|
|
77
|
+
* the instant the line is complete, so a larger ceiling costs nothing when the
|
|
78
|
+
* pipeline is prompt — it only changes what happens when it is slow.
|
|
79
|
+
*
|
|
80
|
+
* The previous 4s was calibrated on a prompt machine, and on the win32 CI runner
|
|
81
|
+
* it expired mid-delivery: the wait then returned marker-LESS output, which the
|
|
82
|
+
* courier posted on to `<prefix>.lspProfiler.memory.ingest`, and the LSP rejected it with
|
|
83
|
+
* "no recognized __LSPPROF_MEM*__ marker in script output"
|
|
84
|
+
* (profiler/memory/session.rs). That reads as a broken injection script rather
|
|
85
|
+
* than as a wait that gave up, which is why the same test failed three different
|
|
86
|
+
* ways across consecutive runs ([PROF-TESTING]).
|
|
87
|
+
*
|
|
88
|
+
* 20s is a judgement, not a measurement — no per-platform delivery figure was
|
|
89
|
+
* taken. It is bounded from both sides: comfortably above the sibling
|
|
90
|
+
* `FILE_PAYLOAD_WAIT_MS` render budget's granularity, and small enough that even
|
|
91
|
+
* three fully-expired legs stay inside the courier round-trip's own 90s test
|
|
92
|
+
* budget. Nothing asserts how QUICKLY a marker arrives.
|
|
93
|
+
*/
|
|
94
|
+
const MARKER_WAIT_MS = 20_000;
|
|
95
|
+
/** Poll interval while waiting for marker output. */
|
|
96
|
+
const MARKER_POLL_MS = 25;
|
|
97
|
+
/** How long to wait for the debuggee's render worker to fill the payload file.
|
|
98
|
+
* The snapshot/diff evaluate returns as soon as the C-level capture is done
|
|
99
|
+
* (so it never stalls past pydevd's 3 s evaluation budget); the per-trace
|
|
100
|
+
* aggregation happens on a debuggee worker thread and can take a while on
|
|
101
|
+
* multi-million-trace heaps ([PROF-PY-MEMORY-COURIER]). */
|
|
102
|
+
const FILE_PAYLOAD_WAIT_MS = 60_000;
|
|
103
|
+
/** Poll interval while the payload file is still an empty reservation. */
|
|
104
|
+
const FILE_PAYLOAD_POLL_MS = 100;
|
|
105
|
+
/** Return the active host debug session, or undefined. */
|
|
106
|
+
function activeHostDebugSession() {
|
|
107
|
+
const session = vscode.debug.activeDebugSession;
|
|
108
|
+
return session?.type === (0, ids_1.debugType)() ? session : undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Evaluate a Python expression/statement in the active host debug session
|
|
112
|
+
* and return its textual output.
|
|
113
|
+
*
|
|
114
|
+
* Injection scripts `print()` their `__LSPPROF_MEM*__` marker payloads, and
|
|
115
|
+
* debugpy delivers that to DAP `output` events (the debuggee's stdout is
|
|
116
|
+
* redirected) — **not** in the `evaluate` response. So we snapshot the output
|
|
117
|
+
* cursor, run the evaluate, and then recover whatever the script printed (with
|
|
118
|
+
* a short wait, since the `output` event can land just after the response). The
|
|
119
|
+
* evaluate `result` is included too, in case an adapter does echo it. Returns
|
|
120
|
+
* null when there is no active host debug session or the request fails.
|
|
121
|
+
*/
|
|
122
|
+
async function evaluateInDebugSession(expression, frameId, context = "repl") {
|
|
123
|
+
const session = activeHostDebugSession();
|
|
124
|
+
if (session === undefined) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const cursor = (0, dap_output_1.debugOutputCursor)(session.id);
|
|
128
|
+
try {
|
|
129
|
+
const direct = (0, unknown_shape_1.stringField)(await session.customRequest("evaluate", { expression, context, ...(frameId === undefined ? {} : { frameId }) }), "result") ?? "";
|
|
130
|
+
return await resolveMarkerFilePayload(await recoverPrinted(session, cursor, direct));
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
logger_1.Logger.warn(`[Memory] evaluate failed: ${(0, failure_1.errorText)(error)}`);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** The direct evaluate result, or the printed marker output recovered after it. */
|
|
138
|
+
async function recoverPrinted(session, cursor, direct) {
|
|
139
|
+
if (direct.includes(MARKER_PREFIX)) {
|
|
140
|
+
return direct;
|
|
141
|
+
}
|
|
142
|
+
const printed = await waitForMarkerOutput(session.id, cursor);
|
|
143
|
+
return printed.length > 0 ? printed : direct;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Resolve a file-handoff payload. Large memory snapshots are written to a temp
|
|
147
|
+
* file by the injection script — which prints only `__LSPPROF_MEM_FILE__<path>`
|
|
148
|
+
* — because debugpy truncates a single `print()` at ~20 KB
|
|
149
|
+
* ([PROF-PY-MEMORY-COURIER]). When that marker is present, read the file (the
|
|
150
|
+
* real `__LSPPROF_MEM*__ + json` payload), delete it, and return its contents.
|
|
151
|
+
* Anything else (CPU acks, small OK markers) passes through untouched.
|
|
152
|
+
*
|
|
153
|
+
* The snapshot/diff scripts print the path while a debuggee worker thread is
|
|
154
|
+
* still rendering the payload (that render is seconds of pure Python on big
|
|
155
|
+
* heaps — running it inside the evaluate stalled the debugger past pydevd's
|
|
156
|
+
* 3 s budget, the original bug): the reserved file exists but is EMPTY until
|
|
157
|
+
* the worker atomically `os.replace`s the whole payload in. So an empty file
|
|
158
|
+
* means "still rendering" and is polled; any non-empty content is complete by
|
|
159
|
+
* construction. A missing file is still an immediate, honest failure.
|
|
160
|
+
*/
|
|
161
|
+
async function resolveMarkerFilePayload(out) {
|
|
162
|
+
const path = payloadFilePath(out);
|
|
163
|
+
return path === "" ? out : (await readPayloadFile(path)) ?? out;
|
|
164
|
+
}
|
|
165
|
+
/** The path after `__LSPPROF_MEM_FILE__`, or "" when the output hands off no file. */
|
|
166
|
+
function payloadFilePath(out) {
|
|
167
|
+
const at = out.indexOf(FILE_PAYLOAD_MARKER);
|
|
168
|
+
return at === -1 ? "" : out.slice(at + FILE_PAYLOAD_MARKER.length).split(/\r?\n/u, 1)[0]?.trim() ?? "";
|
|
169
|
+
}
|
|
170
|
+
/** The payload once the worker filled the file, which is then deleted; undefined when it is missing or stays empty. */
|
|
171
|
+
async function readPayloadFile(path) {
|
|
172
|
+
return readPayloadUntil(path, Date.now() + FILE_PAYLOAD_WAIT_MS);
|
|
173
|
+
}
|
|
174
|
+
/** Poll for the payload file until it holds data or `deadline` (epoch) passes. */
|
|
175
|
+
async function readPayloadUntil(path, deadline) {
|
|
176
|
+
const contents = await readPayloadContents(path);
|
|
177
|
+
if (contents === undefined) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
if (contents.length > 0 || Date.now() >= deadline) {
|
|
181
|
+
return finalizePayloadFile(path, contents);
|
|
182
|
+
}
|
|
183
|
+
await (0, timeouts_1.delay)(FILE_PAYLOAD_POLL_MS);
|
|
184
|
+
return readPayloadUntil(path, deadline);
|
|
185
|
+
}
|
|
186
|
+
/** Read the payload file, warning and returning undefined when it cannot be read. */
|
|
187
|
+
async function readPayloadContents(path) {
|
|
188
|
+
try {
|
|
189
|
+
return await fs.promises.readFile(path, "utf8");
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
logger_1.Logger.warn(`[Memory] could not read payload file: ${(0, failure_1.errorText)(error)}`);
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** Delete a settled payload file and return its non-empty contents, if any. */
|
|
197
|
+
async function finalizePayloadFile(path, contents) {
|
|
198
|
+
if (contents.length === 0) {
|
|
199
|
+
logger_1.Logger.warn(`[Memory] payload file stayed empty for ${String(FILE_PAYLOAD_WAIT_MS)}ms: ${path}`);
|
|
200
|
+
}
|
|
201
|
+
await removePayloadFile(path);
|
|
202
|
+
return contents.length > 0 ? contents : undefined;
|
|
203
|
+
}
|
|
204
|
+
/** Best-effort delete of a payload file; a missing file is already the outcome. */
|
|
205
|
+
async function removePayloadFile(path) {
|
|
206
|
+
try {
|
|
207
|
+
await fs.promises.unlink(path);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// The worker may have replaced or removed it; nothing to clean up.
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Wait for printed marker output to arrive via `output` events.
|
|
215
|
+
*
|
|
216
|
+
* The payload is a single `print()`ed line (`marker + json.dumps(...)` + `\n`)
|
|
217
|
+
* but debugpy can split it across several `output` events, so we wait until the
|
|
218
|
+
* marker line is **newline-terminated** — otherwise a large JSON snapshot is
|
|
219
|
+
* truncated mid-string. `json.dumps` (no indent) emits no embedded newlines, so
|
|
220
|
+
* the first `\n` after the marker reliably ends the payload.
|
|
221
|
+
*/
|
|
222
|
+
async function waitForMarkerOutput(sessionId, cursor) {
|
|
223
|
+
return waitForMarkerUntil(sessionId, cursor, Date.now() + MARKER_WAIT_MS);
|
|
224
|
+
}
|
|
225
|
+
/** Poll for marker output until its line is newline-terminated or `deadline` passes. */
|
|
226
|
+
async function waitForMarkerUntil(sessionId, cursor, deadline) {
|
|
227
|
+
const out = (0, dap_output_1.debugOutputSince)(sessionId, cursor);
|
|
228
|
+
const markerAt = out.indexOf(MARKER_PREFIX);
|
|
229
|
+
// The payload line is complete once a newline follows the marker (the
|
|
230
|
+
// `print()` terminator); `includes(.., markerAt)` searches from the marker.
|
|
231
|
+
if (markerAt !== -1 && out.includes("\n", markerAt)) {
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
if (Date.now() >= deadline) {
|
|
235
|
+
warnMarkerWaitExpired(out, markerAt);
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
await (0, timeouts_1.delay)(MARKER_POLL_MS);
|
|
239
|
+
return waitForMarkerUntil(sessionId, cursor, deadline);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Say WHY the wait gave up. Returning quietly hands marker-less (or truncated)
|
|
243
|
+
* output to the ingest leg, which rejects it as an unrecognised marker —
|
|
244
|
+
* blaming the injection script for a wait that ran out. This distinguishes the
|
|
245
|
+
* two cases the caller cannot: nothing arrived at all, versus a marker that
|
|
246
|
+
* arrived but never terminated.
|
|
247
|
+
*/
|
|
248
|
+
function warnMarkerWaitExpired(out, markerAt) {
|
|
249
|
+
logger_1.Logger.warn(markerAt === -1
|
|
250
|
+
? `[Memory] no marker in ${String(out.length)} bytes of debuggee output after ${String(MARKER_WAIT_MS)}ms`
|
|
251
|
+
: `[Memory] marker output still unterminated after ${String(MARKER_WAIT_MS)}ms (${String(out.length)} bytes) — payload likely truncated`);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Resolve a frameId for a currently-stopped thread, or null if nothing is
|
|
255
|
+
* paused. debugpy rejects `evaluate` without a stopped frame, so memory
|
|
256
|
+
* profiling requires the debuggee to be paused at a breakpoint.
|
|
257
|
+
*
|
|
258
|
+
* "Is anything paused?" cannot be probed with requests: debugpy answers
|
|
259
|
+
* `stackTrace` for a RUNNING thread with a sampled frame whose id is not
|
|
260
|
+
* evaluable (`evaluate` then fails with "Unable to find thread for
|
|
261
|
+
* evaluation"). So this gates on the tracker's `stopped`/`continued`
|
|
262
|
+
* bookkeeping (dap-output.ts) and only then asks for the top frame.
|
|
263
|
+
*/
|
|
264
|
+
async function currentStoppedFrameId() {
|
|
265
|
+
const session = activeHostDebugSession();
|
|
266
|
+
if (session === undefined) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
const stopped = (0, dap_output_1.stoppedThreadIds)(session.id);
|
|
270
|
+
if (stopped.length === 0) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
return stoppedFrameIdFor(session, stopped);
|
|
274
|
+
}
|
|
275
|
+
/** The top evaluable frame among `stopped` threads, else null. */
|
|
276
|
+
async function stoppedFrameIdFor(session, stopped) {
|
|
277
|
+
try {
|
|
278
|
+
const candidates = stopped.includes(dap_output_1.ALL_THREADS) ? await allThreadIds(session) : stopped;
|
|
279
|
+
return await firstTopFrameId(session, candidates);
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
logger_1.Logger.warn(`[Memory] could not resolve a stopped frame: ${(0, failure_1.errorText)(error)}`);
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/** The top frame of the first of `threadIds` that is stopped, else null. */
|
|
287
|
+
async function firstTopFrameId(session, threadIds) {
|
|
288
|
+
return firstTopFrameAt(session, threadIds, 0);
|
|
289
|
+
}
|
|
290
|
+
/** The top frame of `threadIds[index]` (or later) if stopped, else null. */
|
|
291
|
+
async function firstTopFrameAt(session, threadIds, index) {
|
|
292
|
+
const threadId = threadIds[index];
|
|
293
|
+
if (threadId === undefined) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
const frameId = await topFrameIdIfStopped(session, threadId);
|
|
297
|
+
return frameId ?? firstTopFrameAt(session, threadIds, index + 1);
|
|
298
|
+
}
|
|
299
|
+
/** Every thread id the debuggee reports (for `allThreadsStopped` stops). */
|
|
300
|
+
async function allThreadIds(session) {
|
|
301
|
+
const threads = await session.customRequest("threads");
|
|
302
|
+
return (0, unknown_shape_1.recordArrayField)(threads, "threads")
|
|
303
|
+
.map((thread) => (0, unknown_shape_1.numberField)(thread, "id"))
|
|
304
|
+
.filter((id) => id !== undefined);
|
|
305
|
+
}
|
|
306
|
+
/** Backoff between transparent-pause attempts, letting the debuggee progress
|
|
307
|
+
* out of interpreter/debugger bootstrap frames into user code. */
|
|
308
|
+
const PAUSE_RETRY_BACKOFF_MS = 150;
|
|
309
|
+
/**
|
|
310
|
+
* Acquire an evaluable stopped frame, transparently pausing the debuggee
|
|
311
|
+
* when it is running — IDE-grade memory snapshots must not demand a manual
|
|
312
|
+
* breakpoint ([PROF-UI-MEMORY]). When acquisition pauses the program,
|
|
313
|
+
* `release` resumes it; when the user was already stopped at a breakpoint,
|
|
314
|
+
* `release` is a no-op and their pause is preserved.
|
|
315
|
+
*
|
|
316
|
+
* A pause landing while the debuggee is still inside interpreter/debugger
|
|
317
|
+
* bootstrap (a launch is only milliseconds old) suspends it in frames
|
|
318
|
+
* `justMyCode` hides — `stackTrace` reports **zero frames**, and since the
|
|
319
|
+
* thread now sits parked there, it would stay unevaluable forever. So a
|
|
320
|
+
* transparent pause is a retry loop: pause, briefly wait for an evaluable
|
|
321
|
+
* frame, and when none appears resume and re-pause after a backoff — the
|
|
322
|
+
* program progresses into user code between attempts.
|
|
323
|
+
*/
|
|
324
|
+
async function acquireStoppedFrame() {
|
|
325
|
+
const session = activeHostDebugSession();
|
|
326
|
+
if (session === undefined) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
const existing = await currentStoppedFrameId();
|
|
330
|
+
// The user's own pause: nothing to release.
|
|
331
|
+
if (existing !== null) {
|
|
332
|
+
return { frameId: existing, release: async () => { await Promise.resolve(); } };
|
|
333
|
+
}
|
|
334
|
+
return pauseForFrame(session);
|
|
335
|
+
}
|
|
336
|
+
/** Pause the running debuggee until it stops in an evaluable frame, retrying from bootstrap frames. */
|
|
337
|
+
async function pauseForFrame(session) {
|
|
338
|
+
return pauseForFrameUntil(session, Date.now() + timeouts_1.STARTUP_TIMEOUT_MS, 1);
|
|
339
|
+
}
|
|
340
|
+
/** One transparent-pause attempt; recurses with the next attempt until `deadline` passes. */
|
|
341
|
+
async function pauseForFrameUntil(session, deadline, attempt) {
|
|
342
|
+
if (Date.now() >= deadline) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
if (!(await pauseDebuggee(session))) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
const acquired = await acquiredFrameOrResume(session, deadline, attempt);
|
|
349
|
+
if (acquired !== undefined) {
|
|
350
|
+
return acquired;
|
|
351
|
+
}
|
|
352
|
+
await (0, timeouts_1.delay)(PAUSE_RETRY_BACKOFF_MS);
|
|
353
|
+
return pauseForFrameUntil(session, deadline, attempt + 1);
|
|
354
|
+
}
|
|
355
|
+
/** An evaluable frame, or a resume-and-retry when the pause landed in bootstrap frames. */
|
|
356
|
+
async function acquiredFrameOrResume(session, deadline, attempt) {
|
|
357
|
+
const frameId = await waitForFrameUntil(Math.min(deadline, Date.now() + timeouts_1.WAIT_MS));
|
|
358
|
+
if (frameId !== null) {
|
|
359
|
+
logger_1.Logger.info(`[Memory] transparently paused the debuggee for evaluation (attempt ${String(attempt)})`);
|
|
360
|
+
return { frameId, release: async () => { await resumeDebuggee(session); } };
|
|
361
|
+
}
|
|
362
|
+
// Paused, but no evaluable frame (bootstrap / hidden frames): resume so
|
|
363
|
+
// the program can reach user code, then try again.
|
|
364
|
+
logger_1.Logger.info(`[Memory] pause landed in non-user frames (attempt ${String(attempt)}) — resuming to retry`);
|
|
365
|
+
await resumeDebuggee(session);
|
|
366
|
+
return undefined;
|
|
367
|
+
}
|
|
368
|
+
/** Poll for an evaluable stopped frame until `deadlineMs` (epoch), else null. */
|
|
369
|
+
async function waitForFrameUntil(deadlineMs) {
|
|
370
|
+
if (Date.now() >= deadlineMs) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
const frameId = await currentStoppedFrameId();
|
|
374
|
+
if (frameId !== null) {
|
|
375
|
+
return frameId;
|
|
376
|
+
}
|
|
377
|
+
await (0, timeouts_1.delay)(timeouts_1.POLL_INTERVAL_MS);
|
|
378
|
+
return waitForFrameUntil(deadlineMs);
|
|
379
|
+
}
|
|
380
|
+
/** Ask debugpy to pause the first reported thread. */
|
|
381
|
+
async function pauseDebuggee(session) {
|
|
382
|
+
try {
|
|
383
|
+
const ids = await allThreadIds(session);
|
|
384
|
+
if (ids.length === 0) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
await session.customRequest("pause", { threadId: ids[0] });
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
logger_1.Logger.warn(`[Memory] pause failed: ${(0, failure_1.errorText)(error)}`);
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/** Resume the first stopped (or reported) thread after a transparent pause. */
|
|
396
|
+
async function resumeDebuggee(session) {
|
|
397
|
+
try {
|
|
398
|
+
const threadId = await resumeThreadId(session);
|
|
399
|
+
if (threadId === undefined) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
await session.customRequest("continue", { threadId });
|
|
403
|
+
logger_1.Logger.info("[Memory] resumed the debuggee after evaluation");
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
logger_1.Logger.warn(`[Memory] resume failed: ${(0, failure_1.errorText)(error)}`);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/** The thread to resume: the first stopped one, else the first reported one. */
|
|
410
|
+
async function resumeThreadId(session) {
|
|
411
|
+
const stopped = (0, dap_output_1.stoppedThreadIds)(session.id).filter((id) => id !== dap_output_1.ALL_THREADS);
|
|
412
|
+
const firstStopped = stopped.at(0);
|
|
413
|
+
if (firstStopped !== undefined) {
|
|
414
|
+
return firstStopped;
|
|
415
|
+
}
|
|
416
|
+
const allIds = await allThreadIds(session);
|
|
417
|
+
return allIds.at(0);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Poll for a stopped frame until the startup budget runs out. Shared by the
|
|
421
|
+
* memory track-on-launch flow and the cooperative CPU sampler injection,
|
|
422
|
+
* both of which wait for the `stopOnEntry` pause before evaluating.
|
|
423
|
+
*/
|
|
424
|
+
async function waitForStoppedFrame() {
|
|
425
|
+
return waitForFrameUntil(Date.now() + timeouts_1.STARTUP_TIMEOUT_MS);
|
|
426
|
+
}
|
|
427
|
+
/** Top frameId of `threadId` if it is stopped, else null (running threads error). */
|
|
428
|
+
async function topFrameIdIfStopped(session, threadId) {
|
|
429
|
+
try {
|
|
430
|
+
const stack = await session.customRequest("stackTrace", {
|
|
431
|
+
threadId,
|
|
432
|
+
startFrame: 0,
|
|
433
|
+
levels: 1,
|
|
434
|
+
});
|
|
435
|
+
return (0, unknown_shape_1.numberField)((0, unknown_shape_1.recordArrayField)(stack, "stackFrames")[0], "id") ?? null;
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
// Thread not suspended.
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
//# sourceMappingURL=dap-evaluate.js.map
|