-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Rewrite Of C++ Demanglers #69
base: main
Are you sure you want to change the base?
Conversation
- Common types like int, signed char, etc... are being demangled in function params now - Support for custom types in function param list needs to be added. - Support for repeated parameter types.
Now 180 tests pass out of all. Two tests seem to be wrong at the moment, but will take a look later. TODO - Sequence of identical types - Templates - Function params that have qualifier list in their type
src/cp/vec.h
Outdated
*/ | ||
#define vec_foreach(v, var, body) \ | ||
do { \ | ||
size_t ___iter___ = 0; \ |
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.
Maybe use another name for this. ___xxx___
might be a macro on some compilers
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.
ok
((p) ? (dem_string_free ((p)->name), \ | ||
dem_string_free ((p)->suffix), \ | ||
dem_string_free ((p)->prefix), \ | ||
memset ((p), 0, sizeof (Param)), \ | ||
(p)) : \ | ||
NULL) |
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.
maybe just use a do {} while(0)
with an if
inside ?
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 like them having as expressions so I can do an if(!expr) {error}
on them to debug sometimes.
((p) ? (((p)->name = dem_string_new()), \ | ||
((p)->suffix = dem_string_new()), \ | ||
((p)->prefix = dem_string_new()), \ | ||
(p)) : \ | ||
NULL) |
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.
same here
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 can convert these after the rewrite is complete, it won't hurt to change them and the code will be going into static mode.
((param_init (p_dst) && (p_src)) ? (dem_string_concat ((p_dst)->name, (p_src)->name), \ | ||
dem_string_concat ((p_dst)->suffix, (p_src)->suffix), \ | ||
dem_string_concat ((p_dst)->prefix, (p_src)->prefix), \ | ||
(p_dst)) : \ | ||
NULL) |
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.
if the purpose is to call this, then maybe just define a function that does this directly in the demangler ?
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.
Yep, I'll do that. I used this init
then concat
pattern some other places as well. It'll fix those as well...
#define nearest_power_of_two(v) \ | ||
(((v)--), \ | ||
((v) |= (v) >> 1), \ | ||
((v) |= (v) >> 2), \ | ||
((v) |= (v) >> 4), \ | ||
((v) |= (v) >> 8), \ |
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.
instead of reinventing the wheel, why not copying the code from rizin side?
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.
Yea, sorry about that 😅 I have a habit of doing that. The plus point is that src/cp
will be a completely independent module on it's own if we just provide a DemString
to it. Maybe that's good...?
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.
just define one like DemString (which is an extract of RzStrBuf) which any other demangler can use.
Remove old GPL code from libiberty and completely rewrite both GNU v2 and GNU v3 demanglers with LGPL license.
Work plan :
src/gnu_v2
src/cxx
Test plan :