From 796354ca13e85c37a6233d34429737c8f0cf9e80 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 26 Jul 2019 15:44:39 +0200 Subject: ptalog: Optionally store return values of function calls --- include/object/ptalog.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'include/object') diff --git a/include/object/ptalog.h b/include/object/ptalog.h index 70e9664..808eef8 100644 --- a/include/object/ptalog.h +++ b/include/object/ptalog.h @@ -19,6 +19,9 @@ class PTALog { #ifdef PTALOG_TIMING counter_value_t timer; counter_overflow_t overflow; +#endif +#ifdef PTALOG_WITH_RETURNVALUES + uint16_t return_value; #endif } log_entry; @@ -70,12 +73,14 @@ class PTALog { { kout << "[PTA] trace=" << dec << trace_id << " count=" << log_index << endl; for (uint8_t i = 0; i < log_index; i++) { -#ifdef PTALOG_TIMING kout << "[PTA] transition=" << log[i].transition_id; - kout << " cycles=" << log[i].timer << "/" << log[i].overflow << endl; -#else - kout << "[PTA] transition=" << log[i].transition_id << endl; +#ifdef PTALOG_TIMING + kout << " cycles=" << log[i].timer << "/" << log[i].overflow; +#endif +#ifdef PTALOG_WITH_RETURNVALUES + kout << " return=" << log[i].return_value; #endif + kout << endl; } } @@ -84,6 +89,13 @@ class PTALog { gpio.write(sync_pin, 1); } +#ifdef PTALOG_WITH_RETURNVALUES + inline void logReturn(uint16_t ret) + { + log[log_index - 1].return_value = ret; + } +#endif + #ifdef PTALOG_TIMING inline void stopTransition(Counter& counter) #else -- cgit v1.2.3