Skip to content

Conversation

@philipc
Copy link
Collaborator

@philipc philipc commented Dec 18, 2025

Adds sample implementation to dwarfdump that prints the same information as llvm-dwarfdump.

Adds sample implementation to dwarfdump that prints the same
information as llvm-dwarfdump.

Co-authored-by: Tim McGilchrist <[email protected]>
pub name: String,

/// The offset to the compilation unit header in .debug_info.
pub compilation_unit_offset: DebugInfoOffset<R::Offset>,
Copy link
Collaborator Author

@philipc philipc Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all entries require a CU offset. We'll need to do something different here but I'm not sure what. We could remove NameLookupResult and return only NameEntry, but we still need some way to also convert the CU index from the attribute into a CU offset, and similarly for TUs.

Maybe DebugNames::find_entries_by_name should return an iterator rather than a Vec, and that iterator could keep some state for looking up the indexes.

S: Reader<Offset = R::Offset>,
{
// Compute the hash for the name
let hash = compute_djb_hash(name);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash must be of the case folded name. That means either name is already case folded, or we need to the case folding ourselves.

.filter_map(|name_index| {
// Resolve the actual string to verify it matches
let resolved_name = unit.resolve_name_at_index(debug_str, name_index)?;
if resolved_name != name {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a case folding comparison for languages that are case insensitive. Or we could always do a case folding comparison and require the user to do another comparison if required. Or we could do no comparison at all and leave it up to the user completely.


// Determine the compilation unit offset using the CU index from the entry
let cu_offset = entry.compile_unit(&name_index).ok()??;
return Some(NameLookupResult::new(entry, resolved_name, cu_offset));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to return all matching entries, not only the first match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant