public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: Juan Scerri <juan.scerri.21@um.edu.mt>
Cc: gcc@gcc.gnu.org
Subject: Re: GSoC (Make cp-demangle non-recursive)
Date: Wed, 02 Mar 2022 19:37:11 +0100	[thread overview]
Message-ID: <ri65yowqjzc.fsf@suse.cz> (raw)
In-Reply-To: <CACJSivv=BmcxsSoM8o8q_82VQ9LDSRC-2_HBsb_AowP+Scir7A@mail.gmail.com>

Hello Juan,

we are delighted you found contributing to GCC interesting.

On Sat, Feb 26 2022, Juan Scerri wrote:
> To whom this may concern,
>
> Firstly, I will introduce myself. I am Juan Scerri and I am a student at
> the University of Malta studying Computer Science and Mathematics for my
> undergraduate degree.
> I am currently in my first year of studies, which is technically my first
> formal introduction to GNU/Linux. However, I have been using GNU/Linux for
> over a year. I am
> mostly interested in programming which involves compilers, operating
> systems and things of a similar sort.
>
> I have looked at the selected project ideas by the GCC team and one of the
> problems which has caught my attention is making cp-demangle non-recursive.
> I am interested in this particular problem because as stated in the "Before
> you apply" section it is one of the selected problems which do not require
> extensive
> knowledge of the compiler theory (which I will be doing in my 3rd year of
> studies). However, I do understand the aim of the project.

Great.  The other skill necessary for the project is reading and writing
C code (not C++).

The bulk of the demangler is in libiberty which is shared between gcc
and binutils projects.  It is actually easier to hack on it in the
binutils repo, because there you get a utility to try it (c++filt) and
there are tests in the testsuite to check that code (still) works.

So I suggest you check out the binutils repo from git clone
git://sourceware.org/git/binutils-gdb.git and build it as described in
README (you do not need to run make install - you can run the configure
and make in a different working directory if you wish to keep things
clean).

The source code of interest to you is almost entirely in
libiberty/cp-demangle.c and libiberty/cp-demangle.h.

You will need to wade through some preprocessor cruft, it is there for
historical reasons and because the demangler can be used in utilities as
well as in libraries and some interface functions have different names
in those situations.  Some of that might need to be changed/adjusted, do
not be afraid of changing stuff.

Those are the files you need to study, identify the various recursion
cycles and think how to remove them and especially what would the data
structures to do so look like.  Ideally one by one, so that intermediate
results still can be checked.

I will have to refresh my own knowledge of the file so I will not go
into any more detail now, but if you have any questions about the source
code and would like to discuss approaches, priorities, anything, feel
free to ask again here on the mailing list.

When you build binutils, the simple utility to demangle stuff is called
binutils/cxxfilt (it is installed under the name of c++filt which is
what you'll find on Linux machines).  There is a testsuite, you need
package dejagnu for it, and you can run it by issuing

  make -C libiberty check

in the binutils build directory.

As I wrote above, if you have any further questions, feel free to ask
here on the list.

Good luck,

Martin



  parent reply	other threads:[~2022-03-02 18:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26 10:34 Juan Scerri
2022-02-26 16:31 ` Juan Scerri
2022-03-02 18:37 ` Martin Jambor [this message]
     [not found]   ` <CACJSivvYgNG+C2Y5ph=4yv5y0iaV+Ak7=vh3FGD7W6eQADxk9w@mail.gmail.com>
2022-03-09 16:15     ` Martin Jambor
2022-03-27 12:21 Juan Scerri
2022-04-07 15:24 ` Martin Jambor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ri65yowqjzc.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc@gcc.gnu.org \
    --cc=juan.scerri.21@um.edu.mt \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).