From 744eca48621c9395483b4cf5b7ee310848a11859 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Tue, 26 Jan 2021 22:24:11 +0100 Subject: [PATCH 1/9] UI for setting compiled funcs/mods --- package.json | 71 ++++++- scripts/packages/DebugAdapter | 2 +- .../packages/VSCodeServer/src/VSCodeServer.jl | 1 + scripts/packages/VSCodeServer/src/debugger.jl | 62 ++++++ .../VSCodeServer/src/repl_protocol.jl | 7 + src/debugger/debugProtocol.ts | 2 +- src/debugger/juliaDebug.ts | 3 +- src/interactive/debugConfig.ts | 187 ++++++++++++++++++ src/interactive/repl.ts | 10 +- 9 files changed, 339 insertions(+), 6 deletions(-) create mode 100644 src/interactive/debugConfig.ts diff --git a/package.json b/package.json index ea328cd52..e4c6f687e 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "embeddedLanguages": { "meta.embedded.inline.cpp": "cpp", "meta.embedded.inline.javascript": "javascript", - "meta.embedded.inline.markdown": "juliamarkdown", + "meta.embedded.inline.markdown": "markdown", "meta.embedded.inline.python": "python", "meta.embedded.inline.r": "r" } @@ -290,6 +290,35 @@ { "command": "language-julia.activateFromDir", "title": "Julia: Activate Parent Environment" + }, + { + "command": "language-julia.switchToInterpreted", + "title": "Interpret" + }, + { + "command": "language-julia.switchToCompiled", + "title": "Compile" + }, + { + "command": "language-julia.switchAllToInterpreted", + "title": "Switch all to interpreted" + }, + { + "command": "language-julia.switchAllToCompiled", + "title": "(all)" + }, + { + "command": "language-julia.apply-compiled-defaults", + "title": "Apply default compiled modules/functions" + }, + { + "command": "language-julia.reset-compiled", + "title": "Reset compiled modules/functions", + "icon": "$(close)" + }, + { + "command": "language-julia.refreshCompiled", + "title": "Julia: Refresh Compiled/Interpreted Pane" } ], "menus": { @@ -400,6 +429,21 @@ "command": "language-julia.showInVSCode", "when": "view == REPLVariables && viewItem == globalvariable", "group": "inline" + }, + { + "command": "language-julia.switchToInterpreted", + "when": "view == debugger-compiled && viewItem == is-compiled || viewItem == is-compiled-with-children", + "group": "inline@1" + }, + { + "command": "language-julia.switchToCompiled", + "when": "view == debugger-compiled && viewItem == is-interpreted || viewItem == is-interpreted-with-children", + "group": "inline@1" + }, + { + "command": "language-julia.switchAllToCompiled", + "when": "view == debugger-compiled && viewItem == is-interpreted-with-children", + "group": "inline@2" } ], "view/title": [ @@ -412,6 +456,16 @@ "command": "language-julia.browse-forward-documentation", "when": "view == julia-documentation", "group": "navigation" + }, + { + "command": "language-julia.apply-compiled-defaults", + "when": "view == debugger-compiled", + "group": "menu" + }, + { + "command": "language-julia.reset-compiled", + "when": "view == debugger-compiled", + "group": "menu" } ], "editor/context": [ @@ -807,6 +861,14 @@ "default": "test/runtests.jl", "description": "A workspace relative path to a Julia file that contains the tests that should be run for live testing.", "scope": "window" + }, + "julia.debuggerDefaultCompiled": { + "type": "array", + "default": [ + "Base.iterate" + ], + "description": "Functions or modules that are set to compiled mode when setting the defaults.", + "scope": "window" } } }, @@ -850,6 +912,13 @@ "id": "julia-documentation", "name": "Documentation" } + ], + "debug": [ + { + "type": "tree", + "id": "debugger-compiled", + "name": "Compiled/Interpreted Code" + } ] }, "breakpoints": [ diff --git a/scripts/packages/DebugAdapter b/scripts/packages/DebugAdapter index 544becfa4..9e335b2d6 160000 --- a/scripts/packages/DebugAdapter +++ b/scripts/packages/DebugAdapter @@ -1 +1 @@ -Subproject commit 544becfa41961c52d84a2e8ea495430c41c32d7c +Subproject commit 9e335b2d6a4da024fe61d1fd8bfd9b7f81e85c0f diff --git a/scripts/packages/VSCodeServer/src/VSCodeServer.jl b/scripts/packages/VSCodeServer/src/VSCodeServer.jl index a43a9692b..86b500e2b 100644 --- a/scripts/packages/VSCodeServer/src/VSCodeServer.jl +++ b/scripts/packages/VSCodeServer/src/VSCodeServer.jl @@ -101,6 +101,7 @@ function serve(args...; is_dev=false, crashreporting_pipename::Union{AbstractStr msg_dispatcher[repl_toggle_progress_notification_type] = toggle_progress msg_dispatcher[cd_notification_type] = cd_to_uri msg_dispatcher[activate_project_notification_type] = activate_uri + msg_dispatcher[repl_getdebugitems_request_type] = debugger_getdebugitems_request while true msg = JSONRPC.get_next_message(conn_endpoint[]) diff --git a/scripts/packages/VSCodeServer/src/debugger.jl b/scripts/packages/VSCodeServer/src/debugger.jl index 15db827b3..ec78e9caf 100644 --- a/scripts/packages/VSCodeServer/src/debugger.jl +++ b/scripts/packages/VSCodeServer/src/debugger.jl @@ -29,6 +29,68 @@ function remove_lln!(ex::Expr) end end +function debugger_getdebugitems_request(conn, params) + accessor = params.juliaAccessor + out = DebugConfigTreeItem[] + loaded_modules = Base.loaded_modules_array() + if accessor == "#root" + # root modules + for mod in loaded_modules + push!(out, DebugConfigTreeItem(string(mod), true, string(mod))) + end + else + obj = get_obj_by_accessor(accessor) + if obj isa Module + for name in names(obj; all = true) + isdefined(obj, name) || continue + strname = string(name) + startswith(strname, '#') && continue + this = getfield(obj, name) + this === obj && continue + + if this isa Base.Callable || this isa Module + push!(out, DebugConfigTreeItem(strname, this isa Module, string(accessor, ".", strname))) + end + end + end + end + return sort!(out, lt = (x, y) -> x.hasChildren == y.hasChildren ? x.label < y.label : x.hasChildren) +end + +function get_obj_by_accessor(accessor, super = nothing) + parts = split(accessor, '.') + @assert length(parts) > 0 + top = popfirst!(parts) + if super === nothing + # try getting module from loaded_modules_array first and then from Main: + loaded_modules = Base.loaded_modules_array() + ind = findfirst(==(top), string.(loaded_modules)) + if ind !== nothing + root = loaded_modules[ind] + if length(parts) > 0 + return get_obj_by_accessor(join(parts, '.'), root) + end + return root + else + return get_obj_by_accessor(accessor, Main) + end + else + for name in names(super; all = true) + if string(name) == top && isdefined(super, name) + this = getfield(super, name) + if length(parts) > 0 + if this isa Module + return get_obj_by_accessor(join(parts, '.'), this) + end + else + return this + end + end + end + end + return nothing +end + macro enter(command) remove_lln!(command) :(JSONRPC.send_notification(conn_endpoint[], "debugger/enter", (code = $(string(command)), filename = $(string(__source__.file))))) diff --git a/scripts/packages/VSCodeServer/src/repl_protocol.jl b/scripts/packages/VSCodeServer/src/repl_protocol.jl index 2f651e8dd..b856248ba 100644 --- a/scripts/packages/VSCodeServer/src/repl_protocol.jl +++ b/scripts/packages/VSCodeServer/src/repl_protocol.jl @@ -33,6 +33,12 @@ JSONRPC.@dict_readable mutable struct ReplWorkspaceItem <: JSONRPC.Outbound type::String end +JSONRPC.@dict_readable mutable struct DebugConfigTreeItem <: JSONRPC.Outbound + label::String + hasChildren::Bool + juliaAccessor::String +end + const repl_runcode_request_type = JSONRPC.RequestType("repl/runcode", ReplRunCodeRequestParams, ReplRunCodeRequestReturn) const repl_interrupt_notification_type = JSONRPC.NotificationType("repl/interrupt", Nothing) const repl_getvariables_request_type = JSONRPC.RequestType("repl/getvariables", Nothing, Vector{ReplWorkspaceItem}) @@ -47,3 +53,4 @@ const repl_toggle_plot_pane_notification_type = JSONRPC.NotificationType("repl/t const repl_toggle_progress_notification_type = JSONRPC.NotificationType("repl/toggleProgress", Bool) const cd_notification_type = JSONRPC.NotificationType("repl/cd", NamedTuple{(:uri,),Tuple{String}}) const activate_project_notification_type = JSONRPC.NotificationType("repl/activateProject", NamedTuple{(:uri,),Tuple{String}}) +const repl_getdebugitems_request_type = JSONRPC.RequestType("repl/getDebugItems", NamedTuple{(:juliaAccessor,),Tuple{String}}, Vector{DebugConfigTreeItem}) diff --git a/src/debugger/debugProtocol.ts b/src/debugger/debugProtocol.ts index ced3bc153..3dcbb8c56 100644 --- a/src/debugger/debugProtocol.ts +++ b/src/debugger/debugProtocol.ts @@ -202,6 +202,6 @@ export const requestTypeThreads = new RequestType0('breakpointLocations') export const notifyTypeRun = new NotificationType<{ program: string }>('run') export const notifyTypeDebug = new NotificationType<{ stopOnEntry: boolean, program: string }>('debug') -export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string }>('exec') +export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string, compiledModulesOrFunctions: string[] }>('exec') export const notifyTypeOurFinished = new NotificationType('finished') export const notifyTypeStopped = new NotificationType('stopped') diff --git a/src/debugger/juliaDebug.ts b/src/debugger/juliaDebug.ts index 5f72e8502..abbf28f6d 100644 --- a/src/debugger/juliaDebug.ts +++ b/src/debugger/juliaDebug.ts @@ -33,6 +33,7 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments { code: string file: string stopOnEntry: boolean + compiledModulesOrFunctions?: string[] } export class JuliaDebugSession extends LoggingDebugSession { @@ -173,7 +174,7 @@ export class JuliaDebugSession extends LoggingDebugSession { // await this._configurationDone.wait(1000); await this._configurationDone.wait() - this._connection.sendNotification(notifyTypeExec, { stopOnEntry: args.stopOnEntry, code: args.code, file: args.file }) + this._connection.sendNotification(notifyTypeExec, { stopOnEntry: args.stopOnEntry, code: args.code, file: args.file, compiledModulesOrFunctions: args.compiledModulesOrFunctions }) this.sendResponse(response) } diff --git a/src/interactive/debugConfig.ts b/src/interactive/debugConfig.ts new file mode 100644 index 000000000..7edcd716e --- /dev/null +++ b/src/interactive/debugConfig.ts @@ -0,0 +1,187 @@ +import * as vscode from 'vscode' +import * as rpc from 'vscode-jsonrpc/node' +import { onExit, onFinishEval, onInit } from './repl' + +interface DebugConfigTreeItem { + label: string + hasChildren?: boolean + juliaAccessor?: string +} + +const requestTypeGetDebugItems = new rpc.RequestType< + { juliaAccessor: string }, + DebugConfigTreeItem[], + void>('repl/getDebugItems') + +export class DebugConfigTreeProvider implements vscode.TreeDataProvider { + private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter() + readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event + private _compiledItems: Set = new Set() + private _connection = null + + refresh(el = null): void { + this._onDidChangeTreeData.fire(el) + } + + setConnection(conn) { + this._connection = conn + } + + getChildren(node?: DebugConfigTreeItem): vscode.ProviderResult { + if (node) { + if (node.hasChildren) { + if (this._connection) { + const accessor = node.juliaAccessor || '#root' + return Promise.race([ + this._connection.sendRequest(requestTypeGetDebugItems, { juliaAccessor: accessor }), + new Promise(resolve => { + setTimeout(() => resolve([]), 10000) + }) + ]) + } + return [] + } else { + return [] + } + } + return this.getToplevelItems() + } + + getToplevelItems(): DebugConfigTreeItem[] { + return [ + { + label: 'All loaded modules', + hasChildren: true, + juliaAccessor: '#root' + } + ] + } + + getTreeItem(node: DebugConfigTreeItem): vscode.TreeItem { + const treeItem = new vscode.TreeItem(node.label) + const id = this.getNodeId(node) + const parent = this.getParent(node) + let anyAncestorCompiledAll = false + + // this is bad and I feel bad + let p = node + while (true) { + p = this.getParent(p) + if (p === undefined || !p.juliaAccessor) { + break + } + if (this._compiledItems.has(this.getNodeId(p) + '.')) { + anyAncestorCompiledAll = true + break + } + } + const compiledBecauseParentIsCompiled = node.hasChildren ? parent && this._compiledItems.has(this.getNodeId(parent) + '.') : parent && this._compiledItems.has(this.getNodeId(parent)) + const isCompiled = this._compiledItems.has(id) || compiledBecauseParentIsCompiled || anyAncestorCompiledAll + if (id !== '#root') { + treeItem.description = isCompiled ? 'compiled' : 'interpreted' + treeItem.tooltip = isCompiled ? 'Compiled code cannot be stepped through and breakpoints are disregarded.' : 'Interpreted code can be stepped through and breakpoints are respected.' + treeItem.contextValue = compiledBecauseParentIsCompiled || anyAncestorCompiledAll ? '' : node.hasChildren ? (isCompiled ? 'is-compiled-with-children' : 'is-interpreted-with-children') : (isCompiled ? 'is-compiled' : 'is-interpreted') + } + treeItem.collapsibleState = node.hasChildren ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None + treeItem.id = id + return treeItem + } + + getParent(node: DebugConfigTreeItem): vscode.ProviderResult { + if (node.juliaAccessor === undefined) { + return + } else { + const path = node.juliaAccessor + const parts = path.split('.') + if (parts.length === 0) { + return + } else { + parts.pop() + return { + label: parts[parts.length - 1], // previous name + hasChildren: true, // by definition + juliaAccessor: parts.join('.') + } + } + } + } + + switchStatus(node: DebugConfigTreeItem, compiled: boolean, all: boolean = false) { + if (node === undefined) { + console.error('switchStatus called with undefined!') + return + } + const id = this.getNodeId(node) + if (compiled) { + if (all) { + this._compiledItems.add(id + '.') + } + this._compiledItems.add(id) + } else { + this._compiledItems.delete(id) + this._compiledItems.delete(id + '.') + } + this.refresh(node) + } + + getNodeId(node: DebugConfigTreeItem): string { + return node.juliaAccessor || node.label + } + + getCompiledItems() { + return [...this._compiledItems] + } + + applyDefaults() { + this.reset() + + const defaults: string[] = vscode.workspace.getConfiguration('julia').get('debuggerDefaultCompiled') + defaults.forEach(el => this._compiledItems.add(el)) + this.refresh() + } + + reset() { + this._compiledItems.clear() + this.refresh() + } +} + +export function activate(context: vscode.ExtensionContext) { + const provider = new DebugConfigTreeProvider() + context.subscriptions.push( + vscode.window.registerTreeDataProvider('debugger-compiled', provider), + vscode.commands.registerCommand('language-julia.switchToCompiled', (item: DebugConfigTreeItem) => { + provider.switchStatus(item, true, false) + }), + vscode.commands.registerCommand('language-julia.switchToInterpreted', (item: DebugConfigTreeItem) => { + provider.switchStatus(item, false, false) + }), + vscode.commands.registerCommand('language-julia.switchAllToCompiled', (item: DebugConfigTreeItem) => { + provider.switchStatus(item, true, true) + }), + vscode.commands.registerCommand('language-julia.switchAllToInterpreted', (item: DebugConfigTreeItem) => { + provider.switchStatus(item, false, true) + }), + vscode.commands.registerCommand('language-julia.refreshCompiled', () => { + provider.refresh() + }), + vscode.commands.registerCommand('language-julia.apply-compiled-defaults', () => { + provider.applyDefaults() + }), + vscode.commands.registerCommand('language-julia.reset-compiled', () => { + provider.reset() + }), + onInit(connection => { + provider.setConnection(connection) + provider.refresh() + }), + onFinishEval(_ => provider.refresh()), + onExit(e => { + provider.setConnection(null) + provider.refresh() + }), + ) + return provider +} + +export function deactivate() { } diff --git a/src/interactive/repl.ts b/src/interactive/repl.ts index 77c585d2a..3aef99ec8 100644 --- a/src/interactive/repl.ts +++ b/src/interactive/repl.ts @@ -12,6 +12,7 @@ import { switchEnvToPath } from '../jlpkgenv' import * as juliaexepath from '../juliaexepath' import * as telemetry from '../telemetry' import { generatePipeName, getVersionedParamsAtPosition, inferJuliaNumThreads, setContext } from '../utils' +import * as debugViewProvider from './debugConfig' import { VersionedTextDocumentPositionParams } from './misc' import * as modules from './modules' import * as plots from './plots' @@ -23,6 +24,7 @@ import * as workspace from './workspace' let g_context: vscode.ExtensionContext = null let g_languageClient: vslc.LanguageClient = null +let g_compiledProvider = null let g_terminal: vscode.Terminal = null @@ -134,7 +136,8 @@ function debuggerRun(params: DebugLaunchParams) { name: 'Julia REPL', code: params.code, file: params.filename, - stopOnEntry: false + stopOnEntry: false, + compiledModulesOrFunctions: g_compiledProvider.getCompiledItems() }) } @@ -145,7 +148,8 @@ function debuggerEnter(params: DebugLaunchParams) { name: 'Julia REPL', code: params.code, file: params.filename, - stopOnEntry: true + stopOnEntry: true, + compiledModulesOrFunctions: g_compiledProvider.getCompiledItems() }) } @@ -738,6 +742,8 @@ export async function replStartDebugger(pipename: string) { export function activate(context: vscode.ExtensionContext) { g_context = context + g_compiledProvider = debugViewProvider.activate(context) + context.subscriptions.push( // listeners onSetLanguageClient(languageClient => { From 545680def64d06aea68508d63a1fa08bbeb40c9b Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 27 Jan 2021 16:25:02 +0100 Subject: [PATCH 2/9] improvements --- package.json | 54 +++++++++-- scripts/packages/DebugAdapter | 2 +- scripts/packages/VSCodeServer/src/debugger.jl | 16 ++-- src/interactive/debugConfig.ts | 89 ++++++++++++++++--- 4 files changed, 130 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index e4c6f687e..cdf36fee0 100644 --- a/package.json +++ b/package.json @@ -293,32 +293,43 @@ }, { "command": "language-julia.switchToInterpreted", - "title": "Interpret" + "title": "Remove from compiled modules/functions", + "icon": "$(remove)" }, { "command": "language-julia.switchToCompiled", - "title": "Compile" + "title": "Julia: Add to compiled modules/functions", + "icon": "$(add)" }, { "command": "language-julia.switchAllToInterpreted", - "title": "Switch all to interpreted" + "title": "Julia: Switch all to interpreted" }, { "command": "language-julia.switchAllToCompiled", - "title": "(all)" + "title": "all" }, { "command": "language-julia.apply-compiled-defaults", - "title": "Apply default compiled modules/functions" + "title": "Julia: Apply default compiled modules/functions" }, { "command": "language-julia.reset-compiled", - "title": "Reset compiled modules/functions", - "icon": "$(close)" + "title": "Julia: Reset compiled modules/functions", + "icon": "$(remove)" }, { "command": "language-julia.refreshCompiled", "title": "Julia: Refresh Compiled/Interpreted Pane" + }, + { + "command": "language-julia.set-compiled-for-name", + "title": "Julia: Add symbol to compiled modules/functions", + "icon": "$(add)" + }, + { + "command": "language-julia.set-current-as-default-compiled", + "title": "Julia: Set current compiled modules/functions as default" } ], "menus": { @@ -444,6 +455,11 @@ "command": "language-julia.switchAllToCompiled", "when": "view == debugger-compiled && viewItem == is-interpreted-with-children", "group": "inline@2" + }, + { + "command": "language-julia.reset-compiled", + "when": "view == debugger-compiled && viewItem == is-root-compiled", + "group": "inline" } ], "view/title": [ @@ -466,6 +482,16 @@ "command": "language-julia.reset-compiled", "when": "view == debugger-compiled", "group": "menu" + }, + { + "command": "language-julia.set-current-as-default-compiled", + "when": "view == debugger-compiled", + "group": "menu" + }, + { + "command": "language-julia.set-compiled-for-name", + "when": "view == debugger-compiled", + "group": "navigation" } ], "editor/context": [ @@ -865,7 +891,17 @@ "julia.debuggerDefaultCompiled": { "type": "array", "default": [ - "Base.iterate" + "Base.iterate", + "Core", + "Core.Compiler.", + "Core.IR", + "Core.Intrinsics", + "DelimitedFiles", + "Distributed", + "LinearAlgebra.", + "Serialization", + "SparseArrays", + "Mmap" ], "description": "Functions or modules that are set to compiled mode when setting the defaults.", "scope": "window" @@ -917,7 +953,7 @@ { "type": "tree", "id": "debugger-compiled", - "name": "Compiled/Interpreted Code" + "name": "Julia: Compiled Code" } ] }, diff --git a/scripts/packages/DebugAdapter b/scripts/packages/DebugAdapter index 9e335b2d6..b9663756e 160000 --- a/scripts/packages/DebugAdapter +++ b/scripts/packages/DebugAdapter @@ -1 +1 @@ -Subproject commit 9e335b2d6a4da024fe61d1fd8bfd9b7f81e85c0f +Subproject commit b9663756ed1dd8446e4e780beb76147cb5165d12 diff --git a/scripts/packages/VSCodeServer/src/debugger.jl b/scripts/packages/VSCodeServer/src/debugger.jl index ec78e9caf..ecafdcc13 100644 --- a/scripts/packages/VSCodeServer/src/debugger.jl +++ b/scripts/packages/VSCodeServer/src/debugger.jl @@ -75,16 +75,14 @@ function get_obj_by_accessor(accessor, super = nothing) return get_obj_by_accessor(accessor, Main) end else - for name in names(super; all = true) - if string(name) == top && isdefined(super, name) - this = getfield(super, name) - if length(parts) > 0 - if this isa Module - return get_obj_by_accessor(join(parts, '.'), this) - end - else - return this + if isdefined(super, Symbol(top)) + this = getfield(super, Symbol(top)) + if length(parts) > 0 + if this isa Module + return get_obj_by_accessor(join(parts, '.'), this) end + else + return this end end end diff --git a/src/interactive/debugConfig.ts b/src/interactive/debugConfig.ts index 7edcd716e..2d62c759b 100644 --- a/src/interactive/debugConfig.ts +++ b/src/interactive/debugConfig.ts @@ -6,6 +6,7 @@ interface DebugConfigTreeItem { label: string hasChildren?: boolean juliaAccessor?: string + isCompiledTree: boolean } const requestTypeGetDebugItems = new rpc.RequestType< @@ -29,9 +30,9 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider { if (node) { - if (node.hasChildren) { + if (!node.isCompiledTree && node.hasChildren) { if (this._connection) { - const accessor = node.juliaAccessor || '#root' + const accessor = node.juliaAccessor return Promise.race([ this._connection.sendRequest(requestTypeGetDebugItems, { juliaAccessor: accessor }), new Promise(resolve => { @@ -40,6 +41,8 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider x.length > 0) + if (parts.length > 0) { + const juliaAccessor = isRoot ? + parts[0] : + item.slice(0, node.juliaAccessor.length - (node.juliaAccessor.endsWith('.') ? 1 : 0)) + '.' + parts[0] + const index = out.map(x => x.juliaAccessor).indexOf(juliaAccessor) + if (index === -1) { + out.push({ + label: parts[0], + hasChildren: parts.length > 1, + juliaAccessor: juliaAccessor, + isCompiledTree: true + }) + } else { + out[index].hasChildren = parts.length > 1 + } + } + } + } + return [...out].sort((a, b) => a.label.localeCompare(b.label)) + } + getTreeItem(node: DebugConfigTreeItem): vscode.TreeItem { const treeItem = new vscode.TreeItem(node.label) const id = this.getNodeId(node) @@ -76,14 +115,17 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider { @@ -171,6 +225,17 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand('language-julia.reset-compiled', () => { provider.reset() }), + vscode.commands.registerCommand('language-julia.set-compiled-for-name', async () => { + const name = await vscode.window.showInputBox({ + prompt: 'Please enter a fully qualified module or function name you want the debugger to treat as compiled code (e.g. `Base.Math.sin` or `StaticArrays`). A trailing `.` will treat all submodules as compiled as well.' + }) + if (name) { + provider.addNameToCompiled(name) + } + }), + vscode.commands.registerCommand('language-julia.set-current-as-default-compiled', async () => { + provider.setCurrentAsDefault() + }), onInit(connection => { provider.setConnection(connection) provider.refresh() From 426b2437f6586bc61744523308d326889b5f1f05 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 28 Jan 2021 15:20:24 +0100 Subject: [PATCH 3/9] also support launched debugger and allow list of compiled methods to be changed on the fly --- scripts/packages/DebugAdapter | 2 +- src/{interactive => debugger}/debugConfig.ts | 3 +-- src/debugger/debugFeature.ts | 10 ++++++++-- src/debugger/debugProtocol.ts | 5 +++-- src/debugger/juliaDebug.ts | 13 ++++++++++--- src/extension.ts | 6 ++++-- src/interactive/repl.ts | 6 ++---- 7 files changed, 29 insertions(+), 16 deletions(-) rename src/{interactive => debugger}/debugConfig.ts (99%) diff --git a/scripts/packages/DebugAdapter b/scripts/packages/DebugAdapter index b9663756e..2c57fd564 160000 --- a/scripts/packages/DebugAdapter +++ b/scripts/packages/DebugAdapter @@ -1 +1 @@ -Subproject commit b9663756ed1dd8446e4e780beb76147cb5165d12 +Subproject commit 2c57fd564cf3d95e3f475410a705cf691e33af52 diff --git a/src/interactive/debugConfig.ts b/src/debugger/debugConfig.ts similarity index 99% rename from src/interactive/debugConfig.ts rename to src/debugger/debugConfig.ts index 2d62c759b..4e2149152 100644 --- a/src/interactive/debugConfig.ts +++ b/src/debugger/debugConfig.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode' import * as rpc from 'vscode-jsonrpc/node' -import { onExit, onFinishEval, onInit } from './repl' +import { onExit, onFinishEval, onInit } from '../interactive/repl' interface DebugConfigTreeItem { label: string @@ -23,7 +23,6 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider { + if (vscode.debug.activeDebugSession && vscode.debug.activeDebugSession.type === 'julia') { + vscode.debug.activeDebugSession.customRequest('setCompiledItems', { compiledModulesOrFunctions: compiledProvider.getCompiledItems() }) + } + }) + this.context.subscriptions.push( vscode.debug.registerDebugConfigurationProvider('julia', provider), vscode.debug.registerDebugAdapterDescriptorFactory('julia', factory), @@ -50,7 +56,7 @@ export class JuliaDebugFeature { name: 'Debug Editor Contents', request: 'launch', program, - + compiledModulesOrFunctions: compiledProvider.getCompiledItems() }) }) ) diff --git a/src/debugger/debugProtocol.ts b/src/debugger/debugProtocol.ts index 3dcbb8c56..eeb8c0b7d 100644 --- a/src/debugger/debugProtocol.ts +++ b/src/debugger/debugProtocol.ts @@ -201,7 +201,8 @@ export const requestTypeSetVariable = new RequestType('threads') export const requestTypeBreakpointLocations = new RequestType('breakpointLocations') export const notifyTypeRun = new NotificationType<{ program: string }>('run') -export const notifyTypeDebug = new NotificationType<{ stopOnEntry: boolean, program: string }>('debug') -export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string, compiledModulesOrFunctions: string[] }>('exec') +export const notifyTypeDebug = new NotificationType<{ stopOnEntry: boolean, program: string, compiledModulesOrFunctions?: string[] }>('debug') +export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string, compiledModulesOrFunctions?: string[] }>('exec') export const notifyTypeOurFinished = new NotificationType('finished') export const notifyTypeStopped = new NotificationType('stopped') +export const notifyTypeSetCompiledItems = new NotificationType<{ compiledModulesOrFunctions: string[] }>('setCompiledItems') diff --git a/src/debugger/juliaDebug.ts b/src/debugger/juliaDebug.ts index abbf28f6d..2082433d2 100644 --- a/src/debugger/juliaDebug.ts +++ b/src/debugger/juliaDebug.ts @@ -9,7 +9,7 @@ import { createMessageConnection, Disposable, MessageConnection, StreamMessageRe import { replStartDebugger } from '../interactive/repl' import { getCrashReportingPipename } from '../telemetry' import { generatePipeName } from '../utils' -import { notifyTypeDebug, notifyTypeExec, notifyTypeOurFinished, notifyTypeRun, notifyTypeStopped, requestTypeBreakpointLocations, requestTypeContinue, requestTypeDisconnect, requestTypeEvaluate, requestTypeExceptionInfo, requestTypeNext, requestTypeRestartFrame, requestTypeScopes, requestTypeSetBreakpoints, requestTypeSetExceptionBreakpoints, requestTypeSetFunctionBreakpoints, requestTypeSetVariable, requestTypeSource, requestTypeStackTrace, requestTypeStepIn, requestTypeStepInTargets, requestTypeStepOut, requestTypeTerminate, requestTypeThreads, requestTypeVariables } from './debugProtocol' +import { notifyTypeDebug, notifyTypeExec, notifyTypeOurFinished, notifyTypeRun, notifyTypeSetCompiledItems, notifyTypeStopped, requestTypeBreakpointLocations, requestTypeContinue, requestTypeDisconnect, requestTypeEvaluate, requestTypeExceptionInfo, requestTypeNext, requestTypeRestartFrame, requestTypeScopes, requestTypeSetBreakpoints, requestTypeSetExceptionBreakpoints, requestTypeSetFunctionBreakpoints, requestTypeSetVariable, requestTypeSource, requestTypeStackTrace, requestTypeStepIn, requestTypeStepInTargets, requestTypeStepOut, requestTypeTerminate, requestTypeThreads, requestTypeVariables } from './debugProtocol' /** * This interface describes the Julia specific launch attributes @@ -23,10 +23,11 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments { /** Automatically stop target after launch. If not specified, target does not stop. */ stopOnEntry?: boolean cwd?: string - juliaEnv?: string, + juliaEnv?: string /** enable logging the Debug Adapter Protocol */ trace?: boolean args?: string[] + compiledModulesOrFunctions?: string[] } interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments { @@ -265,7 +266,7 @@ export class JuliaDebugSession extends LoggingDebugSession { this._connection.sendNotification(notifyTypeRun, { program: args.program }) } else { - this._connection.sendNotification(notifyTypeDebug, { stopOnEntry: args.stopOnEntry, program: args.program }) + this._connection.sendNotification(notifyTypeDebug, { stopOnEntry: args.stopOnEntry, program: args.program, compiledModulesOrFunctions: args.compiledModulesOrFunctions }) } this.sendResponse(response) @@ -391,4 +392,10 @@ export class JuliaDebugSession extends LoggingDebugSession { response.body = await this._connection.sendRequest(requestTypeVariables, args) this.sendResponse(response) } + + protected async customRequest(request: string, response: any, args: any) { + if (request === 'setCompiledItems') { + this._connection.sendNotification(notifyTypeSetCompiledItems, args) + } + } } diff --git a/src/extension.ts b/src/extension.ts index fb1d30016..3e68b7dcc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,6 +8,7 @@ import * as os from 'os' import * as path from 'path' import * as vscode from 'vscode' import { LanguageClient, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient/node' +import * as debugViewProvider from './debugger/debugConfig' import { JuliaDebugFeature } from './debugger/debugFeature' import * as documentation from './docbrowser/documentation' import { ProfilerResultsProvider } from './interactive/profiler' @@ -57,9 +58,10 @@ export async function activate(context: vscode.ExtensionContext) { }) // Active features from other files + const compiledProvider = debugViewProvider.activate(context) juliaexepath.activate(context) await juliaexepath.getJuliaExePath() // We run this function now and await to make sure we don't run in twice simultaneously later - repl.activate(context) + repl.activate(context, compiledProvider) weave.activate(context) documentation.activate(context) tasks.activate(context) @@ -68,7 +70,7 @@ export async function activate(context: vscode.ExtensionContext) { openpackagedirectory.activate(context) jlpkgenv.activate(context) - context.subscriptions.push(new JuliaDebugFeature(context)) + context.subscriptions.push(new JuliaDebugFeature(context, compiledProvider)) context.subscriptions.push(new JuliaPackageDevFeature(context)) g_startupNotification = vscode.window.createStatusBarItem() diff --git a/src/interactive/repl.ts b/src/interactive/repl.ts index 3aef99ec8..1b8dcd1a6 100644 --- a/src/interactive/repl.ts +++ b/src/interactive/repl.ts @@ -12,7 +12,6 @@ import { switchEnvToPath } from '../jlpkgenv' import * as juliaexepath from '../juliaexepath' import * as telemetry from '../telemetry' import { generatePipeName, getVersionedParamsAtPosition, inferJuliaNumThreads, setContext } from '../utils' -import * as debugViewProvider from './debugConfig' import { VersionedTextDocumentPositionParams } from './misc' import * as modules from './modules' import * as plots from './plots' @@ -21,7 +20,6 @@ import * as results from './results' import { Frame } from './results' import * as workspace from './workspace' - let g_context: vscode.ExtensionContext = null let g_languageClient: vslc.LanguageClient = null let g_compiledProvider = null @@ -739,10 +737,10 @@ export async function replStartDebugger(pipename: string) { g_connection.sendNotification(notifyTypeReplStartDebugger, { debugPipename: pipename }) } -export function activate(context: vscode.ExtensionContext) { +export function activate(context: vscode.ExtensionContext, compiledProvider) { g_context = context - g_compiledProvider = debugViewProvider.activate(context) + g_compiledProvider = compiledProvider context.subscriptions.push( // listeners From 6e70a25914cdf2e56e51dfcf7ed1e1676d94bb28 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 24 Feb 2021 12:00:28 +0100 Subject: [PATCH 4/9] stop abusing bp API for compiled mode --- package.json | 20 ++++++++++++++++++++ src/debugger/debugConfig.ts | 24 ++++++++++++++++++++++++ src/debugger/debugFeature.ts | 8 +++++++- src/debugger/debugProtocol.ts | 5 +++-- src/debugger/juliaDebug.ts | 22 ++++++++++++++++++---- src/interactive/repl.ts | 6 ++++-- 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index cdf36fee0..60e7fd8a0 100644 --- a/package.json +++ b/package.json @@ -330,6 +330,16 @@ { "command": "language-julia.set-current-as-default-compiled", "title": "Julia: Set current compiled modules/functions as default" + }, + { + "command": "language-julia.enable-compiled-mode", + "title": "Julia: Enable Compiled Mode for the debugger", + "icon": "$(debug-breakpoint)" + }, + { + "command": "language-julia.disable-compiled-mode", + "title": "Julia: Disable Compiled Mode for the debugger", + "icon": "$(debug-breakpoint-unverified)" } ], "menus": { @@ -492,6 +502,16 @@ "command": "language-julia.set-compiled-for-name", "when": "view == debugger-compiled", "group": "navigation" + }, + { + "command": "language-julia.disable-compiled-mode", + "when": "view == debugger-compiled && juliaCompiledMode == true", + "group": "navigation" + }, + { + "command": "language-julia.enable-compiled-mode", + "when": "view == debugger-compiled && juliaCompiledMode == false", + "group": "navigation" } ], "editor/context": [ diff --git a/src/debugger/debugConfig.ts b/src/debugger/debugConfig.ts index 4e2149152..b2cb2bddf 100644 --- a/src/debugger/debugConfig.ts +++ b/src/debugger/debugConfig.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode' import * as rpc from 'vscode-jsonrpc/node' import { onExit, onFinishEval, onInit } from '../interactive/repl' +import { setContext } from '../utils' interface DebugConfigTreeItem { label: string @@ -17,12 +18,16 @@ const requestTypeGetDebugItems = new rpc.RequestType< export class DebugConfigTreeProvider implements vscode.TreeDataProvider { private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter() readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event + private _onDidChangeCompiledMode: vscode.EventEmitter = new vscode.EventEmitter() + readonly onDidChangeCompiledMode: vscode.Event = this._onDidChangeCompiledMode.event private _compiledItems: Set = new Set() + public compiledMode = false private _connection = null refresh(el = null): void { this._onDidChangeTreeData.fire(el) } + setConnection(conn) { this._connection = conn } @@ -191,6 +196,16 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider { provider.setCurrentAsDefault() }), + vscode.commands.registerCommand('language-julia.enable-compiled-mode', async () => { + provider.enableCompiledMode() + setContext('juliaCompiledMode', true) + }), + vscode.commands.registerCommand('language-julia.disable-compiled-mode', async () => { + provider.disableCompiledMode() + setContext('juliaCompiledMode', false) + }), onInit(connection => { provider.setConnection(connection) provider.refresh() diff --git a/src/debugger/debugFeature.ts b/src/debugger/debugFeature.ts index 7352342fe..3fa0a19dc 100644 --- a/src/debugger/debugFeature.ts +++ b/src/debugger/debugFeature.ts @@ -13,6 +13,11 @@ export class JuliaDebugFeature { vscode.debug.activeDebugSession.customRequest('setCompiledItems', { compiledModulesOrFunctions: compiledProvider.getCompiledItems() }) } }) + compiledProvider.onDidChangeCompiledMode(mode => { + if (vscode.debug.activeDebugSession && vscode.debug.activeDebugSession.type === 'julia') { + vscode.debug.activeDebugSession.customRequest('setCompiledMode', { compiledMode: mode }) + } + }) this.context.subscriptions.push( vscode.debug.registerDebugConfigurationProvider('julia', provider), @@ -56,7 +61,8 @@ export class JuliaDebugFeature { name: 'Debug Editor Contents', request: 'launch', program, - compiledModulesOrFunctions: compiledProvider.getCompiledItems() + compiledModulesOrFunctions: compiledProvider.getCompiledItems(), + compiledMode: compiledProvider.compiledMode }) }) ) diff --git a/src/debugger/debugProtocol.ts b/src/debugger/debugProtocol.ts index eeb8c0b7d..d8c3d3924 100644 --- a/src/debugger/debugProtocol.ts +++ b/src/debugger/debugProtocol.ts @@ -201,8 +201,9 @@ export const requestTypeSetVariable = new RequestType('threads') export const requestTypeBreakpointLocations = new RequestType('breakpointLocations') export const notifyTypeRun = new NotificationType<{ program: string }>('run') -export const notifyTypeDebug = new NotificationType<{ stopOnEntry: boolean, program: string, compiledModulesOrFunctions?: string[] }>('debug') -export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string, compiledModulesOrFunctions?: string[] }>('exec') +export const notifyTypeDebug = new NotificationType<{ stopOnEntry: boolean, program: string, compiledModulesOrFunctions?: string[], compiledMode?: Boolean }>('debug') +export const notifyTypeExec = new NotificationType<{ stopOnEntry: boolean, code: string, file: string, compiledModulesOrFunctions?: string[], compiledMode?: Boolean }>('exec') export const notifyTypeOurFinished = new NotificationType('finished') export const notifyTypeStopped = new NotificationType('stopped') export const notifyTypeSetCompiledItems = new NotificationType<{ compiledModulesOrFunctions: string[] }>('setCompiledItems') +export const notifyTypeSetCompiledMode = new NotificationType<{ compiledMode: Boolean }>('setCompiledMode') diff --git a/src/debugger/juliaDebug.ts b/src/debugger/juliaDebug.ts index 2082433d2..351c4dab7 100644 --- a/src/debugger/juliaDebug.ts +++ b/src/debugger/juliaDebug.ts @@ -9,7 +9,7 @@ import { createMessageConnection, Disposable, MessageConnection, StreamMessageRe import { replStartDebugger } from '../interactive/repl' import { getCrashReportingPipename } from '../telemetry' import { generatePipeName } from '../utils' -import { notifyTypeDebug, notifyTypeExec, notifyTypeOurFinished, notifyTypeRun, notifyTypeSetCompiledItems, notifyTypeStopped, requestTypeBreakpointLocations, requestTypeContinue, requestTypeDisconnect, requestTypeEvaluate, requestTypeExceptionInfo, requestTypeNext, requestTypeRestartFrame, requestTypeScopes, requestTypeSetBreakpoints, requestTypeSetExceptionBreakpoints, requestTypeSetFunctionBreakpoints, requestTypeSetVariable, requestTypeSource, requestTypeStackTrace, requestTypeStepIn, requestTypeStepInTargets, requestTypeStepOut, requestTypeTerminate, requestTypeThreads, requestTypeVariables } from './debugProtocol' +import { notifyTypeDebug, notifyTypeExec, notifyTypeOurFinished, notifyTypeRun, notifyTypeSetCompiledItems, notifyTypeSetCompiledMode, notifyTypeStopped, requestTypeBreakpointLocations, requestTypeContinue, requestTypeDisconnect, requestTypeEvaluate, requestTypeExceptionInfo, requestTypeNext, requestTypeRestartFrame, requestTypeScopes, requestTypeSetBreakpoints, requestTypeSetExceptionBreakpoints, requestTypeSetFunctionBreakpoints, requestTypeSetVariable, requestTypeSource, requestTypeStackTrace, requestTypeStepIn, requestTypeStepInTargets, requestTypeStepOut, requestTypeTerminate, requestTypeThreads, requestTypeVariables } from './debugProtocol' /** * This interface describes the Julia specific launch attributes @@ -28,6 +28,7 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments { trace?: boolean args?: string[] compiledModulesOrFunctions?: string[] + compiledMode?: Boolean } interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments { @@ -35,6 +36,7 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments { file: string stopOnEntry: boolean compiledModulesOrFunctions?: string[] + compiledMode?: Boolean } export class JuliaDebugSession extends LoggingDebugSession { @@ -111,7 +113,6 @@ export class JuliaDebugSession extends LoggingDebugSession { response.body.supportsStepInTargetsRequest = true response.body.exceptionBreakpointFilters = [ - { filter: 'compilemode', label: 'Compiled Mode (experimental)', default: false }, { filter: 'error', label: 'Uncaught Exceptions', default: true }, { filter: 'throw', label: 'All Exceptions', default: false } ] @@ -175,7 +176,13 @@ export class JuliaDebugSession extends LoggingDebugSession { // await this._configurationDone.wait(1000); await this._configurationDone.wait() - this._connection.sendNotification(notifyTypeExec, { stopOnEntry: args.stopOnEntry, code: args.code, file: args.file, compiledModulesOrFunctions: args.compiledModulesOrFunctions }) + this._connection.sendNotification(notifyTypeExec, { + stopOnEntry: args.stopOnEntry, + code: args.code, + file: args.file, + compiledModulesOrFunctions: args.compiledModulesOrFunctions, + compiledMode: args.compiledMode + }) this.sendResponse(response) } @@ -266,7 +273,12 @@ export class JuliaDebugSession extends LoggingDebugSession { this._connection.sendNotification(notifyTypeRun, { program: args.program }) } else { - this._connection.sendNotification(notifyTypeDebug, { stopOnEntry: args.stopOnEntry, program: args.program, compiledModulesOrFunctions: args.compiledModulesOrFunctions }) + this._connection.sendNotification(notifyTypeDebug, { + stopOnEntry: args.stopOnEntry, + program: args.program, + compiledModulesOrFunctions: args.compiledModulesOrFunctions, + compiledMode: args.compiledMode + }) } this.sendResponse(response) @@ -396,6 +408,8 @@ export class JuliaDebugSession extends LoggingDebugSession { protected async customRequest(request: string, response: any, args: any) { if (request === 'setCompiledItems') { this._connection.sendNotification(notifyTypeSetCompiledItems, args) + } else if (request === 'setCompiledMode') { + this._connection.sendNotification(notifyTypeSetCompiledMode, args) } } } diff --git a/src/interactive/repl.ts b/src/interactive/repl.ts index 1b8dcd1a6..fe0338547 100644 --- a/src/interactive/repl.ts +++ b/src/interactive/repl.ts @@ -135,7 +135,8 @@ function debuggerRun(params: DebugLaunchParams) { code: params.code, file: params.filename, stopOnEntry: false, - compiledModulesOrFunctions: g_compiledProvider.getCompiledItems() + compiledModulesOrFunctions: g_compiledProvider.getCompiledItems(), + compiledMode: g_compiledProvider.compiledMode }) } @@ -147,7 +148,8 @@ function debuggerEnter(params: DebugLaunchParams) { code: params.code, file: params.filename, stopOnEntry: true, - compiledModulesOrFunctions: g_compiledProvider.getCompiledItems() + compiledModulesOrFunctions: g_compiledProvider.getCompiledItems(), + compiledMode: g_compiledProvider.compiledMode }) } From 15687b11ebbee098579ddc2de462afe24463f34a Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Wed, 24 Feb 2021 16:36:13 +0100 Subject: [PATCH 5/9] support interpreted methods --- package.json | 65 +++++++++++++++++++++++++++++++++---- src/debugger/debugConfig.ts | 39 +++++++++++++++++----- 2 files changed, 88 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 60e7fd8a0..1270b2c45 100644 --- a/package.json +++ b/package.json @@ -307,7 +307,8 @@ }, { "command": "language-julia.switchAllToCompiled", - "title": "all" + "title": "Julia: Switch all to compiled", + "icon": "$(diff-added)" }, { "command": "language-julia.apply-compiled-defaults", @@ -315,7 +316,7 @@ }, { "command": "language-julia.reset-compiled", - "title": "Julia: Reset compiled modules/functions", + "title": "Julia: Clear compiled modules/functions", "icon": "$(remove)" }, { @@ -453,22 +454,22 @@ }, { "command": "language-julia.switchToInterpreted", - "when": "view == debugger-compiled && viewItem == is-compiled || viewItem == is-compiled-with-children", + "when": "view == debugger-compiled && viewItem =~ /\\bcompiled\\b/", "group": "inline@1" }, { "command": "language-julia.switchToCompiled", - "when": "view == debugger-compiled && viewItem == is-interpreted || viewItem == is-interpreted-with-children", + "when": "view == debugger-compiled && viewItem =~ /\\binterpreted\\b/", "group": "inline@1" }, { "command": "language-julia.switchAllToCompiled", - "when": "view == debugger-compiled && viewItem == is-interpreted-with-children", + "when": "view == debugger-compiled && viewItem =~ /\\binterpreted\\b/ && viewItem =~ /\\bhasChildren\\b/", "group": "inline@2" }, { "command": "language-julia.reset-compiled", - "when": "view == debugger-compiled && viewItem == is-root-compiled", + "when": "view == debugger-compiled && viewItem == isRootCompiled", "group": "inline" } ], @@ -911,7 +912,57 @@ "julia.debuggerDefaultCompiled": { "type": "array", "default": [ - "Base.iterate", + "Base.", + "-Base.map", + "-Base.setrounding", + "-Base.timedwait", + "-Base.withenv", + "-Base.cd", + "-Base.count", + "-Base.all", + "-Base.atexit", + "-Base.mktemp", + "-Base.all!", + "-Base.print", + "-Base.redirect_stderr", + "-Base.checkindex", + "-Base.reshape", + "-Base.getindex", + "-Base.!", + "-Base.minimum", + "-Base.findfirst", + "-Base.sprint", + "-Base.task_local_storage", + "-Base.setprecision", + "-Base.reduce", + "-Base.include_string", + "-Base.findlast", + "-Base.atreplinit", + "-Base.filter", + "-Base.filter!", + "-Base.map", + "-Base.map!", + "-Base.nameof", + "-Base.sum!", + "-Base.minimum!", + "-Base.disable_sigint", + "-Base.sum", + "-Base.findnext", + "-Base.show", + "-Base.methods", + "-Base.broadcast", + "-Base.mktempdir", + "-Base.prod!", + "-Base.maximum", + "-Base.any", + "-Base.setindex!", + "-Base.findall", + "-Base.maximum!", + "-Base.parentmodule", + "-Base.open", + "-Base.redirect_stdout", + "-Base.reenable_sigint", + "-Base.redirect_stdin", "Core", "Core.Compiler.", "Core.IR", diff --git a/src/debugger/debugConfig.ts b/src/debugger/debugConfig.ts index b2cb2bddf..3ead662da 100644 --- a/src/debugger/debugConfig.ts +++ b/src/debugger/debugConfig.ts @@ -74,8 +74,12 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider 1 + if (isNegative) { + item = item.slice(1, item.length) + } if (item.startsWith(node.juliaAccessor) || isRoot) { const rest = item.slice(node.juliaAccessor.length) const parts = (isRoot ? item : rest).split('.').filter(x => x.length > 0) @@ -120,13 +124,24 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider { const name = await vscode.window.showInputBox({ - prompt: 'Please enter a fully qualified module or function name you want the debugger to treat as compiled code (e.g. `Base.Math.sin` or `StaticArrays`). A trailing `.` will treat all submodules as compiled as well.' + prompt: 'Please enter a fully qualified module or function name you want the debugger to treat as compiled code (e.g. `Base.Math.sin` or `StaticArrays`). A trailing `.` will treat all submodules as compiled as well. A prefixed `-` will ensure that all methods of the specified function are always interpreted.' }) if (name) { provider.addNameToCompiled(name) From 69757b9c0f37411e792310eed1408151de78a517 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Thu, 25 Feb 2021 14:44:22 +0100 Subject: [PATCH 6/9] update interpreted methods --- package.json | 64 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 1270b2c45..750c69bcc 100644 --- a/package.json +++ b/package.json @@ -913,56 +913,44 @@ "type": "array", "default": [ "Base.", - "-Base.map", - "-Base.setrounding", - "-Base.timedwait", - "-Base.withenv", - "-Base.cd", - "-Base.count", + "-Base.!", "-Base.all", - "-Base.atexit", - "-Base.mktemp", "-Base.all!", - "-Base.print", - "-Base.redirect_stderr", - "-Base.checkindex", - "-Base.reshape", - "-Base.getindex", - "-Base.!", - "-Base.minimum", - "-Base.findfirst", - "-Base.sprint", - "-Base.task_local_storage", - "-Base.setprecision", - "-Base.reduce", - "-Base.include_string", - "-Base.findlast", + "-Base.any", + "-Base.any!", + "-Base.atexit", "-Base.atreplinit", + "-Base.cd", + "-Base.disable_sigint", "-Base.filter", "-Base.filter!", + "-Base.findall", + "-Base.findfirst", + "-Base.findlast", + "-Base.findnext", + "-Base.findprev", + "-Base.include_string", "-Base.map", "-Base.map!", - "-Base.nameof", - "-Base.sum!", + "-Base.maximum!", "-Base.minimum!", - "-Base.disable_sigint", - "-Base.sum", - "-Base.findnext", - "-Base.show", - "-Base.methods", - "-Base.broadcast", + "-Base.mktemp", "-Base.mktempdir", - "-Base.prod!", - "-Base.maximum", - "-Base.any", - "-Base.setindex!", - "-Base.findall", - "-Base.maximum!", - "-Base.parentmodule", "-Base.open", + "-Base.prod!", + "-Base.redirect_stderr", + "-Base.redirect_stdin", "-Base.redirect_stdout", "-Base.reenable_sigint", - "-Base.redirect_stdin", + "-Base.setindex!", + "-Base.setprecision", + "-Base.setrounding", + "-Base.show", + "-Base.sprint", + "-Base.sum!", + "-Base.task_local_storage", + "-Base.timedwait", + "-Base.withenv", "Core", "Core.Compiler.", "Core.IR", From 269fcff1e58094ab13aaeef74414fd88f51e0afa Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 15 Mar 2021 10:45:18 +0100 Subject: [PATCH 7/9] Apply suggestions from code review Co-authored-by: Lyndon White --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 750c69bcc..f4f252479 100644 --- a/package.json +++ b/package.json @@ -929,6 +929,7 @@ "-Base.findlast", "-Base.findnext", "-Base.findprev", + "-Base.Generator", "-Base.include_string", "-Base.map", "-Base.map!", @@ -947,6 +948,7 @@ "-Base.setrounding", "-Base.show", "-Base.sprint", + "-Base.sum", "-Base.sum!", "-Base.task_local_storage", "-Base.timedwait", @@ -959,6 +961,8 @@ "Distributed", "LinearAlgebra.", "Serialization", + "Statistics", + "-Statistics.mean", "SparseArrays", "Mmap" ], From 302f917c83ee1139173939069c4a2612b1874ab0 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 15 Mar 2021 12:11:55 +0100 Subject: [PATCH 8/9] better defaults --- package.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d7649123e..d5d3463ff 100644 --- a/package.json +++ b/package.json @@ -892,19 +892,22 @@ "-Base.all!", "-Base.any", "-Base.any!", - "-Base.atexit", - "-Base.atreplinit", "-Base.cd", - "-Base.disable_sigint", + "-Base.iterate", + "-Base.collect", + "-Base.collect_similar", + "-Base._collect", + "-Base.collect_to!", + "-Base.collect_to_with_first!", "-Base.filter", "-Base.filter!", + "-Base.foreach", "-Base.findall", "-Base.findfirst", "-Base.findlast", "-Base.findnext", "-Base.findprev", "-Base.Generator", - "-Base.include_string", "-Base.map", "-Base.map!", "-Base.maximum!", From fe0180c286a33645bffb1bed60a38d8151fc520d Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 15 Mar 2021 12:25:57 +0100 Subject: [PATCH 9/9] rm console.log --- src/debugger/debugConfig.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/debugger/debugConfig.ts b/src/debugger/debugConfig.ts index 3ead662da..1f2260cea 100644 --- a/src/debugger/debugConfig.ts +++ b/src/debugger/debugConfig.ts @@ -73,7 +73,6 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider 1 @@ -96,7 +95,7 @@ export class DebugConfigTreeProvider implements vscode.TreeDataProvider 1 + out[index].hasChildren = true } } }