Support DW_CFA_GNU_args_size

This commit is contained in:
Gary Guo 2023-05-07 12:17:05 +01:00
parent dcb6ae6dc1
commit e3cf678839
2 changed files with 13 additions and 6 deletions

View File

@ -125,6 +125,11 @@ impl Frame {
Err(gimli::Error::UnsupportedEvaluation) Err(gimli::Error::UnsupportedEvaluation)
} }
pub fn adjust_stack_for_args(&self, ctx: &mut Context) {
let size = self.row.saved_args_size();
ctx[Arch::SP] = ctx[Arch::SP].wrapping_add(size as usize);
}
pub fn unwind(&self, ctx: &Context) -> Result<Context, gimli::Error> { pub fn unwind(&self, ctx: &Context) -> Result<Context, gimli::Error> {
let row = &self.row; let row = &self.row;
let mut new_ctx = ctx.clone(); let mut new_ctx = ctx.clone();

View File

@ -229,7 +229,10 @@ fn raise_exception_phase2(
match code { match code {
UnwindReasonCode::CONTINUE_UNWIND => (), UnwindReasonCode::CONTINUE_UNWIND => (),
UnwindReasonCode::INSTALL_CONTEXT => break, UnwindReasonCode::INSTALL_CONTEXT => {
frame.adjust_stack_for_args(ctx);
return UnwindReasonCode::INSTALL_CONTEXT;
}
_ => return UnwindReasonCode::FATAL_PHASE2_ERROR, _ => return UnwindReasonCode::FATAL_PHASE2_ERROR,
} }
} }
@ -240,8 +243,6 @@ fn raise_exception_phase2(
return UnwindReasonCode::FATAL_PHASE2_ERROR; return UnwindReasonCode::FATAL_PHASE2_ERROR;
} }
} }
UnwindReasonCode::INSTALL_CONTEXT
} }
#[inline(never)] #[inline(never)]
@ -312,7 +313,10 @@ fn force_unwind_phase2(
match code { match code {
UnwindReasonCode::CONTINUE_UNWIND => (), UnwindReasonCode::CONTINUE_UNWIND => (),
UnwindReasonCode::INSTALL_CONTEXT => break, UnwindReasonCode::INSTALL_CONTEXT => {
frame.adjust_stack_for_args(ctx);
return UnwindReasonCode::INSTALL_CONTEXT;
}
_ => return UnwindReasonCode::FATAL_PHASE2_ERROR, _ => return UnwindReasonCode::FATAL_PHASE2_ERROR,
} }
} }
@ -323,8 +327,6 @@ fn force_unwind_phase2(
return UnwindReasonCode::END_OF_STACK; return UnwindReasonCode::END_OF_STACK;
} }
} }
UnwindReasonCode::INSTALL_CONTEXT
} }
#[inline(never)] #[inline(never)]