mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 23:10:27 +00:00
By implementing these improvements, users will have the ability to choose specific parts of the trace output. Currently, when executing a file using the explorer with the --trace_file=- or --trace_file=filename.txt flag, the resulting output is an extensive and verbose log containing all the information. In this PR, I have introduced the `ProgramPhase` enum class, which have distinct phases encountered during the compilation of a program in the explorer. Each member of this enum class corresponds to a specific phase, signifying the relevant information to be included in the trace output. The phases covered by the `ProgramPhase` enum class are as follows: 1. Printing the source program 2. Name resolution 3. Control flow resolution 4. Type checking 5. Unformed variable resolution 6. Printing declarations 7. Printing the timings 8. Printing whole output. These phases can be selected by passing the following compiler flags along with `--trace_file=-`. `-trace_source_program`, `-trace_name_resolution`, `-trace_control_flow_resolution`, `-trace_type_checking`, `-trace_unformed_variables_resolution`, `-trace_declarations`, `-trace_execution`, `-trace_timing` and `-trace_all`. If none of these flags is passed only execution trace will be added to the output. Co-authored-by: Richard Smith <richard@metafoo.co.uk>
66 lines
4.8 KiB
Plaintext
66 lines
4.8 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// A lot of output is elided: this is only checking for a few things for simple
|
|
// sanity checking on --parser_debug --trace_file=- along with filter flags output.
|
|
//
|
|
// NOAUTOUPDATE
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_execution | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_source_program | %{FileCheck-allow-unmatched} --check-prefixes=SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_name_resolution | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_control_flow_resolution | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_type_checking | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,TYPE,NO-UNFORMED,NO-DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_unformed_variables_resolution | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,UNFORMED,NO-DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_declarations | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,DECLS,NO-EXEC,NO-TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_timing | %{FileCheck-allow-unmatched} --check-prefixes=NO-SOURCE,NO-NAMES,NO-PRELUDE,NO-FLOW,NO-TYPE,NO-UNFORMED,NO-DECLS,NO-EXEC,TIMING
|
|
// RUN: %{explorer-run} --parser_debug --trace_file=- -trace_all | %{FileCheck-allow-unmatched} --check-prefixes=SOURCE,NAMES,NO-PRELUDE,FLOW,TYPE,UNFORMED,DECLS,EXEC,TIMING
|
|
// NO-SOURCE-NOT:STDOUT: ********** source program **********
|
|
// SOURCE:STDOUT: ********** source program **********
|
|
// NO-SOURCE-NOT:STDOUT: interface TestInterface {
|
|
// SOURCE:STDOUT: interface TestInterface {
|
|
// NO-NAMES-NOT:STDOUT: ********** resolving names **********
|
|
// NAMES:STDOUT: ********** resolving names **********
|
|
// NO-PRELUDE-NOT:STDOUT: interface ImplicitAs {
|
|
// NO-FLOW-NOT:STDOUT: ********** resolving control flow **********
|
|
// FLOW:STDOUT: ********** resolving control flow **********
|
|
// NO-TYPE-NOT:STDOUT: ********** type checking **********
|
|
// TYPE:STDOUT: ********** type checking **********
|
|
// NO-TYPE-NOT:STDOUT: ** declaring interface TestInterface
|
|
// TYPE:STDOUT: ** declaring interface TestInterface
|
|
// NO-UNFORMED-NOT:STDOUT: ********** resolving unformed variables **********
|
|
// UNFORMED:STDOUT: ********** resolving unformed variables **********
|
|
// NO-DECLS-NOT:STDOUT: ********** printing declarations **********
|
|
// DECLS:STDOUT: ********** printing declarations **********
|
|
// NO-DECLS-NOT:STDOUT: interface TestInterface {
|
|
// DECLS:STDOUT: interface TestInterface {
|
|
// NO-EXEC-NOT:STDOUT: ********** starting execution **********
|
|
// EXEC:STDOUT: ********** starting execution **********
|
|
// NO-EXEC-NOT:STDOUT: ********** initializing globals **********
|
|
// EXEC:STDOUT: ********** initializing globals **********
|
|
// NO-EXEC-NOT:STDOUT: ********** calling main function **********
|
|
// EXEC:STDOUT: ********** calling main function **********
|
|
// NO-EXEC-NOT:STDOUT: --- step exp Main() .0. (<Main()>:0) --->
|
|
// EXEC:STDOUT: --- step exp Main() .0. (<Main()>:0) --->
|
|
// NO-EXEC-NOT:STDOUT: interpreter result: 0
|
|
// EXEC:STDOUT: interpreter result: 0
|
|
// NO-TIMING-NOT:STDOUT: ********** printing timing **********
|
|
// TIMING:STDOUT: ********** printing timing **********
|
|
// NO-TIMING-NOT:STDOUT: Time elapsed in ExecProgram: {{[0-9]+}}ms
|
|
// TIMING:STDOUT: Time elapsed in ExecProgram: {{[0-9]+}}ms
|
|
// NO-TIMING-NOT:STDOUT: Time elapsed in AnalyzeProgram: {{[0-9]+}}ms
|
|
// TIMING:STDOUT: Time elapsed in AnalyzeProgram: {{[0-9]+}}ms
|
|
// NO-TIMING-NOT:STDOUT: Time elapsed in AddPrelude: {{[0-9]+}}ms
|
|
// TIMING:STDOUT: Time elapsed in AddPrelude: {{[0-9]+}}ms
|
|
// NO-TIMING-NOT:STDOUT: Time elapsed in Parse: {{[0-9]+}}ms
|
|
// TIMING:STDOUT: Time elapsed in Parse: {{[0-9]+}}ms
|
|
|
|
package ExplorerTest api;
|
|
|
|
interface TestInterface {}
|
|
|
|
fn Main() -> i32 {
|
|
return 0;
|
|
}
|