vppinfra: Make program counter printing more portable
Finding the program counter in the ucontext struct is platform and
architecture specific, place the Linux checks inside an #ifdef and add a
look up for the FreeBSD amd64 specific naming.
Type: improvement
Change-Id: I42fcef5f20227c23d84acee336e37c4870146bb4
Signed-off-by: Tom Jones <thj@freebsd.org>
diff --git a/src/vppinfra/unix-formats.c b/src/vppinfra/unix-formats.c
index d46b00a..297a3fd 100644
--- a/src/vppinfra/unix-formats.c
+++ b/src/vppinfra/unix-formats.c
@@ -432,6 +432,7 @@
uc = va_arg (*args, ucontext_t *);
+#ifdef __linux__
#if defined (powerpc)
regs = &uc->uc_mcontext.uc_regs->gregs[0];
#elif defined (powerpc64)
@@ -454,6 +455,13 @@
reg_no = 0;
regs = 0;
#endif
+#elif __FreeBSD__
+#if defined(__amd64__)
+ reg_no = 0;
+ regs = (void *) &uc->uc_mcontext.mc_rip;
+#else
+#endif /* __amd64__ */
+#endif /* __linux__ */
if (! regs)
return format (s, "unsupported");