Skip to content

Commit

Permalink
Delete unneed R::Offset type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Feb 22, 2019
1 parent b60b3a2 commit eaaf96e
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 92 deletions.
4 changes: 2 additions & 2 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,15 @@ mod cfi {
});
}

fn instrs_len<R: Reader>(fde: &FrameDescriptionEntry<EhFrame<R>, R, R::Offset>) -> usize {
fn instrs_len<R: Reader>(fde: &FrameDescriptionEntry<EhFrame<R>, R>) -> usize {
fde.instructions()
.fold(0, |count, _| count + 1)
.expect("fold over instructions OK")
}

fn get_fde_with_longest_cfi_instructions<R: Reader>(
eh_frame: &EhFrame<R>,
) -> FrameDescriptionEntry<EhFrame<R>, R, R::Offset> {
) -> FrameDescriptionEntry<EhFrame<R>, R> {
let bases = BaseAddresses::default()
.set_eh_frame(0)
.set_got(0)
Expand Down
2 changes: 1 addition & 1 deletion examples/dwarf-validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn validate_info<W, R>(
last_offset = u.offset().0 + u.length_including_self();
units.push(u);
}
let process_unit = |unit: CompilationUnitHeader<R, R::Offset>| -> UnitSummary {
let process_unit = |unit: CompilationUnitHeader<R>| -> UnitSummary {
let mut ret = UnitSummary {
internally_valid: false,
offset: unit.offset(),
Expand Down
4 changes: 2 additions & 2 deletions examples/dwarfdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ where

let units = dwarf.units().collect::<Vec<_>>().unwrap();
let process_unit =
|header: CompilationUnitHeader<R, R::Offset>, buf: &mut Vec<u8>| -> Result<()> {
|header: CompilationUnitHeader<R>, buf: &mut Vec<u8>| -> Result<()> {
writeln!(
buf,
"\nUNIT<header overall offset = 0x{:08x}>:",
Expand Down Expand Up @@ -1310,7 +1310,7 @@ fn dump_exprloc<R: Reader, W: Write>(
fn dump_op<R: Reader, W: Write>(
w: &mut W,
dwop: gimli::DwOp,
op: gimli::Operation<R, R::Offset>,
op: gimli::Operation<R>,
newpc: &R,
) -> Result<()> {
write!(w, "{}", dwop)?;
Expand Down
2 changes: 1 addition & 1 deletion src/read/abbrev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl AttributeSpecification {
///
/// Note that because some attributes are variably sized, the size cannot
/// always be known without parsing, in which case we return `None`.
pub fn size<R: Reader>(&self, header: &UnitHeader<R, R::Offset>) -> Option<usize> {
pub fn size<R: Reader>(&self, header: &UnitHeader<R>) -> Option<usize> {
match self.form {
constants::DW_FORM_addr => Some(header.address_size() as usize),

Expand Down
36 changes: 18 additions & 18 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ impl<'a, R: Reader + 'a> EhHdrTable<'a, R> {
bases: &BaseAddresses,
frame: EhFrame<R>,
cb: F,
) -> Result<FrameDescriptionEntry<EhFrame<R>, R, R::Offset>>
) -> Result<FrameDescriptionEntry<EhFrame<R>, R>>
where
F: FnMut(
EhFrameOffset<R::Offset>,
) -> Result<CommonInformationEntry<EhFrame<R>, R, R::Offset>>,
) -> Result<CommonInformationEntry<EhFrame<R>, R>>,
{
let fdeptr = self.lookup(address, bases)?;
let fdeptr = match fdeptr {
Expand Down Expand Up @@ -534,7 +534,7 @@ pub trait UnwindSection<R: Reader>: Clone + Debug + _UnwindSectionPrivate<R> {
&self,
bases: &'bases BaseAddresses,
offset: Self::Offset,
) -> Result<CommonInformationEntry<Self, R, R::Offset>> {
) -> Result<CommonInformationEntry<Self, R>> {
let offset = UnwindOffset::into(offset);
let input = &mut self.section().clone();
input.skip(offset)?;
Expand Down Expand Up @@ -1012,7 +1012,7 @@ where
Section: UnwindSection<R>,
{
/// This CFI entry is a `CommonInformationEntry`.
Cie(CommonInformationEntry<Section, R, R::Offset>),
Cie(CommonInformationEntry<Section, R>),
/// This CFI entry is a `FrameDescriptionEntry`, however fully parsing it
/// requires parsing its CIE first, so it is left in a partially parsed
/// state.
Expand Down Expand Up @@ -1466,9 +1466,9 @@ where
/// You must provide a function get its associated CIE (either by parsing it
/// on demand, or looking it up in some table mapping offsets to CIEs that
/// you've already parsed, etc.)
pub fn parse<F>(&self, get_cie: F) -> Result<FrameDescriptionEntry<Section, R, R::Offset>>
pub fn parse<F>(&self, get_cie: F) -> Result<FrameDescriptionEntry<Section, R>>
where
F: FnMut(Section::Offset) -> Result<CommonInformationEntry<Section, R, R::Offset>>,
F: FnMut(Section::Offset) -> Result<CommonInformationEntry<Section, R>>,
{
FrameDescriptionEntry::parse_rest(
self.offset,
Expand Down Expand Up @@ -1547,7 +1547,7 @@ where
mut get_cie: F,
) -> Result<FrameDescriptionEntry<Section, R, Offset>>
where
F: FnMut(Section::Offset) -> Result<CommonInformationEntry<Section, R, R::Offset>>,
F: FnMut(Section::Offset) -> Result<CommonInformationEntry<Section, R>>,
{
{
let mut func = bases.eh_frame.func.borrow_mut();
Expand Down Expand Up @@ -1595,7 +1595,7 @@ where

fn parse_addresses(
input: &mut R,
cie: &CommonInformationEntry<Section, R, R::Offset>,
cie: &CommonInformationEntry<Section, R>,
bases: &BaseAddresses,
section: &Section,
) -> Result<(u64, u64)> {
Expand Down Expand Up @@ -1648,7 +1648,7 @@ where
}

/// Get a reference to this FDE's CIE.
pub fn cie(&self) -> &CommonInformationEntry<Section, R, R::Offset> {
pub fn cie(&self) -> &CommonInformationEntry<Section, R> {
&self.cie
}

Expand Down Expand Up @@ -1751,7 +1751,7 @@ where
/// /// Call `f` on each row in the given FDE's unwind table.
/// fn each_unwind_row<F>(
/// &mut self,
/// fde: &gimli::FrameDescriptionEntry<S, R, R::Offset>,
/// fde: &gimli::FrameDescriptionEntry<S, R>,
/// mut f: F,
/// ) -> gimli::Result<()>
/// where
Expand Down Expand Up @@ -1922,7 +1922,7 @@ where
/// `InitializedUnwindContext`.
pub fn initialize(
mut self,
cie: &CommonInformationEntry<Section, R, R::Offset>,
cie: &CommonInformationEntry<Section, R>,
) -> UnwindResult<InitializedUnwindContext<Section, R>, Self> {
self.0.assert_fully_uninitialized();

Expand Down Expand Up @@ -2166,14 +2166,14 @@ where
R: Reader,
Section: UnwindSection<R>,
{
cie: &'cie CommonInformationEntry<Section, R, R::Offset>,
cie: &'cie CommonInformationEntry<Section, R>,
next_start_address: u64,
returned_last_row: bool,
instructions: CallFrameInstructionIter<R>,
ctx: &'ctx mut UnwindContext<Section, R>,
// If this is `None`, then we are executing a CIE's initial_instructions. If
// this is `Some`, then we are executing an FDE's instructions.
fde: Option<&'fde FrameDescriptionEntry<Section, R, R::Offset>>,
fde: Option<&'fde FrameDescriptionEntry<Section, R>>,
}

/// # Signal Safe Methods
Expand All @@ -2189,7 +2189,7 @@ where
/// `FrameDescriptionEntry`'s CFI unwinding program.
pub fn new(
ctx: &'ctx mut InitializedUnwindContext<Section, R>,
fde: &'fde FrameDescriptionEntry<Section, R, R::Offset>,
fde: &'fde FrameDescriptionEntry<Section, R>,
) -> UnwindTable<'fde, 'fde, 'ctx, Section, R> {
assert!(ctx.0.is_initialized);
Self::new_internal(&mut ctx.0, fde.cie(), Some(fde))
Expand All @@ -2207,8 +2207,8 @@ where
{
fn new_internal(
ctx: &'ctx mut UnwindContext<Section, R>,
cie: &'cie CommonInformationEntry<Section, R, R::Offset>,
fde: Option<&'fde FrameDescriptionEntry<Section, R, R::Offset>>,
cie: &'cie CommonInformationEntry<Section, R>,
fde: Option<&'fde FrameDescriptionEntry<Section, R>>,
) -> UnwindTable<'cie, 'fde, 'ctx, Section, R> {
assert!(ctx.stack.len() >= 1);
let next_start_address = fde.map_or(0, |fde| fde.initial_address());
Expand Down Expand Up @@ -3339,12 +3339,12 @@ mod tests {
section: Section,
input: &mut R,
get_cie: F,
) -> Result<FrameDescriptionEntry<Section, R, R::Offset>>
) -> Result<FrameDescriptionEntry<Section, R>>
where
R: Reader,
Section: UnwindSection<R, Offset = O>,
O: UnwindOffset<R::Offset>,
F: FnMut(O) -> Result<CommonInformationEntry<Section, R, R::Offset>>,
F: FnMut(O) -> Result<CommonInformationEntry<Section, R>>,
{
let bases = Default::default();
match parse_cfi_entry(&bases, section, input) {
Expand Down
28 changes: 14 additions & 14 deletions src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<R: Reader> Dwarf<R> {

/// Construct a new `Unit` from the given compilation unit header.
#[inline]
pub fn unit(&self, header: CompilationUnitHeader<R, R::Offset>) -> Result<Unit<R>> {
pub fn unit(&self, header: CompilationUnitHeader<R>) -> Result<Unit<R>> {
Unit::new(self, header)
}

Expand All @@ -78,7 +78,7 @@ impl<R: Reader> Dwarf<R> {

/// Construct a new `Unit` from the given type unit header.
#[inline]
pub fn type_unit(&self, header: TypeUnitHeader<R, R::Offset>) -> Result<Unit<R>> {
pub fn type_unit(&self, header: TypeUnitHeader<R>) -> Result<Unit<R>> {
Unit::new_type_unit(self, header)
}

Expand All @@ -87,15 +87,15 @@ impl<R: Reader> Dwarf<R> {
#[inline]
pub fn abbreviations(
&self,
unit: &CompilationUnitHeader<R, R::Offset>,
unit: &CompilationUnitHeader<R>,
) -> Result<Abbreviations> {
unit.abbreviations(&self.debug_abbrev)
}

/// Parse the abbreviations for a type unit.
// TODO: provide caching of abbreviations
#[inline]
pub fn type_abbreviations(&self, unit: &TypeUnitHeader<R, R::Offset>) -> Result<Abbreviations> {
pub fn type_abbreviations(&self, unit: &TypeUnitHeader<R>) -> Result<Abbreviations> {
unit.abbreviations(&self.debug_abbrev)
}

Expand Down Expand Up @@ -136,7 +136,7 @@ impl<R: Reader> Dwarf<R> {
///
/// then return the attribute's string value. Returns an error if the attribute
/// value does not have a string form, or if a string form has an invalid value.
pub fn attr_string(&self, unit: &Unit<R>, attr: AttributeValue<R, R::Offset>) -> Result<R> {
pub fn attr_string(&self, unit: &Unit<R>, attr: AttributeValue<R>) -> Result<R> {
match attr {
AttributeValue::String(string) => Ok(string),
AttributeValue::DebugStrRef(offset) => self.debug_str.get_str(offset),
Expand Down Expand Up @@ -197,7 +197,7 @@ impl<R: Reader> Dwarf<R> {
pub fn attr_ranges_offset(
&self,
unit: &Unit<R>,
attr: AttributeValue<R, R::Offset>,
attr: AttributeValue<R>,
) -> Result<Option<RangeListsOffset<R::Offset>>> {
match attr {
AttributeValue::RangeListsRef(offset) => Ok(Some(offset)),
Expand All @@ -218,7 +218,7 @@ impl<R: Reader> Dwarf<R> {
pub fn attr_ranges(
&self,
unit: &Unit<R>,
attr: AttributeValue<R, R::Offset>,
attr: AttributeValue<R>,
) -> Result<Option<RngListIter<R>>> {
match self.attr_ranges_offset(unit, attr)? {
Some(offset) => Ok(Some(self.ranges(unit, offset)?)),
Expand Down Expand Up @@ -263,7 +263,7 @@ impl<R: Reader> Dwarf<R> {
pub fn attr_locations_offset(
&self,
unit: &Unit<R>,
attr: AttributeValue<R, R::Offset>,
attr: AttributeValue<R>,
) -> Result<Option<LocationListsOffset<R::Offset>>> {
match attr {
AttributeValue::LocationListsRef(offset) => Ok(Some(offset)),
Expand All @@ -286,7 +286,7 @@ impl<R: Reader> Dwarf<R> {
pub fn attr_locations(
&self,
unit: &Unit<R>,
attr: AttributeValue<R, R::Offset>,
attr: AttributeValue<R>,
) -> Result<Option<LocListIter<R>>> {
match self.attr_locations_offset(unit, attr)? {
Some(offset) => Ok(Some(self.locations(unit, offset)?)),
Expand All @@ -303,7 +303,7 @@ pub struct Unit<R: Reader> {
pub offset: UnitSectionOffset<R::Offset>,

/// The header of the unit.
pub header: UnitHeader<R, R::Offset>,
pub header: UnitHeader<R>,

/// The parsed abbreviations for the unit.
pub abbreviations: Abbreviations,
Expand All @@ -330,13 +330,13 @@ pub struct Unit<R: Reader> {
pub rnglists_base: DebugRngListsBase<R::Offset>,

/// The line number program of the unit.
pub line_program: Option<IncompleteLineProgram<R, R::Offset>>,
pub line_program: Option<IncompleteLineProgram<R>>,
}

impl<R: Reader> Unit<R> {
/// Construct a new `Unit` from the given compilation unit header.
#[inline]
pub fn new(dwarf: &Dwarf<R>, header: CompilationUnitHeader<R, R::Offset>) -> Result<Self> {
pub fn new(dwarf: &Dwarf<R>, header: CompilationUnitHeader<R>) -> Result<Self> {
Self::new_internal(
dwarf,
UnitSectionOffset::DebugInfoOffset(header.offset()),
Expand All @@ -346,7 +346,7 @@ impl<R: Reader> Unit<R> {

/// Construct a new `Unit` from the given type unit header.
#[inline]
pub fn new_type_unit(dwarf: &Dwarf<R>, header: TypeUnitHeader<R, R::Offset>) -> Result<Self> {
pub fn new_type_unit(dwarf: &Dwarf<R>, header: TypeUnitHeader<R>) -> Result<Self> {
Self::new_internal(
dwarf,
UnitSectionOffset::DebugTypesOffset(header.offset()),
Expand All @@ -357,7 +357,7 @@ impl<R: Reader> Unit<R> {
fn new_internal(
dwarf: &Dwarf<R>,
offset: UnitSectionOffset<R::Offset>,
header: UnitHeader<R, R::Offset>,
header: UnitHeader<R>,
) -> Result<Self> {
let abbreviations = header.abbreviations(&dwarf.debug_abbrev)?;
let mut unit = Unit {
Expand Down
Loading

0 comments on commit eaaf96e

Please sign in to comment.