-
Notifications
You must be signed in to change notification settings - Fork 108
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
Implement writing of .debug_info, .debug_abbrev and .debug_str #340
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/// Whether the format of a compilation unit is 32- or 64-bit. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub enum Format { | ||
/// 64-bit DWARF | ||
Dwarf64, | ||
/// 32-bit DWARF | ||
Dwarf32, | ||
} | ||
|
||
impl Format { | ||
/// Return the serialized size of an initial length field for the format. | ||
#[inline] | ||
pub fn initial_length_size(self) -> u8 { | ||
match self { | ||
Format::Dwarf32 => 4, | ||
Format::Dwarf64 => 12, | ||
} | ||
} | ||
|
||
/// Return the natural word size for the format | ||
#[inline] | ||
pub fn word_size(self) -> u8 { | ||
match self { | ||
Format::Dwarf32 => 4, | ||
Format::Dwarf64 => 8, | ||
} | ||
} | ||
} | ||
|
||
/// A DWARF register number. | ||
/// | ||
/// The meaning of this value is ABI dependent. This is generally encoded as | ||
/// a ULEB128, but supported architectures need 16 bits at most. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
pub struct Register(pub u16); | ||
|
||
/// An offset into the `.debug_abbrev` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct DebugAbbrevOffset<T = usize>(pub T); | ||
|
||
/// An offset into the `.debug_info` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)] | ||
pub struct DebugInfoOffset<T = usize>(pub T); | ||
|
||
/// An offset into the `.debug_line` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub struct DebugLineOffset<T = usize>(pub T); | ||
|
||
/// An offset into either the `.debug_loc` section or the `.debug_loclists` section, | ||
/// depending on the version of the unit the offset was contained in. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct LocationListsOffset<T = usize>(pub T); | ||
|
||
/// An offset into the `.debug_macinfo` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct DebugMacinfoOffset<T = usize>(pub T); | ||
|
||
/// An offset into either the `.debug_ranges` section or the `.debug_rnglists` section, | ||
/// depending on the version of the unit the offset was contained in. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct RangeListsOffset<T = usize>(pub T); | ||
|
||
/// An offset into the `.debug_str` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub struct DebugStrOffset<T = usize>(pub T); | ||
|
||
/// An offset into the `.debug_types` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct DebugTypesOffset<T = usize>(pub T); | ||
|
||
/// A type signature as used in the `.debug_types` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct DebugTypeSignature(pub u64); | ||
|
||
/// An offset into the `.debug_frame` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct DebugFrameOffset<T = usize>(pub T); | ||
|
||
impl<T> From<T> for DebugFrameOffset<T> { | ||
#[inline] | ||
fn from(o: T) -> Self { | ||
DebugFrameOffset(o) | ||
} | ||
} | ||
|
||
/// An offset into the `.eh_frame` section. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub struct EhFrameOffset<T = usize>(pub T); | ||
|
||
impl<T> From<T> for EhFrameOffset<T> { | ||
#[inline] | ||
fn from(o: T) -> Self { | ||
EhFrameOffset(o) | ||
} | ||
} |
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
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.
I think it is worth having two traits:
read
andwrite
that enable their corresponding modules. This way, compilers that are emitting DWARF don't need to pay compile time for DWARF reading, and a stack unwinder doesn't need to pay compile time for DWARF writing.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'll do this in a follow up PR.