vlib: stack trace and signal handler improvements

 - use libunwrap which seems to be industry standard
 - display traceback on console if running interactive or with syslog
   disabled (color output unless nocolor specified)
 - print hexdump of offending code
 - print library filename for each stack frame

Type: improvement
Change-Id: I61d3056251b87076be0578ccda300aa311c222ef
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/stack.h b/src/vppinfra/stack.h
new file mode 100644
index 0000000..98a621d
--- /dev/null
+++ b/src/vppinfra/stack.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright (c) 2024 Cisco Systems, Inc.
+ */
+
+#ifndef __STACK_H__
+#define __STACK_H__
+
+#include <vppinfra/clib.h>
+
+typedef struct
+{
+  uword ip, sp;
+  uword offset;
+  char name[64];
+  const char *file_name;
+  u32 index;
+  u8 is_signal_frame;
+} clib_stack_frame_t;
+
+clib_stack_frame_t *clib_stack_frame_get (clib_stack_frame_t *);
+
+#define foreach_clib_stack_frame(sf)                                          \
+  for (clib_stack_frame_t _sf = {}, *sf = clib_stack_frame_get (&_sf); sf;    \
+       sf = clib_stack_frame_get (sf))
+
+#endif /* __STACK_H__ */