aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/stack.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2024-10-08 16:43:12 +0200
committerBeno�t Ganne <bganne@cisco.com>2024-11-13 13:02:30 +0000
commit661fb34a90a131658abd726f4faebdc566230cd8 (patch)
tree3b681985edfde1734fb891c49101df77eba9de9f /src/vppinfra/stack.c
parent34083c41b2aea74a82775ce4b74f5bfa8c434106 (diff)
vlib: add clib_stack_frame_get_raw()
clib_stack_frame_get() is getting the backtrace for all threads and does symbol resolution which is too slow for certain features (eg. memory traces). clib_stack_frame_get_raw() only gets the local backtrace and defer symbol resolution only when displaying results. Type: improvement Change-Id: Ia374d86e9175b6648a39ed5aaa676ceb7235e877 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vppinfra/stack.c')
-rw-r--r--src/vppinfra/stack.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/vppinfra/stack.c b/src/vppinfra/stack.c
index 190e880c228..12b24e3189f 100644
--- a/src/vppinfra/stack.c
+++ b/src/vppinfra/stack.c
@@ -17,7 +17,30 @@
static __thread unw_cursor_t cursor;
static __thread unw_context_t context;
-#endif
+#endif /* HAVE_LIBUNWIND */
+
+__clib_export int
+clib_stack_frame_get_raw (void **sf, int n, int skip)
+{
+#if HAVE_LIBUNWIND == 1
+ void *sf__[20];
+ int n__;
+
+ /* Also skip current frame. */
+ skip++;
+ n__ = unw_backtrace (sf__, clib_min (ARRAY_LEN (sf__), n + skip));
+
+ if (n__ <= skip)
+ return 0;
+ else if (n__ - skip < n)
+ n = n__ - skip;
+
+ clib_memcpy_fast (&sf[0], &sf__[skip], n * sizeof (sf[0]));
+ return n;
+#else /* HAVE_LIBUNWIND */
+ return 0;
+#endif /* HAVE_LIBUNWIND */
+}
__clib_export clib_stack_frame_t *
clib_stack_frame_get (clib_stack_frame_t *sf)