Файли
openidea/src/features/run/xcodeDebug.test.ts
T
LU XIANGRUIтаwildcatDownstairs 657d49e30a fix(debug): bind Xcode breakpoints for projects under /private/tmp (#7368)
Debugging an Xcode app whose project lives under /private/tmp never stopped at a breakpoint: the IDE sends breakpoints on the canonical /private/tmp/… path, while Xcode writes the files into the debug info as /tmp/…. The simulator attach now passes lldb-dap a sourceMap (/tmp, /var, /etc → /private/…). The map is Xcode-only: clang, swift build and cargo record /private/tmp/…, and LLDB uses only the first matching entry.

lldb-dap and CodeLLDB give no reason for a breakpoint they cannot bind; such breakpoints now carry one (code not loaded yet, or debug info under another path), shown translated on hover in the gutter and in the Breakpoints dialog, and dropped once the breakpoint binds.

Fixes #7367

Co-authored-by: wildcatDownstairs <[email protected]>
2026-12-02 12:40:05 +08:00

63 рядки
1.9 KiB
TypeScript

import { beforeEach, expect, test, vi } from "vitest";
import type { RunConfig } from "@/platform/ipc";
const { startRun, executeAction } = vi.hoisted(() => ({ startRun: vi.fn(), executeAction: vi.fn() }));
vi.mock("./store", () => ({ startRun }));
vi.mock("@/platform/actions", () => ({ executeAction }));
import { debugXcodeApp, launchedPid } from "./xcodeDebug";
const config = {
id: "xcode:run:App.xcodeproj:App",
name: "App",
kind: "xcode",
params: { container: "App.xcodeproj", scheme: "App" },
} as unknown as RunConfig;
beforeEach(() => {
startRun.mockReset();
executeAction.mockReset();
});
test("simctl's launch line gives the pid", () => {
expect(launchedPid("dev.example.App: 4321")).toBe(4321);
expect(launchedPid("dev.example.App: 4321\r\n")).toBe(4321);
expect(launchedPid("note: 12")).toBeNull();
expect(launchedPid("** BUILD SUCCEEDED **")).toBeNull();
});
test("Debug launches the app suspended and attaches lldb-dap to its pid once", async () => {
startRun.mockImplementation(async (_c, _r, _b, options) => {
// The launch line can arrive before startRun returns the run's id.
options.onLine("Build succeeded");
options.onLine("dev.example.App: 4321");
options.onLine("dev.example.App: 9999");
return { runId: 7 };
});
await debugXcodeApp(config, false);
const [, , , options] = startRun.mock.calls[0]!;
expect(options.launch.params).toEqual({ container: "App.xcodeproj", scheme: "App", waitForDebugger: "1" });
expect(executeAction).toHaveBeenCalledTimes(1);
expect(executeAction).toHaveBeenCalledWith("debug.attach", {
attachable: {
pid: 4321,
name: "App",
commandLine: "",
kind: "native",
adapter: "lldb-dap",
host: null,
port: null,
},
process: 7,
runConfig: config,
show: false,
extra: {
sourceMap: [
["/tmp", "/private/tmp"],
["/var", "/private/var"],
["/etc", "/private/etc"],
],
},
});
});