дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
7c8d6ff3e8 |
No files matched your search
@@ -530,6 +530,7 @@ pub struct DebuggerSettings {
|
||||
/// Java: whether to reload changed classes into running debug sessions after compilation.
|
||||
pub hot_swap_after_compile: HotSwapPolicy,
|
||||
pub python: PythonDebuggerSettings,
|
||||
pub cpp: CppDebuggerSettings,
|
||||
}
|
||||
|
||||
impl Default for DebuggerSettings {
|
||||
@@ -552,6 +553,7 @@ impl Default for DebuggerSettings {
|
||||
flutter_hot_reload_on_save: true,
|
||||
hot_swap_after_compile: HotSwapPolicy::Ask,
|
||||
python: PythonDebuggerSettings::default(),
|
||||
cpp: CppDebuggerSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,6 +572,14 @@ impl Default for PythonDebuggerSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/// C/C++ debugger executables. Empty paths use automatic discovery.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct CppDebuggerSettings {
|
||||
pub gdb_executable: String,
|
||||
pub lldb_dap_executable: String,
|
||||
}
|
||||
|
||||
/// Run/Debug configuration behaviour.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
@@ -803,4 +813,17 @@ mod tests {
|
||||
assert_eq!(serialized["hotSwapAfterCompile"], raw);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cpp_debugger_paths_default_to_empty_and_roundtrip() {
|
||||
let missing: DebuggerSettings = serde_json::from_str("{}").unwrap();
|
||||
assert!(missing.cpp.gdb_executable.is_empty());
|
||||
assert!(missing.cpp.lldb_dap_executable.is_empty());
|
||||
|
||||
let cpp = serde_json::json!({"gdbExecutable": "tools/gdb-16", "lldbDapExecutable": "/opt/llvm/bin/lldb-dap"});
|
||||
let settings: DebuggerSettings = serde_json::from_value(serde_json::json!({"cpp": cpp})).unwrap();
|
||||
assert_eq!(settings.cpp.gdb_executable, "tools/gdb-16");
|
||||
assert_eq!(settings.cpp.lldb_dap_executable, "/opt/llvm/bin/lldb-dap");
|
||||
assert_eq!(serde_json::to_value(&settings).unwrap()["cpp"], cpp);
|
||||
}
|
||||
}
|
||||
@@ -585,8 +585,9 @@ async fn prepare_gdb(spec: &AdapterSpec, binary: &Path) -> IdeResult<bool> {
|
||||
return Ok(major == 15);
|
||||
}
|
||||
let mut msg = format!(
|
||||
"debugging with GDB needs GDB {GDB_MIN_MAJOR} or newer (found {major}.{minor}): \
|
||||
this one has no DAP interpreter (`gdb -i dap`)"
|
||||
"debugging with GDB needs GDB {GDB_MIN_MAJOR} or newer (found {major}.{minor} at {}): \
|
||||
this one has no DAP interpreter (`gdb -i dap`)",
|
||||
binary.display(),
|
||||
);
|
||||
if let Some(hint) = &spec.install_hint {
|
||||
msg.push_str(". ");
|
||||
@@ -1068,6 +1069,26 @@ mod tests {
|
||||
assert!(builtin("nope").is_none());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn gdb_version_check_probes_the_adapter_command() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let binary = dir.path().join("custom gdb");
|
||||
std::fs::write(&binary, "#!/bin/sh\n[ \"$1\" = --version ] && echo 'GNU gdb (GDB) 13.2'\n").unwrap();
|
||||
std::fs::set_permissions(&binary, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let mut spec = resolve(&builtin("gdb").unwrap(), dir.path().to_path_buf());
|
||||
spec.command = binary.to_str().unwrap().to_owned();
|
||||
|
||||
let Err(error) = ProcessLauncher.launch(spec, None).await else {
|
||||
panic!("GDB 13 was started as a DAP adapter");
|
||||
};
|
||||
assert_eq!(error.kind, ide_core::error::ErrorKind::Unavailable);
|
||||
assert!(error.message.contains("needs GDB 14 or newer (found 13.2 at "), "{}", error.message);
|
||||
assert!(error.message.contains(binary.to_str().unwrap()), "{}", error.message);
|
||||
}
|
||||
|
||||
/// Debian/Ubuntu's versioned lldb-dap (and lldb-vscode before LLVM 18): the newest LLVM wins.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::LaunchConfig;
|
||||
use crate::adapter::{GDB_MIN_MAJOR, probe_gdb_version};
|
||||
use ide_core::{IdeError, IdeResult};
|
||||
use serde_json::{Map, Value, json};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Prefix of the error when none of them is there; the UI offers to install CodeLLDB on it.
|
||||
pub const NO_NATIVE_DEBUGGER: &str = "No C/C++ debugger found";
|
||||
@@ -36,7 +36,7 @@ pub async fn choose(
|
||||
Found::LldbDap => {}
|
||||
Found::CodeLldb => convert(&mut config, "codelldb")?,
|
||||
Found::Gdb(gdb) => match probe_gdb_version(&gdb, &cwd, &[]).await {
|
||||
Some((major, minor)) if major < GDB_MIN_MAJOR => return Err(missing(Some((major, minor)))),
|
||||
Some((major, minor)) if major < GDB_MIN_MAJOR => return Err(missing(Some((&gdb, major, minor)))),
|
||||
// Unknown versions are left to GDB itself, as a GDB launch does.
|
||||
_ => convert(&mut config, "gdb")?,
|
||||
},
|
||||
@@ -52,11 +52,12 @@ enum Found {
|
||||
Nothing,
|
||||
}
|
||||
|
||||
fn missing(gdb: Option<(u32, u32)>) -> IdeError {
|
||||
fn missing(gdb: Option<(&Path, u32, u32)>) -> IdeError {
|
||||
let found = match gdb {
|
||||
Some((major, minor)) => format!(
|
||||
"lldb-dap and CodeLLDB are not installed, and GDB {major}.{minor} cannot debug through DAP \
|
||||
(it needs GDB {GDB_MIN_MAJOR} or newer)"
|
||||
Some((path, major, minor)) => format!(
|
||||
"lldb-dap and CodeLLDB are not installed, and GDB {major}.{minor} at {} cannot debug through DAP \
|
||||
(it needs GDB {GDB_MIN_MAJOR} or newer)",
|
||||
path.display(),
|
||||
),
|
||||
None => "lldb-dap, CodeLLDB and GDB are not installed".to_owned(),
|
||||
};
|
||||
@@ -103,8 +104,6 @@ fn convert(config: &mut LaunchConfig, to: &str) -> IdeResult<()> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::BTreeMap;
|
||||
#[cfg(unix)]
|
||||
use std::path::Path;
|
||||
|
||||
fn cmake_launch() -> LaunchConfig {
|
||||
LaunchConfig {
|
||||
@@ -188,9 +187,11 @@ mod tests {
|
||||
async fn an_old_gdb_is_named_in_the_error() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let gdb = fake_gdb(dir.path(), "GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1");
|
||||
let e = choose(cmake_launch(), move |c| (c == "gdb").then(|| gdb.clone())).await.unwrap_err();
|
||||
let path = gdb.clone();
|
||||
let e = choose(cmake_launch(), move |c| (c == "gdb").then(|| path.clone())).await.unwrap_err();
|
||||
assert!(e.message.starts_with(NO_NATIVE_DEBUGGER), "{}", e.message);
|
||||
assert!(e.message.contains("GDB 12.1"), "{}", e.message);
|
||||
assert!(e.message.contains(gdb.to_str().unwrap()), "{}", e.message);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
mod kotlin;
|
||||
#[cfg(test)]
|
||||
mod kotlin_tests;
|
||||
#[cfg(test)]
|
||||
mod native_tests;
|
||||
mod output;
|
||||
|
||||
use crate::Host;
|
||||
use ide_command::command;
|
||||
use ide_core::{DebugSessionId, IdeResult};
|
||||
use ide_dap::*;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Starts a session owned by this window: its events (and those of child sessions) go here only.
|
||||
#[command(trust = trusted)]
|
||||
@@ -143,8 +145,10 @@ pub async fn debug_start(host: &Host, window: &str, config: LaunchConfig) -> Ide
|
||||
// No lldb-dap on this host (most Linux hosts): CodeLLDB, else GDB 14+.
|
||||
if config.adapter == "lldb-dap" {
|
||||
let (root, settings) = (root.clone(), settings.clone());
|
||||
let project_root = project.root.clone();
|
||||
config = ide_dap::native::choose(config, move |command| {
|
||||
ide_sdk::apply::tool_command(&root, &settings, command)
|
||||
native_debugger_command(&project_root, &settings.debugger.cpp, command)
|
||||
.or_else(|| ide_sdk::apply::tool_command(&root, &settings, command))
|
||||
.or_else(|| ide_dap::adapter::resolve_binary(command, &root))
|
||||
})
|
||||
.await?;
|
||||
@@ -161,11 +165,13 @@ pub async fn debug_start(host: &Host, window: &str, config: LaunchConfig) -> Ide
|
||||
.await?;
|
||||
}
|
||||
let java_analyzer = java_analyzer_command(host, window, &config)?;
|
||||
let native = native_debugger_command(&project.root, &settings.debugger.cpp, &config.adapter);
|
||||
let custom = |command: &str| {
|
||||
if let Some(binary) = java_analyzer {
|
||||
return Some(binary.to_string_lossy().into_owned());
|
||||
}
|
||||
let path = ide_sdk::apply::tool_command(&root, &settings, command)
|
||||
let path = native
|
||||
.or_else(|| ide_sdk::apply::tool_command(&root, &settings, command))
|
||||
.or_else(|| ruby_tools.into_iter().find(|(name, _)| *name == command).map(|(_, path)| path))?;
|
||||
Some(path.to_string_lossy().into_owned())
|
||||
};
|
||||
@@ -197,6 +203,19 @@ pub async fn debug_start(host: &Host, window: &str, config: LaunchConfig) -> Ide
|
||||
result
|
||||
}
|
||||
|
||||
fn native_debugger_command(
|
||||
root: &Path,
|
||||
settings: &ide_core::settings::CppDebuggerSettings,
|
||||
adapter: &str,
|
||||
) -> Option<PathBuf> {
|
||||
let path = match adapter {
|
||||
"gdb" => &settings.gdb_executable,
|
||||
"lldb-dap" => &settings.lldb_dap_executable,
|
||||
_ => return None,
|
||||
};
|
||||
ide_sdk::apply::setting_path(root, path)
|
||||
}
|
||||
|
||||
/// For java-analyzer's debugger, the executable of the java-analyzer serving the module
|
||||
/// (`projectRoot`, else the working directory), so the session debugs with the server that
|
||||
/// analyzes the code.
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
use super::*;
|
||||
use ide_core::IdeError;
|
||||
use ide_dap::adapter::{AdapterLauncher, AdapterSpec, LaunchFuture};
|
||||
use ide_workspace::SettingsScope;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Default)]
|
||||
struct CaptureAdapter(Mutex<Option<AdapterSpec>>);
|
||||
|
||||
impl AdapterLauncher for CaptureAdapter {
|
||||
fn launch(&self, spec: AdapterSpec, _: Option<u16>) -> LaunchFuture {
|
||||
*self.0.lock() = Some(spec);
|
||||
Box::pin(async { Err(IdeError::cancelled()) })
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn cpp_debugger_paths_override_adapter_commands() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(dir.path()).unwrap();
|
||||
let root = base.join("project");
|
||||
let cwd = root.join("build");
|
||||
std::fs::create_dir_all(&cwd).unwrap();
|
||||
let capture = Arc::new(CaptureAdapter::default());
|
||||
let mut host = Host::new(crate::HostConfig::for_test(&base));
|
||||
host.debugger = DebugManager::with_launcher(host.languages.clone(), capture.clone());
|
||||
host.open_project("main", &root).unwrap();
|
||||
host.set_project_trust(&root, true, false).await.unwrap();
|
||||
let project = host.project("main").unwrap();
|
||||
|
||||
for (adapter, key, configured) in [
|
||||
("gdb", "gdbExecutable", root.join("custom gdb").to_str().unwrap().to_owned()),
|
||||
("lldb-dap", "lldbDapExecutable", "tools/lldb-dap-custom".into()),
|
||||
] {
|
||||
let config = LaunchConfig {
|
||||
name: "C++".into(),
|
||||
adapter: adapter.into(),
|
||||
request: "attach".into(),
|
||||
program: None,
|
||||
args: vec![],
|
||||
cwd: Some(cwd.clone().into()),
|
||||
env: Default::default(),
|
||||
extra_json: Some(r#"{"pid":1}"#.into()),
|
||||
};
|
||||
let _ = debug_start(&host, "main", config.clone()).await.unwrap_err();
|
||||
assert_eq!(capture.0.lock().take().unwrap().command, adapter);
|
||||
|
||||
project
|
||||
.settings
|
||||
.set(SettingsScope::Project, &format!("debugger.cpp.{key}"), serde_json::json!(configured))
|
||||
.unwrap();
|
||||
let mut config = config;
|
||||
config.request = "launch".into();
|
||||
config.program = Some(cwd.join("app").to_str().unwrap().to_owned());
|
||||
config.extra_json = None;
|
||||
let _ = debug_start(&host, "main", config).await.unwrap_err();
|
||||
let spec = capture.0.lock().take().unwrap();
|
||||
assert_eq!(spec.adapter, adapter);
|
||||
assert_eq!(Path::new(&spec.command), root.join(configured));
|
||||
assert_eq!(spec.cwd, cwd);
|
||||
}
|
||||
}
|
||||
@@ -5914,6 +5914,12 @@ export type CoverageSuite = {
|
||||
files: FileCoverage[],
|
||||
};
|
||||
|
||||
/** C/C++ debugger executables. Empty paths use automatic discovery. */
|
||||
export type CppDebuggerSettings = {
|
||||
gdbExecutable?: string,
|
||||
lldbDapExecutable?: string,
|
||||
};
|
||||
|
||||
/** Payload for creating a new instruction or rule file. */
|
||||
export type CreateAgentMemoryInput = {
|
||||
scope: McpScope,
|
||||
@@ -6923,6 +6929,7 @@ export type DebuggerSettings = {
|
||||
/** Java: whether to reload changed classes into running debug sessions after compilation. */
|
||||
hotSwapAfterCompile?: HotSwapPolicy,
|
||||
python?: PythonDebuggerSettings,
|
||||
cpp?: CppDebuggerSettings,
|
||||
};
|
||||
|
||||
/** An editor decoration. */
|
||||
|
||||
@@ -15,57 +15,9 @@ import { choosePath } from "@/platform/choosePath";
|
||||
import { usePageContext, useSetting } from "../components/context";
|
||||
import { SdkField, tildify, useDetected, useJdtlsJdk } from "./components";
|
||||
import { isMavenThreadCount } from "./mavenThreads";
|
||||
import { PathField, PathInput } from "./PathInput";
|
||||
import styles from "./Sdk.module.css";
|
||||
|
||||
interface PathFieldProps {
|
||||
k: string;
|
||||
placeholder: string;
|
||||
title: string;
|
||||
id?: string;
|
||||
"aria-label"?: string;
|
||||
/** Browse for a file instead of a directory. */
|
||||
file?: boolean;
|
||||
}
|
||||
|
||||
function PathField({ k, placeholder, title, id, file, ...aria }: PathFieldProps) {
|
||||
const [value, set] = useSetting<string>(k);
|
||||
return (
|
||||
<span className={styles.pathRow}>
|
||||
<Input
|
||||
id={id}
|
||||
mono
|
||||
className={styles.pathInput}
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
onChange={(e) => set(e.target.value.trim())}
|
||||
aria-label={aria["aria-label"]}
|
||||
/>
|
||||
<IconButton
|
||||
icon="folder-open"
|
||||
size="small"
|
||||
title="Browse…"
|
||||
onClick={async () => {
|
||||
const p = await choosePath({ directory: !file, title, defaultPath: value || undefined });
|
||||
if (p) set(p);
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function PathInput({
|
||||
label,
|
||||
hint,
|
||||
...field
|
||||
}: Omit<PathFieldProps, "id" | "aria-label"> & { label: string; hint?: string }) {
|
||||
const id = useId();
|
||||
return (
|
||||
<Row label={label} htmlFor={id} hint={hint}>
|
||||
<PathField {...field} id={id} />
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
function SdkRow({
|
||||
k,
|
||||
label,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { useId } from "react";
|
||||
import { choosePath } from "@/platform/choosePath";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { IconButton, Input } from "@/ui";
|
||||
import { Row } from "../components/Form";
|
||||
import { useSetting } from "../components/context";
|
||||
import styles from "./Sdk.module.css";
|
||||
|
||||
interface PathFieldProps {
|
||||
k: string;
|
||||
placeholder: string;
|
||||
title: string;
|
||||
id?: string;
|
||||
"aria-label"?: string;
|
||||
/** Browse for a file instead of a directory. */
|
||||
file?: boolean;
|
||||
}
|
||||
|
||||
export function PathField({ k, placeholder, title, id, file, ...aria }: PathFieldProps) {
|
||||
const [value, set] = useSetting<string>(k);
|
||||
const tx = useTx();
|
||||
return (
|
||||
<span className={styles.pathRow}>
|
||||
<Input
|
||||
id={id}
|
||||
mono
|
||||
className={styles.pathInput}
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
onChange={(e) => set(e.target.value.trim())}
|
||||
aria-label={aria["aria-label"]}
|
||||
/>
|
||||
<IconButton
|
||||
icon="folder-open"
|
||||
size="small"
|
||||
title="Browse…"
|
||||
onClick={async () => {
|
||||
const p = await choosePath({ directory: !file, title: tx(title), defaultPath: value || undefined });
|
||||
if (p) set(p);
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function PathInput({
|
||||
label,
|
||||
hint,
|
||||
...field
|
||||
}: Omit<PathFieldProps, "id" | "aria-label"> & { label: string; hint?: string }) {
|
||||
const id = useId();
|
||||
return (
|
||||
<Row label={label} htmlFor={id} hint={hint}>
|
||||
<PathField {...field} id={id} />
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { useProject } from "@/platform/project";
|
||||
import type { SelectOption } from "@/ui";
|
||||
import { ColorSwatches, FormGroup, GlobListEditor, Row, SettingNumber, Toggle } from "../components/Form";
|
||||
import { usePageContext, useSetting } from "../components/context";
|
||||
import { PathInput } from "../languages/PathInput";
|
||||
import { useSettingsDialog } from "../model/staging";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
@@ -25,6 +26,35 @@ export const BUILD_GROUP = "Build, Execution, Deployment";
|
||||
|
||||
const L = WORKFLOW_LIMITS;
|
||||
|
||||
const gdbLabel = "GDB executable";
|
||||
const lldbDapLabel = "LLDB DAP executable";
|
||||
|
||||
function GdbExecutable() {
|
||||
return (
|
||||
<PathInput
|
||||
k="debugger.cpp.gdbExecutable"
|
||||
label={gdbLabel}
|
||||
title={gdbLabel}
|
||||
placeholder="Auto"
|
||||
hint="Requires GDB 14 or newer. Leave blank for automatic discovery."
|
||||
file
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function LldbDapExecutable() {
|
||||
return (
|
||||
<PathInput
|
||||
k="debugger.cpp.lldbDapExecutable"
|
||||
label={lldbDapLabel}
|
||||
title={lldbDapLabel}
|
||||
placeholder="Auto"
|
||||
hint="Leave blank for automatic discovery."
|
||||
file
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const CONSOLE_ENCODINGS: SelectOption[] = [
|
||||
"UTF-8",
|
||||
"UTF-16LE",
|
||||
@@ -382,6 +412,13 @@ export const EXECUTION_PAGES: PageSpec[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "C/C++",
|
||||
options: [
|
||||
{ kind: "custom", label: gdbLabel, component: GdbExecutable },
|
||||
{ kind: "custom", label: lldbDapLabel, component: LldbDapExecutable },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1344,6 +1344,10 @@
|
||||
"Debug views": "偵錯檢視",
|
||||
"Debuggable configurations": "可偵錯的組態",
|
||||
"Debugger": "偵錯工具",
|
||||
"GDB executable": "GDB 執行檔",
|
||||
"LLDB DAP executable": "LLDB DAP 執行檔",
|
||||
"Requires GDB 14 or newer. Leave blank for automatic discovery.": "需要 GDB 14 或更新版本。留空則自動尋找。",
|
||||
"Leave blank for automatic discovery.": "留空則自動尋找。",
|
||||
"Debugger actions": "偵錯工具操作",
|
||||
"Debugger is not available": "偵錯工具不可用",
|
||||
"Debugging": "正在偵錯",
|
||||
|
||||
@@ -1849,6 +1849,10 @@
|
||||
"Debug views": "调试视图",
|
||||
"Debuggable configurations": "可调试的配置",
|
||||
"Debugger": "调试器",
|
||||
"GDB executable": "GDB 可执行文件",
|
||||
"LLDB DAP executable": "LLDB DAP 可执行文件",
|
||||
"Requires GDB 14 or newer. Leave blank for automatic discovery.": "需要 GDB 14 或更高版本。留空则自动查找。",
|
||||
"Leave blank for automatic discovery.": "留空则自动查找。",
|
||||
"Debugger actions": "调试器操作",
|
||||
"Debugger is not available": "调试器不可用",
|
||||
"Debugging": "正在调试",
|
||||
|
||||
@@ -130,6 +130,16 @@ describe("validateWorkflow", () => {
|
||||
expect(validateWorkflow({ debugger: { hotSwapAfterCompile: "invalid" } }).debugger.hotSwapAfterCompile).toBe("ask");
|
||||
});
|
||||
|
||||
it("defaults C/C++ debugger paths to empty and accepts absolute and relative paths", () => {
|
||||
const defaults = { gdbExecutable: "", lldbDapExecutable: "" };
|
||||
expect(validateWorkflow({}).debugger.cpp).toEqual(defaults);
|
||||
expect(
|
||||
validateWorkflow({ debugger: { cpp: { gdbExecutable: 14, lldbDapExecutable: null } } }).debugger.cpp,
|
||||
).toEqual(defaults);
|
||||
const cpp = { gdbExecutable: "tools/gdb-16", lldbDapExecutable: "/opt/LLVM Tools/lldb-dap" };
|
||||
expect(validateWorkflow({ debugger: { cpp } }).debugger.cpp).toEqual(cpp);
|
||||
});
|
||||
|
||||
it("falls back to defaults for missing or malformed values", () => {
|
||||
expect(validateWorkflow(undefined)).toEqual(DEFAULT_WORKFLOW);
|
||||
const v = validateWorkflow({
|
||||
|
||||
@@ -161,6 +161,7 @@ export interface DebuggerSettingsValid {
|
||||
flutterHotReloadOnSave: boolean;
|
||||
hotSwapAfterCompile: HotSwapPolicy;
|
||||
python: { attachSubprocess: boolean; gevent: boolean };
|
||||
cpp: { gdbExecutable: string; lldbDapExecutable: string };
|
||||
}
|
||||
|
||||
export interface RunSettingsValid {
|
||||
@@ -424,6 +425,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
|
||||
debugServerPage: false,
|
||||
flutterHotReloadOnSave: true,
|
||||
hotSwapAfterCompile: "ask",
|
||||
cpp: { gdbExecutable: "", lldbDapExecutable: "" },
|
||||
python: { attachSubprocess: true, gevent: false },
|
||||
},
|
||||
run: {
|
||||
@@ -624,6 +626,7 @@ export function validateDebugger(raw: unknown): DebuggerSettingsValid {
|
||||
const d = DEFAULT_WORKFLOW.debugger;
|
||||
const v = obj(raw);
|
||||
const py = obj(v.python);
|
||||
const cpp = obj(v.cpp);
|
||||
return {
|
||||
showOnBreakpoint: bool(v.showOnBreakpoint, d.showOnBreakpoint),
|
||||
focusAppOnBreakpoint: bool(v.focusAppOnBreakpoint, d.focusAppOnBreakpoint),
|
||||
@@ -645,6 +648,10 @@ export function validateDebugger(raw: unknown): DebuggerSettingsValid {
|
||||
attachSubprocess: bool(py.attachSubprocess, d.python.attachSubprocess),
|
||||
gevent: bool(py.gevent, d.python.gevent),
|
||||
},
|
||||
cpp: {
|
||||
gdbExecutable: text(cpp.gdbExecutable, d.cpp.gdbExecutable),
|
||||
lldbDapExecutable: text(cpp.lldbDapExecutable, d.cpp.lldbDapExecutable),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Заблокувати користувача