From d4d4ddbcbaee4dbaa927bf75f2ccf51b32483855 Mon Sep 17 00:00:00 2001 From: andreika-git Date: Thu, 22 Feb 2024 21:31:37 +0200 Subject: [PATCH] Disable tooth logger if ptrace is started https://github.com/rusefi/rusefi/issues/5983 --- firmware/console/binary/tooth_logger.cpp | 4 ++++ firmware/console/binary/tooth_logger.h | 2 ++ firmware/development/perf_trace.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index 64614135b48..e71f7894447 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -326,4 +326,8 @@ void EnableToothLoggerIfNotEnabled() { } } +bool IsToothLoggerEnabled() { + return ToothLoggerEnabled; +} + #endif /* EFI_TOOTH_LOGGER */ diff --git a/firmware/console/binary/tooth_logger.h b/firmware/console/binary/tooth_logger.h index 22c599d518a..f4f4645f06e 100644 --- a/firmware/console/binary/tooth_logger.h +++ b/firmware/console/binary/tooth_logger.h @@ -24,6 +24,8 @@ void EnableToothLogger(); // Stop logging - leave buffer intact void DisableToothLogger(); +bool IsToothLoggerEnabled(); + // A new tooth has arrived! Log to the buffer if enabled. void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp); diff --git a/firmware/development/perf_trace.cpp b/firmware/development/perf_trace.cpp index 2bce68d56c4..a0b027ed863 100644 --- a/firmware/development/perf_trace.cpp +++ b/firmware/development/perf_trace.cpp @@ -117,6 +117,12 @@ void perfEventInstantGlobal(PE event) { } void perfTraceEnable() { + // force release of the buffer if occupied by the tooth logger + if (IsToothLoggerEnabled()) { + // don't worry, it will be automatically enabled + // when the next TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY command arrives + DisableToothLogger(); + } s_traceBuffer = getBigBuffer(BigBufferUser::PerfTrace); s_isTracing = true; }