Skip to content
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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

brightprogrammer
Copy link
Contributor

@brightprogrammer brightprogrammer commented Jan 3, 2025

Remove old GPL code from libiberty and completely rewrite both GNU v2 and GNU v3 demanglers with LGPL license.

Work plan :

Test plan :

  • Already added in Add More GNU v2/v3 Tests #68
  • Write a fuzzer (in less than 100 lines) as implemented in GCC?
  • Build old GCC version (maybe using Qemu) and then compile and get [mangled, original] name pairs for testing.

Attachments :

- 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 Show resolved Hide resolved
src/cp/param.h Outdated Show resolved Hide resolved
src/cp/param.h Outdated Show resolved Hide resolved
src/cp/param.h Outdated Show resolved Hide resolved
src/cp/vec.h Outdated Show resolved Hide resolved
@brightprogrammer
Copy link
Contributor Author

We do need to find a way to test the GNU v2 code more like we do for GNU v3. There are very few examples. Also due to lack of a precise grammar, things like special naming conventions are hard for me to cover. Any suggestions?

@brightprogrammer brightprogrammer marked this pull request as ready for review January 17, 2025 10:34
@brightprogrammer
Copy link
Contributor Author

There are some function parameter types for which tests don't exist. I haven't added them for now, because I won't have any way to test my implementation.

.reuse/dep5 Show resolved Hide resolved
From the beginning itself, a single test is passing. Now I just have to
keep fixing tests to make the demangler work.
src/cp/common.h Outdated Show resolved Hide resolved
src/cp/v2.c Outdated Show resolved Hide resolved
@wargio
Copy link
Member

wargio commented Feb 2, 2025

overall this looks very very good. great job!

@brightprogrammer
Copy link
Contributor Author

This PR is going to get a bit messy. I'm going to make a split of the very large (around 28k lines) test/test_cxx.c file into multiple smaller files of 1000 tests max. Later on before the merge I can merge all these files back to a big one, or we can leave it this way for future cases.

Also, the split is done without any category. I'll focus on passing all tests in a single file at a time. Slowly cover all files.

I used the following command for the split :

split -d -l 1000 test_cxx.c test_cxx.

@brightprogrammer
Copy link
Contributor Author

My current focus is only on passing all tests cases and completing the demangler as soon as possible, and later on we can worry about other failing CI. Every CI is at the time of writing...

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.

2 participants