support a few DWARF-5 only features (#1410)
Support a few DWARF-5 only features: * read .debug_addr * read .debug_rnglists * read .debug_loclists when present * add dwarf-5 test * read .debug_addr * read .debug_rnglists * read .debug_loclists when present * support .debug_line_str and .debug_str_offsets Co-authored-by: Yury Delendik <ydelendik@mozilla.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use super::address_transform::AddressTransform;
|
||||
use super::{DebugInputContext, Reader};
|
||||
use anyhow::Error;
|
||||
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset};
|
||||
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset, Unit};
|
||||
use more_asserts::assert_lt;
|
||||
use wasmtime_environ::entity::EntityRef;
|
||||
use wasmtime_environ::wasm::DefinedFuncIndex;
|
||||
@@ -15,21 +15,25 @@ pub(crate) enum RangeInfoBuilder {
|
||||
|
||||
impl RangeInfoBuilder {
|
||||
pub(crate) fn from<R>(
|
||||
unit: &Unit<R, R::Offset>,
|
||||
entry: &DebuggingInformationEntry<R>,
|
||||
context: &DebugInputContext<R>,
|
||||
unit_encoding: gimli::Encoding,
|
||||
cu_low_pc: u64,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
R: Reader,
|
||||
{
|
||||
if let Some(AttributeValue::RangeListsRef(r)) = entry.attr_value(gimli::DW_AT_ranges)? {
|
||||
return RangeInfoBuilder::from_ranges_ref(r, context, unit_encoding, cu_low_pc);
|
||||
return RangeInfoBuilder::from_ranges_ref(unit, r, context, cu_low_pc);
|
||||
};
|
||||
|
||||
let low_pc =
|
||||
if let Some(AttributeValue::Addr(addr)) = entry.attr_value(gimli::DW_AT_low_pc)? {
|
||||
addr
|
||||
} else if let Some(AttributeValue::DebugAddrIndex(i)) =
|
||||
entry.attr_value(gimli::DW_AT_low_pc)?
|
||||
{
|
||||
context.debug_addr.get_address(4, unit.addr_base, i)?
|
||||
} else {
|
||||
return Ok(RangeInfoBuilder::Undefined);
|
||||
};
|
||||
@@ -44,20 +48,21 @@ impl RangeInfoBuilder {
|
||||
}
|
||||
|
||||
pub(crate) fn from_ranges_ref<R>(
|
||||
unit: &Unit<R, R::Offset>,
|
||||
ranges: RangeListsOffset,
|
||||
context: &DebugInputContext<R>,
|
||||
unit_encoding: gimli::Encoding,
|
||||
cu_low_pc: u64,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
R: Reader,
|
||||
{
|
||||
let unit_encoding = unit.encoding();
|
||||
let mut ranges = context.rnglists.ranges(
|
||||
ranges,
|
||||
unit_encoding,
|
||||
cu_low_pc,
|
||||
&context.debug_addr,
|
||||
context.debug_addr_base,
|
||||
unit.addr_base,
|
||||
)?;
|
||||
let mut result = Vec::new();
|
||||
while let Some(range) = ranges.next()? {
|
||||
@@ -75,18 +80,23 @@ impl RangeInfoBuilder {
|
||||
}
|
||||
|
||||
pub(crate) fn from_subprogram_die<R>(
|
||||
unit: &Unit<R, R::Offset>,
|
||||
entry: &DebuggingInformationEntry<R>,
|
||||
context: &DebugInputContext<R>,
|
||||
unit_encoding: gimli::Encoding,
|
||||
addr_tr: &AddressTransform,
|
||||
cu_low_pc: u64,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
R: Reader,
|
||||
{
|
||||
let unit_encoding = unit.encoding();
|
||||
let addr =
|
||||
if let Some(AttributeValue::Addr(addr)) = entry.attr_value(gimli::DW_AT_low_pc)? {
|
||||
addr
|
||||
} else if let Some(AttributeValue::DebugAddrIndex(i)) =
|
||||
entry.attr_value(gimli::DW_AT_low_pc)?
|
||||
{
|
||||
context.debug_addr.get_address(4, unit.addr_base, i)?
|
||||
} else if let Some(AttributeValue::RangeListsRef(r)) =
|
||||
entry.attr_value(gimli::DW_AT_ranges)?
|
||||
{
|
||||
@@ -95,7 +105,7 @@ impl RangeInfoBuilder {
|
||||
unit_encoding,
|
||||
cu_low_pc,
|
||||
&context.debug_addr,
|
||||
context.debug_addr_base,
|
||||
unit.addr_base,
|
||||
)?;
|
||||
if let Some(range) = ranges.next()? {
|
||||
range.begin
|
||||
|
||||
Reference in New Issue
Block a user