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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ All notable changes to the Simics Target Debug extension will be documented here
- The Start button in TCF Launch Configurations is no longer disabled while
any Simics Target Debug session runs, only for configurations that connect
to an agent (host and port) that already has a session.
- The prompts for adding and editing symbol files, the context picker and
the symbol prompt of function breakpoints stay open when VS Code loses
focus, so you can copy an address or context from another window. Press
Escape to cancel them.

## [0.5.0] - 2026-11-02

Expand Down
5 changes: 2 additions & 3 deletions docs/configuration/symbol-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ from the Command Palette. Enter:
- The path as seen by the agent. Relative paths are resolved against the
debug session's workspace folder. As you type the path, local files and
folders are suggested; select a folder to list it, or `..` for its parent
folder. **Browse for a File...** and **Browse for a Folder...** open the
file dialog. Enter a path directly if the file is only available to the
agent.
folder. **Browse for a File...** opens the file dialog. Enter a path
directly if the file is only available to the agent.
- The contexts the symbols apply to, with the
[context picker](/configuration/contexts#the-context-picker).
- How the symbols are placed: the file addresses, a relocation offset (like
Expand Down
3 changes: 3 additions & 0 deletions src/contextPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function chooseScope(options: PickContextsOptions): Promise<MenuItem["action"] |
const picker = vscode.window.createQuickPick<MenuItem>();
picker.title = options.title;
picker.placeholder = "Choose the contexts it applies to";
picker.ignoreFocusOut = true;
picker.matchOnDescription = true;
const menu = scopeMenuItems(options.scope, options.contexts, options.selectedId);
const items: MenuItem[] = menu.map(({ label, description, action }) => ({ label, description, action }));
Expand Down Expand Up @@ -115,6 +116,7 @@ function check(options: PickContextsOptions, initial: readonly string[]): Promis
picker.title = options.title;
picker.placeholder = options.placeholder ?? "Check one or more contexts";
picker.canSelectMany = true;
picker.ignoreFocusOut = true;
picker.matchOnDescription = true;
picker.matchOnDetail = true;
picker.buttons = [vscode.QuickInputButtons.Back];
Expand Down Expand Up @@ -187,6 +189,7 @@ function enterQuery(options: PickContextsOptions, initial: string): Promise<Step
input.prompt = "TCF context query";
input.placeholder = "Context query";
input.value = initial;
input.ignoreFocusOut = true;
input.buttons = [vscode.QuickInputButtons.Back];
let finished = false;

Expand Down
83 changes: 48 additions & 35 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ async function addFunctionBreakpointInContext(
const symbol = await vscode.window.showInputBox({
title: "Add Function Breakpoint",
prompt: `Symbol in ${describeContextScope(scope)}`,
ignoreFocusOut: true,
validateInput: (value) => (!value.trim() ? "Enter a symbol or expression" : undefined),
});
if (!symbol?.trim()) {
Expand Down Expand Up @@ -445,54 +446,54 @@ async function addSymbolFile(symbolFiles: SymbolFilesProvider): Promise<void> {
interface SymbolPathChoice extends vscode.QuickPickItem {
path: string;
directory?: boolean;
browse?: "file" | "folder";
browse?: true;
}

const BROWSE_CHOICES: SymbolPathChoice[] = [
{ label: "$(file) Browse for a File...", path: "", browse: "file", alwaysShow: true },
{ label: "$(folder-opened) Browse for a Folder...", path: "", browse: "folder", alwaysShow: true },
];
const BROWSE_CHOICE: SymbolPathChoice = {
label: "$(file) Browse for a File...",
path: "",
browse: true,
alwaysShow: true,
};

async function browseSymbolPath(
pick: "file" | "folder",
typed: string,
workspaceFolder?: string,
): Promise<string | undefined> {
async function browseSymbolFile(typed: string, workspaceFolder?: string): Promise<string | undefined> {
const uris = await vscode.window.showOpenDialog({
canSelectFiles: pick === "file",
canSelectFolders: pick === "folder",
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
defaultUri: startFolder(typed, workspaceFolder),
openLabel: "Select",
});
return uris?.[0]?.fsPath;
}

// A file as defaultUri makes VS Code's simple file dialog behave like a save dialog.
function startFolder(typed: string, workspaceFolder?: string): vscode.Uri | undefined {
/** The typed path on this host, resolved against the workspace folder. */
function localSymbolPath(typed: string, workspaceFolder?: string): string | undefined {
const value = typed.trim();
const resolved = !value
? undefined
: path.isAbsolute(value)
? value
: workspaceFolder && path.join(workspaceFolder, value);
for (const candidate of resolved ? [resolved, path.dirname(resolved)] : []) {
try {
if (fs.statSync(candidate).isDirectory()) {
return vscode.Uri.file(candidate);
}
} catch {
// Try the next candidate.
}
return !value ? undefined : path.isAbsolute(value) ? value : workspaceFolder && path.join(workspaceFolder, value);
}

function isLocalFolder(file: string | undefined): boolean {
try {
return file !== undefined && fs.statSync(file).isDirectory();
} catch {
return false;
}
return workspaceFolder ? vscode.Uri.file(workspaceFolder) : undefined;
}

// A file as defaultUri makes VS Code's simple file dialog behave like a save dialog.
function startFolder(typed: string, workspaceFolder?: string): vscode.Uri | undefined {
const resolved = localSymbolPath(typed, workspaceFolder);
const folder = (resolved ? [resolved, path.dirname(resolved)] : []).find(isLocalFolder);
return folder ? vscode.Uri.file(folder) : workspaceFolder ? vscode.Uri.file(workspaceFolder) : undefined;
}

function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promise<string | undefined> {
return new Promise((resolve) => {
const picker = vscode.window.createQuickPick<SymbolPathChoice>();
picker.title = initialPath ? "Update Symbol File Path" : "Add Symbol File";
picker.placeholder = "Type an agent path or select a suggested local file or folder";
picker.placeholder = "Type an agent path or select a suggested local file";
picker.ignoreFocusOut = true;
let finished = false;

function finish(value?: string): void {
Expand All @@ -507,9 +508,11 @@ function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promi

async function update(value: string): Promise<void> {
const typed = value.trim();
// A local folder is not a symbol file; the suggestions list it instead.
const usable = typed && !isLocalFolder(localSymbolPath(typed, workspaceFolder));
const manual: SymbolPathChoice[] = [
...(typed ? [{ label: typed, description: "Use this path", path: typed }] : []),
...BROWSE_CHOICES,
...(usable ? [{ label: typed, description: "Use this path", path: typed }] : []),
BROWSE_CHOICE,
];
picker.items = manual;
picker.busy = true;
Expand Down Expand Up @@ -558,11 +561,19 @@ function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promi
const typed = picker.value;
finished = true;
picker.dispose();
resolve(browseSymbolPath(selected.browse, typed, workspaceFolder));
resolve(browseSymbolFile(typed, workspaceFolder));
} else if (selected?.directory) {
picker.value = selected.path + path.sep;
} else if (selected?.path || picker.value.trim()) {
finish(selected?.path ?? picker.value.trim());
} else {
const chosen = selected?.path ?? picker.value.trim();
if (!chosen) {
return;
}
if (!isLocalFolder(localSymbolPath(chosen, workspaceFolder))) {
finish(chosen);
} else if (!chosen.endsWith(path.sep)) {
picker.value = chosen + path.sep;
}
}
});
picker.onDidHide(() => finish());
Expand Down Expand Up @@ -632,7 +643,7 @@ async function editSymbolFile(item?: SymbolFileViewItem): Promise<void> {
{ label: "Contexts", description: capitalize(describeContextScope(file)), field: "contexts" },
{ label: "Load Address", description: describeLoadAddress(file), field: "address" },
],
{ title: "Edit Symbol Mapping", placeHolder: "Select a field to update" },
{ title: "Edit Symbol Mapping", placeHolder: "Select a field to update", ignoreFocusOut: true },
);
if (!selected) {
return;
Expand Down Expand Up @@ -717,6 +728,7 @@ async function promptLoadAddress(
const mode = await vscode.window.showQuickPick(items, {
title: "Load Address",
placeHolder: "How are the symbols placed in memory?",
ignoreFocusOut: true,
});
if (!mode) {
return undefined;
Expand All @@ -731,6 +743,7 @@ async function promptLoadAddress(
? "Address of the first loadable segment, hex or decimal (for example 0x100000)"
: "Offset added to the file addresses, hex or decimal, may be negative (for example 0x1000 or -0x1000)",
value: currentMode === mode.mode ? formatConfigAddress(current?.address) : "",
ignoreFocusOut: true,
validateInput: (v) =>
(absolute ? /^(0x[0-9a-f]+|\d+)$/i : /^-?\s*(0x[0-9a-f]+|\d+)$/i).test(v.trim())
? undefined
Expand Down