-
Notifications
You must be signed in to change notification settings - Fork 248
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
Printing backtrace ip for x86_64-fortanix-unknown-sgx #268
Open
jethrogb
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
jethrogb:jb/fix_x86_64-fortanix-unknown-sgx
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,8 @@ impl BacktraceFrameFmt<'_, '_, '_> { | |
filename: Option<BytesOrWideString>, | ||
lineno: Option<u32>, | ||
) -> fmt::Result { | ||
let mut print_frame_ip = PrintFmt::Full == self.fmt.format; | ||
|
||
// No need to print "null" frames, it basically just means that the | ||
// system backtrace was a bit eager to trace back super far. | ||
if let PrintFmt::Short = self.fmt.format { | ||
|
@@ -196,30 +198,32 @@ impl BacktraceFrameFmt<'_, '_, '_> { | |
// To reduce TCB size in Sgx enclave, we do not want to implement symbol | ||
// resolution functionality. Rather, we can print the offset of the | ||
// address here, which could be later mapped to correct function. | ||
#[cfg(all(feature = "std", target_env = "sgx", target_vendor = "fortanix"))] | ||
#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] | ||
{ | ||
let image_base = std::os::fortanix_sgx::mem::image_base(); | ||
frame_ip = usize::wrapping_sub(frame_ip as usize, image_base as _) as _; | ||
print_frame_ip = true; | ||
} | ||
|
||
// Print the index of the frame as well as the optional instruction | ||
// pointer of the frame. If we're beyond the first symbol of this frame | ||
// though we just print appropriate whitespace. | ||
if self.symbol_index == 0 { | ||
write!(self.fmt.fmt, "{:4}: ", self.fmt.frame_index)?; | ||
if let PrintFmt::Full = self.fmt.format { | ||
if print_frame_ip { | ||
write!(self.fmt.fmt, "{:1$?} - ", frame_ip, HEX_WIDTH)?; | ||
} | ||
} else { | ||
write!(self.fmt.fmt, " ")?; | ||
if let PrintFmt::Full = self.fmt.format { | ||
if print_frame_ip { | ||
write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH + 3)?; | ||
} | ||
} | ||
|
||
// Next up write out the symbol name, using the alternate formatting for | ||
// more information if we're a full backtrace. Here we also handle | ||
// symbols which don't have a name, | ||
#[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this use an |
||
match (symbol_name, &self.fmt.format) { | ||
(Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{:#}", name)?, | ||
(Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{}", name)?, | ||
|
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.
I think the removal of this
feature
directive will break this building when included into libstd?