-
Notifications
You must be signed in to change notification settings - Fork 127
Read debug_names section from DWARF 5 #847
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
base: master
Are you sure you want to change the base?
Conversation
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>, |
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.
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); |
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.
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.
src/read/names.rs
Outdated
| .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 { |
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.
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.
While the strings should be UTF-8, we don't depend on it.
|
|
||
| // 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)); |
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.
We need to return all matching entries, not only the first match.
Adds sample implementation to dwarfdump that prints the same information as llvm-dwarfdump.