-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support multiple clone suffixes #194
Conversation
Note that
I chose to leave a space between the clone suffixes for readability. |
57776db
to
9bf586a
Compare
Awesome work! Personally I think we should probably stay closer to matching
So looking at the output it looks like it separates each suffix into their own bracket. Also if you get that fixed, could you make |
9bf586a
to
d6225c6
Compare
@miguelsaldivar updated, thanks! |
d6225c6
to
46aab00
Compare
I'm noticing now that there is another test that's failing from the libiberty test suite:
I'm wondering now what the best approach to parse this. We could detect that the clone type identifier is missing and just make it empty or optional. WDYT? |
src/ast.rs
Outdated
@@ -7791,7 +7795,7 @@ mod tests { | |||
SourceName(Identifier { | |||
start: 3, | |||
end: 6, | |||
}))))), None), | |||
}))))), Vec::new()), |
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.
I think we need vec![]
rather than Vec::new()
, to satisfy the no-std
requirement? That's where the CI is failing.
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.
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.
I can't see it through there either for some reason, but going here does the trick.
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.
travis notifications have been flaky in gimli as well.
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.
I wonder if this started happening after the project was moved to gimli-rs? Could be an old webhook, potentially.
On my local machine, and on CI all the tests seem to be passing. The only differences I see are with the |
46aab00
to
dbddf4d
Compare
@jan-auer I think once you get a fix for that |
dbddf4d
to
9059eac
Compare
let (identifier, tail) = CloneTypeIdentifier::parse(ctx, subs, tail)?; | ||
if tail.is_empty() { | ||
return Err(error::Error::UnexpectedText); | ||
} |
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.
On my local machine, and on CI all the tests seem to be passing
That's because I had this one test disabled. I didn't look into it too closely, but the cppfilt
example does demangle, while the libiberty tests did not. They all ran into this UnexpectedText
error, since the symbol foo(int) [clone .1988]
only has a nonnegative number but no type identifier.
Coming back to my earlier message: According to the grammar, the clone type identifier is optional:
<clone-suffix> ::= [ . <clone-type-identifier> ] [ . <nonnegative number> ]*
With this fix, the number is parsed into the clone type identifier. For demangling, this doesn't really make a difference. However, if you prefer to make the clone type identifier optional, I can do that aswell.
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.
Okay I see now. Making it optional seems like the way to go. c++filt
's output seems to not care if you're missing either of those, but if you're missing both that's when c++filt
does nothing.
$ c++filt _Z3fooi.12
foo(int) [clone .12]
$ c++filt _Z3fooi.part
foo(int) [clone .part]
$ c++filt _Z3fooi.
_Z3fooi.
I think making it optional is the best choice imo. :)
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.
I'm trying this now, and I'm no longer sure if it's actually worth the effort. This complicates parsing quite a bit for very little benefit. I've pushed this up in a separate commit now to see the difference. I'd highly be in favor of leaving the earlier version, though.
The problem with this implementation is that we have to detect a number of cases throughout the hierarchy of CloneSuffix and CloneTypeIdentifier. This creates very tight coupling, since we have to swallow errors in zero_or_one
, and then reintroduce redundant checks at the higher level. For example, see fbd5741#diff-6a87164025de4254d2818e3ca4bc813aR1538.
libiberty
Does not seem to differentiate, and instead just consumes everything into one large string. In that sense, the implementation we had earlier is probably enough and serves the purpose.
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.
Yeah you're right it does add a bit more overhead, and doesn't seem worth it. Okay I think just making it empty should be fine.
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.
Thanks. Reverted to the prior implementation.
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.
Sorry for making you jump through those hoops, awesome work though!
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.
No worries, it's well worth the effort to get a good implementation :)
fbd5741
to
9059eac
Compare
@fitzgen can you merge, I don't have access. Thank you! :) |
I don't think CI ran for the last push (9059eac) but I can't see a way to retry it. Going to merge as is... |
@philipc thank you for merging! I appreciate it :) |
Thank you both! I'd appreciate a release with this commit so I can publish a dependent crate. |
Fixes demangling errors with symbols that contain multiple clone suffixes, as well as clone suffixes without numbers. Such symbols are quite frequent in ELF symbol tables and they currently fail to demangle completely.
Examples are taken from a Google Breakpad Linux build, as well as from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40831.
Fixes #193