Prevent continueing execution on unreliable stack. (LLVM register save area information is missing)

This commit is contained in:
losfair 2019-08-10 03:10:12 +08:00
parent 2e89f02191
commit d61a8bb6d2
2 changed files with 12 additions and 28 deletions

View File

@ -28,6 +28,7 @@ pub enum ShellExitOperation {
pub struct InteractiveShellContext { pub struct InteractiveShellContext {
pub image: Option<InstanceImage>, pub image: Option<InstanceImage>,
pub patched: bool,
} }
struct OptimizationState { struct OptimizationState {
@ -178,8 +179,6 @@ pub fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
.as_ptr() as usize, .as_ptr() as usize,
}); });
n_versions.set(n_versions.get() + 1); n_versions.set(n_versions.get() + 1);
eprintln!("Patched");
} }
// TODO: Fix this for optimized version. // TODO: Fix this for optimized version.
let breakpoints = baseline.module.runnable_module.get_breakpoints(); let breakpoints = baseline.module.runnable_module.get_breakpoints();
@ -215,6 +214,7 @@ pub fn run_tiering<F: Fn(InteractiveShellContext) -> ShellExitOperation>(
} }
let op = interactive_shell(InteractiveShellContext { let op = interactive_shell(InteractiveShellContext {
image: Some(new_image.clone()), image: Some(new_image.clone()),
patched: n_versions.get() > 1,
}); });
match op { match op {
ShellExitOperation::ContinueWith(new_image) => { ShellExitOperation::ContinueWith(new_image) => {

View File

@ -635,37 +635,21 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation {
} }
} }
"continue" | "c" => { "continue" | "c" => {
if ctx.patched {
println!("Error: Continueing execution is not yet supported on patched code.");
} else {
if let Some(image) = ctx.image.take() { if let Some(image) = ctx.image.take() {
return ShellExitOperation::ContinueWith(image); return ShellExitOperation::ContinueWith(image);
} else { } else {
println!("Program state not available, cannot continue execution"); println!("Program state not available, cannot continue execution");
} }
} }
// Disabled due to unsafety.
/*
"switch_backend" => {
let backend_name = parts.next();
if backend_name.is_none() {
println!("Usage: switch_backend [backend_name]");
continue;
} }
let backend_name = backend_name.unwrap();
let backend = match backend_name {
"singlepass" => Backend::Singlepass,
"llvm" => Backend::LLVM,
_ => {
println!("unknown backend");
continue;
}
};
if let Some(image) = ctx.image.take() {
return ShellExitOperation::ContinueWith(image, Some(backend));
} else {
println!("Program state not available, cannot continue execution");
}
}
*/
"backtrace" | "bt" => { "backtrace" | "bt" => {
if ctx.patched {
println!("Warning: Backtrace on patched code might be inaccurate.");
}
if let Some(ref image) = ctx.image { if let Some(ref image) = ctx.image {
println!("{}", image.execution_state.colored_output()); println!("{}", image.execution_state.colored_output());
} else { } else {