diff --git a/include/n64recomp.h b/include/n64recomp.h index 95b783c..c214ac7 100644 --- a/include/n64recomp.h +++ b/include/n64recomp.h @@ -217,7 +217,7 @@ namespace N64Recomp { std::vector event_symbols; // Causes functions to print their name to the console the first time they're called. - bool function_trace_mode; + bool trace_mode; // Imports sections and function symbols from a provided context into this context's reference sections and reference functions. bool import_reference_context(const Context& reference_context); diff --git a/src/config.cpp b/src/config.cpp index 68b78d0..4c3594e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -414,15 +414,15 @@ N64Recomp::Config::Config(const char* path) { } // Use RE mode if enabled (optional) - std::optional function_trace_mode_opt = input_data["function_trace_mode"].value(); - if (function_trace_mode_opt.has_value()) { - function_trace_mode = function_trace_mode_opt.value(); - if (function_trace_mode) { - recomp_include += "\n#include \n#include "; + std::optional trace_mode_opt = input_data["trace_mode"].value(); + if (trace_mode_opt.has_value()) { + trace_mode = trace_mode_opt.value(); + if (trace_mode) { + recomp_include += "\n#include \"trace.h\""; } } else { - function_trace_mode = false; + trace_mode = false; } // Function reference symbols file (optional) diff --git a/src/config.h b/src/config.h index af7b1e4..0f01a33 100644 --- a/src/config.h +++ b/src/config.h @@ -42,7 +42,7 @@ namespace N64Recomp { bool single_file_output; bool use_absolute_symbols; bool unpaired_lo16_warnings; - bool function_trace_mode; + bool trace_mode; bool allow_exports; bool strict_patch_mode; std::filesystem::path elf_path; diff --git a/src/main.cpp b/src/main.cpp index 64e5f59..bf8d511 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -509,7 +509,7 @@ int main(int argc, char** argv) { } // Propogate the re_mode parameter. - context.function_trace_mode = config.function_trace_mode; + context.trace_mode = config.trace_mode; // Apply any single-instruction patches. for (const N64Recomp::InstructionPatch& patch : config.instruction_patches) { diff --git a/src/recompilation.cpp b/src/recompilation.cpp index 2a82b53..1faef25 100644 --- a/src/recompilation.cpp +++ b/src/recompilation.cpp @@ -745,13 +745,9 @@ bool N64Recomp::recompile_function(const N64Recomp::Context& context, const N64R " int c1cs = 0;\n", // cop1 conditional signal func.name); - if (context.function_trace_mode) { + if (context.trace_mode) { fmt::print(output_file, - " static int {0}_was_called = 0;\n" - " if ({0}_was_called == 0) {{\n" - " fprintf(stderr, \"new function: {0}\\n\");\n" - " {0}_was_called = 1;\n" - " }}\n", + " TRACE_ENTRY();", func.name); }