Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ toml = "0.8"
dirs = "5.0"
object = "0.36"

gimli = "0.31.1"
gimli = "0.33.0"
aya = "0.13.1"
aya-obj = "0.2.1"
aya-ebpf-bindings = "0.1.1"
Expand Down
32 changes: 16 additions & 16 deletions ghostscope-dwarf/src/data/block_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ impl<'a> BlockIndexBuilder<'a> {

/// Build functions for a single CU offset
pub fn build_for_unit(&self, cu_offset: gimli::DebugInfoOffset) -> Option<Vec<FunctionBlocks>> {
let header = self.dwarf.debug_info.header_from_offset(cu_offset).ok()?;
let header = self.dwarf.unit_header(cu_offset).ok()?;
let unit = self.dwarf.unit(header).ok()?;
let mut entries = unit.entries();
let mut out: Vec<FunctionBlocks> = Vec::new();
while let Ok(Some((_depth, entry))) = entries.next_dfs() {
while let Ok(Some(entry)) = entries.next_dfs() {
if entry.tag() == gimli::constants::DW_TAG_subprogram {
let mut fb = FunctionBlocks::new(cu_offset, entry.offset());
if let Ok(ranges) = RangeExtractor::extract_all_ranges(entry, &unit, self.dwarf) {
Expand All @@ -232,7 +232,7 @@ impl<'a> BlockIndexBuilder<'a> {
cu_offset: gimli::DebugInfoOffset,
die_offset: gimli::UnitOffset,
) -> Option<FunctionBlocks> {
let header = self.dwarf.debug_info.header_from_offset(cu_offset).ok()?;
let header = self.dwarf.unit_header(cu_offset).ok()?;
let unit = self.dwarf.unit(header).ok()?;
let entry = unit.entry(die_offset).ok()?;
if entry.tag() != gimli::constants::DW_TAG_subprogram {
Expand Down Expand Up @@ -282,8 +282,8 @@ impl<'a> BlockIndexBuilder<'a> {
gimli::constants::DW_TAG_formal_parameter | gimli::constants::DW_TAG_variable => {
// Only record DIE offsets; evaluation happens on demand
let v = VarRef {
cu_offset: match unit.header.offset() {
gimli::UnitSectionOffset::DebugInfoOffset(off) => off,
cu_offset: match unit.header.debug_info_offset() {
Some(off) => off,
_ => continue,
},
die_offset: e.offset(),
Expand All @@ -296,7 +296,7 @@ impl<'a> BlockIndexBuilder<'a> {
if let Ok(ranges) = RangeExtractor::extract_all_ranges(e, unit, self.dwarf) {
bn.ranges = ranges;
}
if let Ok(Some(a)) = e.attr(gimli::constants::DW_AT_entry_pc) {
if let Some(a) = e.attr(gimli::constants::DW_AT_entry_pc) {
if let gimli::AttributeValue::Addr(addr) = a.value() {
bn.entry_pc = Some(addr);
}
Expand All @@ -315,11 +315,11 @@ impl<'a> BlockIndexBuilder<'a> {
if let Ok(mut it) = unit.entries_at_offset(e.offset()) {
// skip self
let _ = it.next_entry();
while let Ok(Some((depth, ce))) = it.next_dfs() {
if depth == 0 {
while let Ok(Some(ce)) = it.next_dfs() {
if ce.depth() <= 0 {
break;
}
if depth > 1 {
if ce.depth() > 1 {
continue;
}
if ce.tag() == gimli::constants::DW_TAG_formal_parameter {
Expand All @@ -329,25 +329,25 @@ impl<'a> BlockIndexBuilder<'a> {
}
}
if !has_inline_params {
if let Ok(Some(attr)) = e.attr(gimli::constants::DW_AT_abstract_origin)
{
if let Some(attr) = e.attr(gimli::constants::DW_AT_abstract_origin) {
if let gimli::AttributeValue::UnitRef(origin_off) = attr.value() {
if let Ok(mut iter) = unit.entries_at_offset(origin_off) {
// Skip the origin DIE itself
let _ = iter.next_entry();
while let Ok(Some((depth, ce))) = iter.next_dfs() {
while let Ok(Some(ce)) = iter.next_dfs() {
// Only consider direct children of the origin DIE
if depth == 0 {
if ce.depth() <= 0 {
break;
}
if depth > 1 {
if ce.depth() > 1 {
continue;
}
if ce.tag() == gimli::constants::DW_TAG_formal_parameter
{
let v = VarRef {
cu_offset: match unit.header.offset() {
gimli::UnitSectionOffset::DebugInfoOffset(off) => off,
cu_offset: match unit.header.debug_info_offset()
{
Some(off) => off,
_ => continue,
},
die_offset: ce.offset(),
Expand Down
61 changes: 27 additions & 34 deletions ghostscope-dwarf/src/data/on_demand_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl OnDemandResolver {
chain.base,
chain.fields.len()
);
let header = self.dwarf.debug_info.header_from_offset(cu_offset)?;
let header = self.dwarf.unit_header(cu_offset)?;
let unit = self.dwarf.unit(header)?;
let var_entry = unit.entry(var_die)?;

Expand Down Expand Up @@ -110,7 +110,7 @@ impl OnDemandResolver {

let t2 = std::time::Instant::now();
let (fe, ftl, pctx) = planner.plan_chain_from_known(
cu_offset.into(),
cu_offset,
type_die_off,
current_eval,
chain.fields,
Expand All @@ -129,18 +129,13 @@ impl OnDemandResolver {
if let Some(ftl) = final_type_loc {
let t3 = std::time::Instant::now();
// Base: shallow resolve the resulting DIE's type
let mut shallow_final = match ftl.cu_off {
gimli::UnitSectionOffset::DebugInfoOffset(off) => {
let h = self.dwarf.debug_info.header_from_offset(off)?;
let u = self.dwarf.unit(h)?;
crate::parser::DetailedParser::resolve_type_shallow_at_offset(
&self.dwarf,
&u,
ftl.die_off,
)
}
gimli::UnitSectionOffset::DebugTypesOffset(_off) => None,
};
let h = self.dwarf.unit_header(ftl.cu_off)?;
let u = self.dwarf.unit(h)?;
let mut shallow_final = crate::parser::DetailedParser::resolve_type_shallow_at_offset(
&self.dwarf,
&u,
ftl.die_off,
);
tracing::info!(
"DWARF:plan_from_var final_type_ms={}",
t3.elapsed().as_millis()
Expand All @@ -149,25 +144,23 @@ impl OnDemandResolver {
// Minimal parent enrichment: if planner provided parent member context,
// use parent's shallow members to capture bitfield wrapper and accurate member type.
if let Some(ctx) = parent_ctx {
if let gimli::UnitSectionOffset::DebugInfoOffset(pcu) = ctx.parent_cu_off {
let h = self.dwarf.debug_info.header_from_offset(pcu)?;
let u = self.dwarf.unit(h)?;
if let Some(
crate::TypeInfo::StructType { members, .. }
| crate::TypeInfo::UnionType { members, .. },
) = crate::parser::DetailedParser::resolve_type_shallow_at_offset(
&self.dwarf,
&u,
ctx.parent_die_off,
) {
if let Some(m) = members.iter().find(|m| m.name == ctx.member_name) {
tracing::info!(
"DWARF:parent_enrich member='{}' uses BitfieldType={}",
ctx.member_name,
matches!(m.member_type, crate::TypeInfo::BitfieldType { .. })
);
shallow_final = Some(m.member_type.clone());
}
let h = self.dwarf.unit_header(ctx.parent_cu_off)?;
let u = self.dwarf.unit(h)?;
if let Some(
crate::TypeInfo::StructType { members, .. }
| crate::TypeInfo::UnionType { members, .. },
) = crate::parser::DetailedParser::resolve_type_shallow_at_offset(
&self.dwarf,
&u,
ctx.parent_die_off,
) {
if let Some(m) = members.iter().find(|m| m.name == ctx.member_name) {
tracing::info!(
"DWARF:parent_enrich member='{}' uses BitfieldType={}",
ctx.member_name,
matches!(m.member_type, crate::TypeInfo::BitfieldType { .. })
);
shallow_final = Some(m.member_type.clone());
}
}
}
Expand Down Expand Up @@ -209,7 +202,7 @@ impl OnDemandResolver {
) -> Result<Vec<VariableWithEvaluation>> {
let mut vars = Vec::with_capacity(items.len());
for (cu_off, die_off) in items.iter().cloned() {
let header = self.dwarf.debug_info.header_from_offset(cu_off)?;
let header = self.dwarf.unit_header(cu_off)?;
let unit = self.dwarf.unit(header)?;
let entry = unit.entry(die_off)?;
if let Some(v) = self.detailed_parser.parse_variable_entry_with_mode(
Expand Down
Loading
Loading