================ @@ -0,0 +1,185 @@ +import * as vscode from "vscode"; +import { DebugProtocol } from "@vscode/debugprotocol"; + +import { DebugSessionTracker } from "../debug-session-tracker"; +import { DisposableContext } from "../disposable-context"; + +import { DAPSymbolType } from ".."; + +export class SymbolsProvider extends DisposableContext { + constructor( + private readonly tracker: DebugSessionTracker, + private readonly extensionContext: vscode.ExtensionContext, + ) { + super(); + + this.pushSubscription(vscode.commands.registerCommand( + "lldb-dap.debug.showSymbols", + () => { + this.SelectModuleAndShowSymbols(); + }, + )); + + this.pushSubscription(vscode.commands.registerCommand( + "lldb-dap.modules.showSymbols", + (moduleItem: DebugProtocol.Module) => { + const session = vscode.debug.activeDebugSession; + if (!session) { + return; + } + this.showSymbolsForModule(session, moduleItem); + }, + )); + } + + static async doesServerSupportSymbolsRequest(session: vscode.DebugSession): Promise<boolean> { + try { + const dummyArguments = { _dummy: true }; + await session.customRequest("dapGetModuleSymbols", dummyArguments); + return true; + } catch (_error) { + return false; + } + } + + private async SelectModuleAndShowSymbols() { + const session = vscode.debug.activeDebugSession; + if (!session) { + return; + } + + if (!await SymbolsProvider.doesServerSupportSymbolsRequest(session)) { + vscode.window.showErrorMessage("The debug adapter does not support symbol requests."); + return; + } + + const modules = this.tracker.debugSessionModules(session); + if (!modules || modules.length === 0) { + return; + } + + // Let the user select a module to show symbols for + const selectedModule = await vscode.window.showQuickPick(modules.map(m => new ModuleQuickPickItem(m)), { + placeHolder: "Select a module to show symbols for" + }); + if (!selectedModule) { + return; + } + + this.showSymbolsForModule(session, selectedModule.module); + } + + private async showSymbolsForModule(session: vscode.DebugSession, module: DebugProtocol.Module) { + try { + const symbols = await this.getSymbolsForModule(session, module.id.toString()); + this.showSymbolsInNewTab(module.name.toString(), symbols); + } catch (error) { + if (error instanceof Error) { + vscode.window.showErrorMessage("Failed to retrieve symbols: " + error.message); + } else { + vscode.window.showErrorMessage("Failed to retrieve symbols due to an unknown error."); + } + + return; + } + } + + private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbolType[]> { + console.log(`Getting symbols for module: ${moduleId}`); + const symbols_response: { symbols: Array<DAPSymbolType> } = await session.customRequest("dapGetModuleSymbols", { moduleId }); + + + return symbols_response?.symbols || []; + } + + private async showSymbolsInNewTab(moduleName: string, symbols: DAPSymbolType[]) { + const panel = vscode.window.createWebviewPanel( + "lldb-dap.symbols", + `Symbols for ${moduleName}`, + vscode.ViewColumn.Active, + { + enableScripts: true, + localResourceRoots: [ + this.getExtensionResourcePath() + ] + } + ); + + let tabulatorJsFilename = "tabulator_simple.min.css"; ---------------- ashgti wrote:
Do we need to add these files to the lldb-dap/.vscodeignore file? Otherwise they might not get picked up when we package the extension. https://github.com/llvm/llvm-project/pull/153836 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits