Commit 0ed4f017 by David Malcolm Committed by David Malcolm

jit: option-logging

gcc/jit/ChangeLog:
	* jit-logging.h (gcc::jit::log_user::log): Make const.
	* jit-recording.c (gcc::jit::recording::context::set_str_option):
	Log the new value of the option.
	(gcc::jit::recording::context::set_int_option): Likewise.
	(gcc::jit::recording::context::set_bool_option): Likewise.
	(gcc::jit::recording::context::compile): Log the value of all
	options.
	(gcc::jit::recording::context::compile_to_file): Likewise.
	(gcc::jit::recording::context::log_all_options): New function.
	(gcc::jit::recording::context::log_str_option): New function.
	(gcc::jit::recording::context::log_int_option): New function.
	(gcc::jit::recording::context::log_bool_option): New function.
	* jit-recording.h (gcc::jit::recording::context::log_all_options):
	New function.
	(gcc::jit::recording::context::log_str_option): New function.
	(gcc::jit::recording::context::log_int_option): New function.
	(gcc::jit::recording::context::log_bool_option): New function.
	* docs/internals/test-hello-world.exe.log.txt: Update for above
	changes.

From-SVN: r220375
parent 457d0ace
2015-02-03 David Malcolm <dmalcolm@redhat.com> 2015-02-03 David Malcolm <dmalcolm@redhat.com>
* jit-logging.h (gcc::jit::log_user::log): Make const.
* jit-recording.c (gcc::jit::recording::context::set_str_option):
Log the new value of the option.
(gcc::jit::recording::context::set_int_option): Likewise.
(gcc::jit::recording::context::set_bool_option): Likewise.
(gcc::jit::recording::context::compile): Log the value of all
options.
(gcc::jit::recording::context::compile_to_file): Likewise.
(gcc::jit::recording::context::log_all_options): New function.
(gcc::jit::recording::context::log_str_option): New function.
(gcc::jit::recording::context::log_int_option): New function.
(gcc::jit::recording::context::log_bool_option): New function.
* jit-recording.h (gcc::jit::recording::context::log_all_options):
New function.
(gcc::jit::recording::context::log_str_option): New function.
(gcc::jit::recording::context::log_int_option): New function.
(gcc::jit::recording::context::log_bool_option): New function.
* docs/internals/test-hello-world.exe.log.txt: Update for above
changes.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
2015-02-03 David Malcolm <dmalcolm@redhat.com>
PR jit/64810 PR jit/64810
* Make-lang.in (jit_OBJS): Add jit/jit-spec.o and gcc.o. * Make-lang.in (jit_OBJS): Add jit/jit-spec.o and gcc.o.
(LIBGCCJIT_FILENAME): Add EXTRA_GCC_OBJS. (LIBGCCJIT_FILENAME): Add EXTRA_GCC_OBJS.
......
...@@ -13756,18 +13756,25 @@ generated via this call: ...@@ -13756,18 +13756,25 @@ generated via this call:
JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu) JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu)
JIT: compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1 JIT: compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
JIT: entering: gcc_jit_context_set_str_option JIT: entering: gcc_jit_context_set_str_option
JIT: GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
JIT: exiting: gcc_jit_context_set_str_option JIT: exiting: gcc_jit_context_set_str_option
JIT: entering: gcc_jit_context_set_int_option JIT: entering: gcc_jit_context_set_int_option
JIT: GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL: 3
JIT: exiting: gcc_jit_context_set_int_option JIT: exiting: gcc_jit_context_set_int_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DEBUGINFO: true
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_get_type JIT: entering: gcc_jit_context_get_type
JIT: exiting: gcc_jit_context_get_type JIT: exiting: gcc_jit_context_get_type
...@@ -13802,6 +13809,16 @@ JIT: exiting: gcc_jit_context_dump_reproducer_to_file ...@@ -13802,6 +13809,16 @@ JIT: exiting: gcc_jit_context_dump_reproducer_to_file
JIT: entering: gcc_jit_context_compile JIT: entering: gcc_jit_context_compile
JIT: in-memory compile of ctxt: 0x1283e20 JIT: in-memory compile of ctxt: 0x1283e20
JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile() JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile()
JIT: GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
JIT: GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL: 3
JIT: GCC_JIT_BOOL_OPTION_DEBUGINFO: true
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING: false
JIT: GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
JIT: GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES: false
JIT: entering: void gcc::jit::recording::context::validate() JIT: entering: void gcc::jit::recording::context::validate()
JIT: exiting: void gcc::jit::recording::context::validate() JIT: exiting: void gcc::jit::recording::context::validate()
JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*) JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*)
......
JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu) JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu)
JIT: compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1 JIT: compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
JIT: entering: gcc_jit_context_set_str_option JIT: entering: gcc_jit_context_set_str_option
JIT: GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
JIT: exiting: gcc_jit_context_set_str_option JIT: exiting: gcc_jit_context_set_str_option
JIT: entering: gcc_jit_context_set_int_option JIT: entering: gcc_jit_context_set_int_option
JIT: GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL: 3
JIT: exiting: gcc_jit_context_set_int_option JIT: exiting: gcc_jit_context_set_int_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DEBUGINFO: true
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_set_bool_option JIT: entering: gcc_jit_context_set_bool_option
JIT: GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
JIT: exiting: gcc_jit_context_set_bool_option JIT: exiting: gcc_jit_context_set_bool_option
JIT: entering: gcc_jit_context_get_type JIT: entering: gcc_jit_context_get_type
JIT: exiting: gcc_jit_context_get_type JIT: exiting: gcc_jit_context_get_type
...@@ -47,6 +54,16 @@ JIT: exiting: gcc_jit_context_dump_reproducer_to_file ...@@ -47,6 +54,16 @@ JIT: exiting: gcc_jit_context_dump_reproducer_to_file
JIT: entering: gcc_jit_context_compile JIT: entering: gcc_jit_context_compile
JIT: in-memory compile of ctxt: 0x1283e20 JIT: in-memory compile of ctxt: 0x1283e20
JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile() JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile()
JIT: GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
JIT: GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL: 3
JIT: GCC_JIT_BOOL_OPTION_DEBUGINFO: true
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
JIT: GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING: false
JIT: GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
JIT: GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES: false
JIT: entering: void gcc::jit::recording::context::validate() JIT: entering: void gcc::jit::recording::context::validate()
JIT: exiting: void gcc::jit::recording::context::validate() JIT: exiting: void gcc::jit::recording::context::validate()
JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*) JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*)
......
...@@ -127,7 +127,7 @@ class log_user ...@@ -127,7 +127,7 @@ class log_user
logger * get_logger () const { return m_logger; } logger * get_logger () const { return m_logger; }
void set_logger (logger * logger); void set_logger (logger * logger);
void log (const char *fmt, ...) void log (const char *fmt, ...) const
GNU_PRINTF(2, 3); GNU_PRINTF(2, 3);
void enter_scope (const char *scope_name); void enter_scope (const char *scope_name);
...@@ -141,7 +141,7 @@ class log_user ...@@ -141,7 +141,7 @@ class log_user
case where the underlying logger is NULL via a no-op. */ case where the underlying logger is NULL via a no-op. */
inline void inline void
log_user::log (const char *fmt, ...) log_user::log (const char *fmt, ...) const
{ {
if (m_logger) if (m_logger)
{ {
......
...@@ -1093,6 +1093,7 @@ recording::context::set_str_option (enum gcc_jit_str_option opt, ...@@ -1093,6 +1093,7 @@ recording::context::set_str_option (enum gcc_jit_str_option opt,
} }
free (m_str_options[opt]); free (m_str_options[opt]);
m_str_options[opt] = value ? xstrdup (value) : NULL; m_str_options[opt] = value ? xstrdup (value) : NULL;
log_str_option (opt);
} }
/* Set the given integer option for this context, or add an error if /* Set the given integer option for this context, or add an error if
...@@ -1112,6 +1113,7 @@ recording::context::set_int_option (enum gcc_jit_int_option opt, ...@@ -1112,6 +1113,7 @@ recording::context::set_int_option (enum gcc_jit_int_option opt,
return; return;
} }
m_int_options[opt] = value; m_int_options[opt] = value;
log_int_option (opt);
} }
/* Set the given boolean option for this context, or add an error if /* Set the given boolean option for this context, or add an error if
...@@ -1131,6 +1133,7 @@ recording::context::set_bool_option (enum gcc_jit_bool_option opt, ...@@ -1131,6 +1133,7 @@ recording::context::set_bool_option (enum gcc_jit_bool_option opt,
return; return;
} }
m_bool_options[opt] = value ? true : false; m_bool_options[opt] = value ? true : false;
log_bool_option (opt);
} }
/* Add the given dumpname/out_ptr pair to this context's list of requested /* Add the given dumpname/out_ptr pair to this context's list of requested
...@@ -1164,6 +1167,8 @@ recording::context::compile () ...@@ -1164,6 +1167,8 @@ recording::context::compile ()
{ {
JIT_LOG_SCOPE (get_logger ()); JIT_LOG_SCOPE (get_logger ());
log_all_options ();
validate (); validate ();
if (errors_occurred ()) if (errors_occurred ())
...@@ -1192,6 +1197,8 @@ recording::context::compile_to_file (enum gcc_jit_output_kind output_kind, ...@@ -1192,6 +1197,8 @@ recording::context::compile_to_file (enum gcc_jit_output_kind output_kind,
{ {
JIT_LOG_SCOPE (get_logger ()); JIT_LOG_SCOPE (get_logger ());
log_all_options ();
validate (); validate ();
if (errors_occurred ()) if (errors_occurred ())
...@@ -1378,6 +1385,72 @@ static const char * const ...@@ -1378,6 +1385,72 @@ static const char * const
"GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES" "GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES"
}; };
/* Write the current value of all options to the log file (if any). */
void
recording::context::log_all_options () const
{
int opt_idx;
if (!get_logger ())
return;
for (opt_idx = 0; opt_idx < GCC_JIT_NUM_STR_OPTIONS; opt_idx++)
log_str_option ((enum gcc_jit_str_option)opt_idx);
for (opt_idx = 0; opt_idx < GCC_JIT_NUM_INT_OPTIONS; opt_idx++)
log_int_option ((enum gcc_jit_int_option)opt_idx);
for (opt_idx = 0; opt_idx < GCC_JIT_NUM_BOOL_OPTIONS; opt_idx++)
log_bool_option ((enum gcc_jit_bool_option)opt_idx);
}
/* Write the current value of the given string option to the
log file (if any). */
void
recording::context::log_str_option (enum gcc_jit_str_option opt) const
{
gcc_assert (opt < GCC_JIT_NUM_STR_OPTIONS);
if (get_logger ())
{
if (m_str_options[opt])
log ("%s: \"%s\"",
str_option_reproducer_strings[opt],
m_str_options[opt]);
else
log ("%s: NULL",
str_option_reproducer_strings[opt]);
}
}
/* Write the current value of the given int option to the
log file (if any). */
void
recording::context::log_int_option (enum gcc_jit_int_option opt) const
{
gcc_assert (opt < GCC_JIT_NUM_INT_OPTIONS);
if (get_logger ())
log ("%s: %i",
int_option_reproducer_strings[opt],
m_int_options[opt]);
}
/* Write the current value of the given bool option to the
log file (if any). */
void
recording::context::log_bool_option (enum gcc_jit_bool_option opt) const
{
gcc_assert (opt < GCC_JIT_NUM_BOOL_OPTIONS);
if (get_logger ())
log ("%s: %s",
bool_option_reproducer_strings[opt],
m_bool_options[opt] ? "true" : "false");
}
/* Write C source code to PATH that attempts to replay the API /* Write C source code to PATH that attempts to replay the API
calls made to this context (and its parents), for use in calls made to this context (and its parents), for use in
minimizing test cases for libgccjit. minimizing test cases for libgccjit.
......
...@@ -256,6 +256,11 @@ public: ...@@ -256,6 +256,11 @@ public:
get_all_requested_dumps (vec <recording::requested_dump> *out); get_all_requested_dumps (vec <recording::requested_dump> *out);
private: private:
void log_all_options () const;
void log_str_option (enum gcc_jit_str_option opt) const;
void log_int_option (enum gcc_jit_int_option opt) const;
void log_bool_option (enum gcc_jit_bool_option opt) const;
void validate (); void validate ();
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment