Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

969 enable graceful shutdown with sigint on terminate #1066

Closed
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
19 changes: 19 additions & 0 deletions adapter/codelldb/src/debug_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ impl DebugSession {
RequestArguments::disconnect(args) =>
self.handle_disconnect(args)
.map(|_| ResponseBody::disconnect),
RequestArguments::terminate(args) =>
self.handle_terminate(args)
.map(|_| ResponseBody::terminate),
_ => {
if self.no_debug {
bail!("Not supported in noDebug mode.")
Expand Down Expand Up @@ -582,6 +585,7 @@ impl DebugSession {
supports_completions_request: Some(self.command_completions),
supports_exception_info_request: Some(true),
supports_exception_filter_options: Some(true),
supports_terminate_request: Some(cfg!(unix)),
exception_breakpoint_filters: Some(self.get_exception_filters_for(&self.source_languages)),
..Default::default()
}
Expand Down Expand Up @@ -1156,6 +1160,20 @@ impl DebugSession {
Ok(())
}

fn handle_terminate(&mut self, args: Option<TerminateArguments>) -> Result<(), Error> {
if let Initialized(ref target) = self.target {
let process = target.process();
if process.is_valid() {
let state = process.state();
if state.is_alive() {
process.signal (libc::SIGINT)?;
}
}
}

Ok(())
}

fn handle_disassemble(&mut self, args: DisassembleArguments) -> Result<DisassembleResponseBody, Error> {
fn invalid_instruction() -> DisassembledInstruction {
DisassembledInstruction {
Expand Down Expand Up @@ -1444,6 +1462,7 @@ impl DebugSession {
caps.supports_completions_request = Some(command_completions);
}
}

if let Some(ref source_languages) = settings.source_languages {
if self.source_languages.iter().ne(source_languages) {
self.source_languages = source_languages.to_owned();
Expand Down
5 changes: 5 additions & 0 deletions adapter/codelldb/src/debug_session/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ impl super::DebugSession {

self.print_console_mode();

if cfg!(unix) {
let commands = ["process handle SIGINT -p true -s false".to_string()];
self.exec_commands("SIGINT passthrough for graceful terminate request", &commands)?;
}

if let Some(commands) = &args_common.init_commands {
self.exec_commands("initCommands", &commands)?;
}
Expand Down
6 changes: 6 additions & 0 deletions adapter/lldb/src/sb/sbprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ impl SBProcess {
Err(error)
}
}
pub fn signal(&self, sig: i32) -> Result<(), SBError> {
cpp!(unsafe [self as "SBProcess*", sig as "uint32_t"] -> SBError as "SBError" {
return self->Signal(sig);
})
.into_result()
}
}

impl IsValid for SBProcess {
Expand Down
4 changes: 2 additions & 2 deletions extension/adapterSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AdapterSettingManager {
event.affectsConfiguration('lldb.suppressMissingSourceFiles') ||
event.affectsConfiguration('lldb.evaluationTimeout') ||
event.affectsConfiguration('lldb.consoleMode')) {
this.propagateDisplaySettings();
this.propagateDisplaySettings();
}
}));

Expand Down Expand Up @@ -75,7 +75,7 @@ export class AdapterSettingManager {
terminalPromptClear: config.get('terminalPromptClear'),
evaluateForHovers: config.get('evaluateForHovers'),
commandCompletions: config.get('commandCompletions'),
reproducer: config.get('reproducer'),
reproducer: config.get('reproducer')
};
return settings;
}
Expand Down