sched/procfs:use instrument to statistics run time max stack

Usage:
1. CONFIG_FS_PROCFS_MAX_STACK_RECORD > 0, such as 32,
2. add '-finstrument-functions' to CFLAGS for What you want to check
   stack.
3. mount porcfs
4. cat /proc/<pid>/stack will print backtace & size

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao
2023-10-27 21:57:33 +08:00
committed by Xiang Xiao
parent 7dfbd14eba
commit d932e0af2a
12 changed files with 364 additions and 0 deletions
+9
View File
@@ -251,6 +251,10 @@
# define noinstrument_function __attribute__((no_instrument_function))
/* The nooptimiziation_function attribute no optimize */
# define nooptimiziation_function __attribute__((optimize(0)))
/* The nosanitize_address attribute informs GCC don't sanitize it */
# define nosanitize_address __attribute__((no_sanitize_address))
@@ -555,6 +559,7 @@
# define always_inline_function
# define noinline_function
# define noinstrument_function
# define nooptimiziation_function
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
@@ -698,6 +703,7 @@
# define always_inline_function
# define noinline_function
# define noinstrument_function
# define nooptimiziation_function
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
@@ -809,6 +815,7 @@
# define always_inline_function
# define noinline_function
# define noinstrument_function
# define nooptimiziation_function
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
@@ -899,6 +906,7 @@
# define always_inline_function
# define noinline_function
# define noinstrument_function
# define nooptimiziation_function
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
@@ -964,6 +972,7 @@
# define always_inline_function
# define noinline_function
# define noinstrument_function
# define nooptimiziation_function
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
+11
View File
@@ -645,6 +645,17 @@ struct tcb_s
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator */
#endif
#if CONFIG_SCHED_STACK_RECORD > 0
FAR void *stackrecord_pc[CONFIG_SCHED_STACK_RECORD];
FAR void *stackrecord_sp[CONFIG_SCHED_STACK_RECORD];
FAR void *stackrecord_pc_deepest[CONFIG_SCHED_STACK_RECORD];
FAR void *stackrecord_sp_deepest[CONFIG_SCHED_STACK_RECORD];
FAR void *sp_deepest;
size_t caller_deepest;
size_t level_deepest;
size_t level;
#endif
};
/* struct task_tcb_s ********************************************************/