This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Understand GCC test process

On 7 October 2015 at 14:03, Sabrina Souto wrote:
>>> Hi,
>>> I'm needing to analyze the execution flow of a test, but don't
>>> understand how the test drivers, e.g., gcc-dg.exp or dg.exp, access
>>> the source code of GCC. When a test starts, what is the first function
>>> that is called? How can I know that?
>> The first function is main(), because the tests just run the compiler.
>> DejaGnu doesn't access the source code of GCC, it just runs the
>> compiler executable.
> OK, I understand. But when a test run the compiler, all compiler
> stages/phases are always executed?

No, only the stages requested by the dg-do directive.

> how the test knows the compiler
> stage must be run? from the "dg-do" actions (preprocess, compile,
> assemble, link, run)? how the "dg-do" actions are processed/performed?

That's initially handled by DejaGnu, not GCC. See the site-wide dg.exp
file (on my system that is /usr/share/dejagnu/dg.exp) which says:

# dg-do do-what-keyword [{ target/xfail selector }]
#       `do-what-keyword' is tool specific and is passed unchanged to
#       ${tool}-dg-test.  An example is gcc where `keyword' can be any of:
#       preprocess|compile|assemble|link|run
#       and will do one of: produce a .i, produce a .s, produce a .o,
#       produce an a.out, or produce an a.out and run it (the default is
#       compile).

So that passes the argument to the callback gcc-dg-test, which is
defined in gcc/testsuite/lib/gcc-dg.exp, and that sets the
'compile_type' variable to one of assemble, preprocess, link etc. and
sets the appropriate output filename for the action.

That is then translated into command-line options for the compiler, so
a 'compile' test will be run with -c, an 'assemble' test will be run
with -S, a 'link' test will have no special option (so all stages run)
and a 'run' test does the same as 'link' but also runs the executable.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]