Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/debugger/debugAdapterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class LLDBDebugConfigurationProvider implements vscode.DebugConfiguration
}

async promptForCodeLldbSettingsIfRequired(toolchain: SwiftToolchain) {
const libLldbPathResult = await getLLDBLibPath(toolchain);
const libLldbPathResult = await getLLDBLibPath(toolchain, this.logger);
if (!libLldbPathResult.success) {
const errorMessage = `Error: ${getErrorDescription(libLldbPathResult.failure)}`;
void vscode.window.showWarningMessage(
Expand Down
8 changes: 7 additions & 1 deletion src/debugger/lldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as fs from "fs/promises";
import * as path from "path";
import * as vscode from "vscode";

import { SwiftLogger } from "../logging/SwiftLogger";
import { SwiftToolchain } from "../toolchain/toolchain";
import { Result } from "../utilities/result";
import { IS_RUNNING_UNDER_TEST, execFile } from "../utilities/utilities";
Expand Down Expand Up @@ -45,11 +46,15 @@ export function updateLaunchConfigForCI(
*
* @returns Library path for LLDB
*/
export async function getLLDBLibPath(toolchain: SwiftToolchain): Promise<Result<string>> {
export async function getLLDBLibPath(
toolchain: SwiftToolchain,
logger?: SwiftLogger
): Promise<Result<string>> {
let executable: string;
try {
executable = await toolchain.getLLDB();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while we're here, maybe a debug log of what was found

} catch (error) {
logger?.error(`Failed to get LLDB path from the toolchain, error: ${error}`);
return Result.makeFailure(error);
}
let pathHint = path.dirname(toolchain.swiftFolderPath);
Expand All @@ -68,6 +73,7 @@ export async function getLLDBLibPath(toolchain: SwiftToolchain): Promise<Result<
// should just the version of lldb that comes with CodeLLDB. We return a failure with no message
// to indicate we want it to fail silently.
if (process.platform === "win32") {
logger?.error(`Failed to get LLDB library path for lldb on Windows, error: ${error}`);
return Result.makeFailure(undefined);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't seem to add comment to lines not in patch, but in findLibLLDB can we add debug logging for which folders we try to find it in, and debug result of await findLibLLDB(pathHint)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also don't think it would be too verbose to log directory contents returned by readdir in findFileByPattern

Expand Down
5 changes: 4 additions & 1 deletion test/integration-tests/debugger/lldb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ suite("lldb contract test suite", () => {
});

test("getLLDBLibPath Contract Test, make sure we can find lib LLDB", async () => {
const libPath = await getLLDBLibPath(workspaceContext.globalToolchain);
const libPath = await getLLDBLibPath(
workspaceContext.globalToolchain,
workspaceContext.logger
);

// Check the result for various platforms
if (process.platform === "linux") {
Expand Down
Loading