-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Use unwinding
crate for unwinding on Xous platform
#117072
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ee870d6
unwind: add support for using `unwinding` crate
xobs 2820317
panic_unwind: support unwinding on xous
xobs 1828cf8
std: personality: support gcc personality on Xous
xobs bf0e0af
compiler: enable unwinding on riscv32imac_unknown_xous_elf
xobs 2a533df
Cargo.lock: add unwinding to lock file
xobs a6b8de6
std: xous: take eh_frame address from main args
xobs 0773afc
tidy: add `unwinding` as an allowed dependency
xobs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#![allow(nonstandard_style)] | ||
|
||
use libc::{c_int, c_void}; | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone, PartialEq)] | ||
pub enum _Unwind_Action { | ||
_UA_SEARCH_PHASE = 1, | ||
_UA_CLEANUP_PHASE = 2, | ||
_UA_HANDLER_FRAME = 4, | ||
_UA_FORCE_UNWIND = 8, | ||
_UA_END_OF_STACK = 16, | ||
} | ||
pub use _Unwind_Action::*; | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone, PartialEq)] | ||
pub enum _Unwind_Reason_Code { | ||
_URC_NO_REASON = 0, | ||
_URC_FOREIGN_EXCEPTION_CAUGHT = 1, | ||
_URC_FATAL_PHASE2_ERROR = 2, | ||
_URC_FATAL_PHASE1_ERROR = 3, | ||
_URC_NORMAL_STOP = 4, | ||
_URC_END_OF_STACK = 5, | ||
_URC_HANDLER_FOUND = 6, | ||
_URC_INSTALL_CONTEXT = 7, | ||
_URC_CONTINUE_UNWIND = 8, | ||
_URC_FAILURE = 9, // used only by ARM EHABI | ||
} | ||
pub use _Unwind_Reason_Code::*; | ||
|
||
pub use unwinding::abi::UnwindContext; | ||
pub use unwinding::abi::UnwindException; | ||
pub enum _Unwind_Context {} | ||
|
||
pub use unwinding::custom_eh_frame_finder::{ | ||
set_custom_eh_frame_finder, EhFrameFinder, FrameInfo, FrameInfoKind, | ||
}; | ||
|
||
pub type _Unwind_Exception_Class = u64; | ||
pub type _Unwind_Word = *const u8; | ||
pub type _Unwind_Ptr = *const u8; | ||
|
||
pub const unwinder_private_data_size: usize = core::mem::size_of::<UnwindException>() | ||
- core::mem::size_of::<_Unwind_Exception_Class>() | ||
- core::mem::size_of::<_Unwind_Exception_Cleanup_Fn>(); | ||
|
||
pub type _Unwind_Exception_Cleanup_Fn = | ||
extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); | ||
|
||
#[repr(C)] | ||
pub struct _Unwind_Exception { | ||
pub exception_class: _Unwind_Exception_Class, | ||
pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, | ||
pub private: [_Unwind_Word; unwinder_private_data_size], | ||
} | ||
|
||
pub unsafe fn _Unwind_GetDataRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_GetDataRelBase(ctx) as _Unwind_Ptr | ||
} | ||
|
||
pub unsafe fn _Unwind_GetTextRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_GetTextRelBase(ctx) as _Unwind_Ptr | ||
} | ||
|
||
pub unsafe fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_GetRegionStart(ctx) as _Unwind_Ptr | ||
} | ||
|
||
pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_SetGR(ctx, reg_index, value as usize) | ||
} | ||
|
||
pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_SetIP(ctx, value as usize) | ||
} | ||
|
||
pub unsafe fn _Unwind_GetIPInfo( | ||
ctx: *mut _Unwind_Context, | ||
ip_before_insn: *mut c_int, | ||
) -> _Unwind_Word { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
let ip_before_insn = unsafe { &mut *(ip_before_insn as *mut c_int) }; | ||
unsafe { &*(unwinding::abi::_Unwind_GetIPInfo(ctx, ip_before_insn) as _Unwind_Word) } | ||
} | ||
|
||
pub unsafe fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void { | ||
let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; | ||
unwinding::abi::_Unwind_GetLanguageSpecificData(ctx) | ||
} | ||
|
||
pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { | ||
let exception = unsafe { &mut *(exception as *mut UnwindException) }; | ||
unsafe { core::mem::transmute(unwinding::abi::_Unwind_RaiseException(exception)) } | ||
} | ||
|
||
pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) { | ||
let exception = unsafe { &mut *(exception as *mut UnwindException) }; | ||
unsafe { unwinding::abi::_Unwind_DeleteException(exception) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these are available from
unwinding::abi
, can this be used instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the callee uses raw pointers, so most of the functions here are casting pointers to references. The calling code could be modified to use references rather than pointers, but I didn't want to touch such fundamental structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine then. But at least change the
pub fn
topub unsafe fn
since they accept raw pointers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've changed the signatures and verified that it still works.