debugger: Add args argument to debugger launch config (#27953)
This also fixes a bug where debug cargo test code actions would debug all tests in a mod instead of a specific test Release Notes: - N/A
This commit is contained in:
parent
500964a6fa
commit
108ae0b5b0
15 changed files with 42 additions and 17 deletions
|
@ -79,7 +79,7 @@ impl DebugAdapter for GdbDebugAdapter {
|
||||||
json!({"pid": attach_config.process_id})
|
json!({"pid": attach_config.process_id})
|
||||||
}
|
}
|
||||||
dap::DebugRequestType::Launch(launch_config) => {
|
dap::DebugRequestType::Launch(launch_config) => {
|
||||||
json!({"program": launch_config.program, "cwd": launch_config.cwd, "stopOnEntry": config.stop_on_entry})
|
json!({"program": launch_config.program, "cwd": launch_config.cwd, "stopOnEntry": config.stop_on_entry, "args": launch_config.args.clone()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ impl DebugAdapter for GoDebugAdapter {
|
||||||
"program": launch_config.program,
|
"program": launch_config.program,
|
||||||
"cwd": launch_config.cwd,
|
"cwd": launch_config.cwd,
|
||||||
"stopOnEntry": config.stop_on_entry,
|
"stopOnEntry": config.stop_on_entry,
|
||||||
|
"args": launch_config.args
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ impl DebugAdapter for JsDebugAdapter {
|
||||||
}
|
}
|
||||||
DebugRequestType::Launch(launch) => {
|
DebugRequestType::Launch(launch) => {
|
||||||
map.insert("program".into(), launch.program.clone().into());
|
map.insert("program".into(), launch.program.clone().into());
|
||||||
|
map.insert("args".into(), launch.args.clone().into());
|
||||||
map.insert(
|
map.insert(
|
||||||
"cwd".into(),
|
"cwd".into(),
|
||||||
launch
|
launch
|
||||||
|
|
|
@ -82,6 +82,7 @@ impl DebugAdapter for LldbDebugAdapter {
|
||||||
}
|
}
|
||||||
DebugRequestType::Launch(launch) => {
|
DebugRequestType::Launch(launch) => {
|
||||||
map.insert("program".into(), launch.program.clone().into());
|
map.insert("program".into(), launch.program.clone().into());
|
||||||
|
map.insert("args".into(), launch.args.clone().into());
|
||||||
map.insert(
|
map.insert(
|
||||||
"cwd".into(),
|
"cwd".into(),
|
||||||
launch
|
launch
|
||||||
|
|
|
@ -118,6 +118,7 @@ impl DebugAdapter for PhpDebugAdapter {
|
||||||
json!({
|
json!({
|
||||||
"program": launch_config.program,
|
"program": launch_config.program,
|
||||||
"cwd": launch_config.cwd,
|
"cwd": launch_config.cwd,
|
||||||
|
"args": launch_config.args,
|
||||||
"stopOnEntry": config.stop_on_entry,
|
"stopOnEntry": config.stop_on_entry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ impl DebugAdapter for PythonDebugAdapter {
|
||||||
DebugRequestType::Launch(launch_config) => {
|
DebugRequestType::Launch(launch_config) => {
|
||||||
json!({
|
json!({
|
||||||
"program": launch_config.program,
|
"program": launch_config.program,
|
||||||
|
"args": launch_config.args,
|
||||||
"subProcess": true,
|
"subProcess": true,
|
||||||
"cwd": launch_config.cwd,
|
"cwd": launch_config.cwd,
|
||||||
"redirectOutput": true,
|
"redirectOutput": true,
|
||||||
|
|
|
@ -156,10 +156,10 @@ impl Render for InertState {
|
||||||
request: DebugRequestType::Launch(LaunchConfig {
|
request: DebugRequestType::Launch(LaunchConfig {
|
||||||
program,
|
program,
|
||||||
cwd: Some(cwd),
|
cwd: Some(cwd),
|
||||||
|
args: Default::default(),
|
||||||
}),
|
}),
|
||||||
tcp_connection: Some(TCPHost::default()),
|
tcp_connection: Some(TCPHost::default()),
|
||||||
initialize_args: None,
|
initialize_args: None,
|
||||||
args: Default::default(),
|
|
||||||
locator: None,
|
locator: None,
|
||||||
stop_on_entry: None,
|
stop_on_entry: None,
|
||||||
},
|
},
|
||||||
|
@ -322,7 +322,6 @@ impl InertState {
|
||||||
adapter: kind,
|
adapter: kind,
|
||||||
request: DebugRequestType::Attach(task::AttachConfig { process_id: None }),
|
request: DebugRequestType::Attach(task::AttachConfig { process_id: None }),
|
||||||
initialize_args: None,
|
initialize_args: None,
|
||||||
args: Default::default(),
|
|
||||||
locator: None,
|
locator: None,
|
||||||
tcp_connection: Some(TCPHost::default()),
|
tcp_connection: Some(TCPHost::default()),
|
||||||
stop_on_entry: None,
|
stop_on_entry: None,
|
||||||
|
|
|
@ -91,7 +91,6 @@ async fn test_show_attach_modal_and_select_process(
|
||||||
tcp_connection: Some(TCPHost::default()),
|
tcp_connection: Some(TCPHost::default()),
|
||||||
locator: None,
|
locator: None,
|
||||||
stop_on_entry: None,
|
stop_on_entry: None,
|
||||||
args: Default::default(),
|
|
||||||
},
|
},
|
||||||
vec![
|
vec![
|
||||||
Candidate {
|
Candidate {
|
||||||
|
|
|
@ -729,7 +729,12 @@ impl ContextProvider for RustContextProvider {
|
||||||
..TaskTemplate::default()
|
..TaskTemplate::default()
|
||||||
},
|
},
|
||||||
TaskTemplate {
|
TaskTemplate {
|
||||||
label: "Debug".into(),
|
label: format!(
|
||||||
|
"Debug {} {} (package: {})",
|
||||||
|
RUST_BIN_KIND_TASK_VARIABLE.template_value(),
|
||||||
|
RUST_BIN_NAME_TASK_VARIABLE.template_value(),
|
||||||
|
RUST_PACKAGE_TASK_VARIABLE.template_value(),
|
||||||
|
),
|
||||||
cwd: Some("$ZED_DIRNAME".to_owned()),
|
cwd: Some("$ZED_DIRNAME".to_owned()),
|
||||||
command: "cargo".into(),
|
command: "cargo".into(),
|
||||||
task_type: TaskType::Debug(task::DebugArgs {
|
task_type: TaskType::Debug(task::DebugArgs {
|
||||||
|
|
|
@ -471,7 +471,6 @@ impl DapStore {
|
||||||
initialize_args: config.initialize_args.clone(),
|
initialize_args: config.initialize_args.clone(),
|
||||||
tcp_connection: config.tcp_connection.clone(),
|
tcp_connection: config.tcp_connection.clone(),
|
||||||
locator: None,
|
locator: None,
|
||||||
args: Default::default(),
|
|
||||||
stop_on_entry: config.stop_on_entry,
|
stop_on_entry: config.stop_on_entry,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl DapLocator for CargoLocator {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut child = Command::new("cargo")
|
let mut child = Command::new("cargo")
|
||||||
.args(&debug_config.args)
|
.args(&launch_config.args)
|
||||||
.arg("--message-format=json")
|
.arg("--message-format=json")
|
||||||
.current_dir(cwd)
|
.current_dir(cwd)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -59,7 +59,30 @@ impl DapLocator for CargoLocator {
|
||||||
};
|
};
|
||||||
|
|
||||||
launch_config.program = executable;
|
launch_config.program = executable;
|
||||||
debug_config.args.clear();
|
let mut test_name = None;
|
||||||
|
|
||||||
|
if launch_config
|
||||||
|
.args
|
||||||
|
.first()
|
||||||
|
.map_or(false, |arg| arg == "test")
|
||||||
|
{
|
||||||
|
if let Some(package_index) = launch_config
|
||||||
|
.args
|
||||||
|
.iter()
|
||||||
|
.position(|arg| arg == "-p" || arg == "--package")
|
||||||
|
{
|
||||||
|
test_name = launch_config
|
||||||
|
.args
|
||||||
|
.get(package_index + 2)
|
||||||
|
.filter(|name| !name.starts_with("--"))
|
||||||
|
.cloned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
launch_config.args.clear();
|
||||||
|
if let Some(test_name) = test_name {
|
||||||
|
launch_config.args.push(test_name);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,7 @@ impl LocalMode {
|
||||||
DebugRequestType::Launch(task::LaunchConfig {
|
DebugRequestType::Launch(task::LaunchConfig {
|
||||||
program: "".to_owned(),
|
program: "".to_owned(),
|
||||||
cwd: None,
|
cwd: None,
|
||||||
|
args: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
dap::StartDebuggingRequestArgumentsRequest::Attach => {
|
dap::StartDebuggingRequestArgumentsRequest::Attach => {
|
||||||
|
|
|
@ -1489,7 +1489,6 @@ impl Project {
|
||||||
initialize_args: None,
|
initialize_args: None,
|
||||||
tcp_connection: None,
|
tcp_connection: None,
|
||||||
locator: None,
|
locator: None,
|
||||||
args: Default::default(),
|
|
||||||
stop_on_entry: None,
|
stop_on_entry: None,
|
||||||
};
|
};
|
||||||
let caps = caps.unwrap_or(Capabilities {
|
let caps = caps.unwrap_or(Capabilities {
|
||||||
|
|
|
@ -52,6 +52,8 @@ pub struct LaunchConfig {
|
||||||
pub program: String,
|
pub program: String,
|
||||||
/// The current working directory of your project
|
/// The current working directory of your project
|
||||||
pub cwd: Option<PathBuf>,
|
pub cwd: Option<PathBuf>,
|
||||||
|
/// Args to pass to a debuggee
|
||||||
|
pub args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the type that will determine which request to call on the debug adapter
|
/// Represents the type that will determine which request to call on the debug adapter
|
||||||
|
@ -104,8 +106,6 @@ pub struct DebugAdapterConfig {
|
||||||
pub tcp_connection: Option<TCPHost>,
|
pub tcp_connection: Option<TCPHost>,
|
||||||
/// What Locator to use to configure the debug task
|
/// What Locator to use to configure the debug task
|
||||||
pub locator: Option<String>,
|
pub locator: Option<String>,
|
||||||
/// Args to pass to a debug adapter (only used in locator right now)
|
|
||||||
pub args: Vec<String>,
|
|
||||||
/// Whether to tell the debug adapter to stop on entry
|
/// Whether to tell the debug adapter to stop on entry
|
||||||
pub stop_on_entry: Option<bool>,
|
pub stop_on_entry: Option<bool>,
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ impl From<DebugTaskDefinition> for DebugAdapterConfig {
|
||||||
initialize_args: def.initialize_args,
|
initialize_args: def.initialize_args,
|
||||||
tcp_connection: def.tcp_connection,
|
tcp_connection: def.tcp_connection,
|
||||||
locator: def.locator,
|
locator: def.locator,
|
||||||
args: def.args,
|
|
||||||
stop_on_entry: def.stop_on_entry,
|
stop_on_entry: def.stop_on_entry,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +139,6 @@ impl TryFrom<DebugAdapterConfig> for DebugTaskDefinition {
|
||||||
initialize_args: def.initialize_args,
|
initialize_args: def.initialize_args,
|
||||||
tcp_connection: def.tcp_connection,
|
tcp_connection: def.tcp_connection,
|
||||||
locator: def.locator,
|
locator: def.locator,
|
||||||
args: def.args,
|
|
||||||
stop_on_entry: def.stop_on_entry,
|
stop_on_entry: def.stop_on_entry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -217,9 +215,6 @@ pub struct DebugTaskDefinition {
|
||||||
/// Locator to use
|
/// Locator to use
|
||||||
/// -- cargo
|
/// -- cargo
|
||||||
pub locator: Option<String>,
|
pub locator: Option<String>,
|
||||||
/// Args to pass to a debug adapter (only used in locator right now)
|
|
||||||
#[serde(skip)]
|
|
||||||
pub args: Vec<String>,
|
|
||||||
/// Whether to tell the debug adapter to stop on entry
|
/// Whether to tell the debug adapter to stop on entry
|
||||||
pub stop_on_entry: Option<bool>,
|
pub stop_on_entry: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,7 @@ impl ResolvedTask {
|
||||||
DebugRequestType::Launch(LaunchConfig {
|
DebugRequestType::Launch(LaunchConfig {
|
||||||
program: resolved.command.clone(),
|
program: resolved.command.clone(),
|
||||||
cwd: resolved.cwd.clone(),
|
cwd: resolved.cwd.clone(),
|
||||||
|
args,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
crate::task_template::DebugArgsRequest::Attach(attach_config) => {
|
crate::task_template::DebugArgsRequest::Attach(attach_config) => {
|
||||||
|
@ -142,7 +143,6 @@ impl ResolvedTask {
|
||||||
}),
|
}),
|
||||||
initialize_args: debug_args.initialize_args,
|
initialize_args: debug_args.initialize_args,
|
||||||
tcp_connection: debug_args.tcp_connection,
|
tcp_connection: debug_args.tcp_connection,
|
||||||
args,
|
|
||||||
locator: debug_args.locator.clone(),
|
locator: debug_args.locator.clone(),
|
||||||
stop_on_entry: debug_args.stop_on_entry,
|
stop_on_entry: debug_args.stop_on_entry,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue