From c9e3a0669f0217ed79ec0565d7625c19860a2f98 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Thu, 6 Jul 2023 23:09:29 +0800 Subject: [PATCH] sched_backtrace: define sched_dumpstack when not enable SCHED_BACKTRACE Before directly use sched_backtrace() with SCHED_BACKTRACE disable will lead compile error, this commit avoid this problem by define sched_backtrace to 0 when CONFIG_SCHED_BACKTRACE not enable. Signed-off-by: Bowen Wang --- include/execinfo.h | 17 +++-------------- include/sched.h | 5 +++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/execinfo.h b/include/execinfo.h index ae3a555daa..acee5f273a 100644 --- a/include/execinfo.h +++ b/include/execinfo.h @@ -33,20 +33,9 @@ * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_SCHED_BACKTRACE) - -/* Store up to SIZE return address of the current back trace in - * ARRAY and return the exact number of values stored. - */ - -# define backtrace(buffer, size) sched_backtrace(_SCHED_GETTID(), \ - buffer, size, 0) -# define dump_stack() sched_dumpstack(_SCHED_GETTID()) - -#else -# define backtrace(buffer, size) 0 -# define dump_stack() -#endif +#define backtrace(buffer, size) sched_backtrace(_SCHED_GETTID(), \ + buffer, size, 0) +#define dump_stack() sched_dumpstack(_SCHED_GETTID()) /**************************************************************************** * Public Function Prototypes diff --git a/include/sched.h b/include/sched.h index 79de62b854..f1b77408bd 100644 --- a/include/sched.h +++ b/include/sched.h @@ -267,8 +267,13 @@ bool sched_idletask(void); /* Task Backtrace */ +#ifdef CONFIG_SCHED_BACKTRACE int sched_backtrace(pid_t tid, FAR void **buffer, int size, int skip); void sched_dumpstack(pid_t tid); +#else +# define sched_backtrace(tid, buffer, size, skip) 0 +# define sched_dumpstack(tid) +#endif #undef EXTERN #if defined(__cplusplus)