-
Notifications
You must be signed in to change notification settings - Fork 109
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
Why is Dwarf::borrow
deprecated?
#744
Comments
For consistency with how
That was the intent.
Sure, but I'll need to understand the reason why it is needed. |
Oh lol. I skimmed the code and read it as doing a cheap In any case, it's worse because users are forced to do the same
It's necessary for when a second |
I still don't understand. Can you demonstrate with some code? For example, here's what I think the two alternatives are, using code from the documentation examples: let dwarf = owned_dwarf.borrow(|section| {
gimli::EndianSlice::new(§ion, gimli::LittleEndian)
}); let dwarf = dwarf_sections.borrow_with_sup(&dwarf_sup_sections, |section| {
gimli::EndianSlice::new(§ion, gimli::LittleEndian)
}); The only difference I can see is an extra argument, which seems like a trivial difference to me. |
For an argument in favor of |
Here is an example: let sections = gimli::DwarfSections::load(/* .. */).unwrap();
let dwarf = if let Some(...) = /* maybe-some-sup-object */ {
let sup_secs = gimli::DwarfSections::load(/* load sections from sup object */).unwrap();
sections.borrow_with_sup(&sup_secs, |b| *b)
} else {
sections.borrow(|b| *b)
};
let ctx = addr2line::Context::from_dwarf(dwarf).unwrap();
// Down here we may need a `Dwarf` again. So now we need to keep the `sup_secs` around,
// recreate everything again with the conditional `sections.borrow_with_sup` dance, instead
// of just being able to pass `dwarf.borrow(|b| *b)` to `addr2line::Context::from_dwarf` and then
// still have the "original". |
Ok. That seems like a design mistake with let sections = gimli::DwarfSections::load(/* .. */).unwrap();
let sup_secs = if let Some(...) = /* maybe-some-sup-object */ {
Some(gimli::DwarfSections::load(/* load sections from sup object */).unwrap())
} else {
None
};
let dwarf = sections.borrow_with_sup(sup_secs.as_ref(), |b| *b)
let ctx = addr2line::Context::from_dwarf(dwarf).unwrap();
// Down here we may need a `Dwarf` again.
let dwarf = sections.borrow_with_sup(sup_secs.as_ref(), |b| *b); |
A better solution is gimli-rs/addr2line#327, which allows you to use the same |
Yep, either should work for the use case at hand. Thanks! |
See title.
Introduced by e6e90c9, which states:
I looked for it, but couldn't find said consistency. Now we have
borrow
onDwarfSections
and...nothing forDwarf
. What ifDwarf
has asup
set and I want to borrow that? Seems now I am forced toDwarfSections::borrow_with_sup
again, which allocates a newArc
with a sup which seems consistently worse than what was possible beforehand, right? Can we please consider reverting the deprecation?The text was updated successfully, but these errors were encountered: