This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH 09/12] mips: add basic unwind support
- From: Marcin Nowakowski <marcin dot nowakowski at imgtec dot com>
- To: <systemtap at sourceware dot org>
- Cc: Marcin Nowakowski <marcin dot nowakowski at imgtec dot com>
- Date: Tue, 11 Oct 2016 10:14:25 +0200
- Subject: [PATCH 09/12] mips: add basic unwind support
- Authentication-results: sourceware.org; auth=none
- References: <1476173668-30787-1-git-send-email-marcin.nowakowski@imgtec.com>
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
---
runtime/linux/runtime.h | 2 +-
runtime/unwind/mips.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
runtime/unwind/unwind.h | 2 ++
3 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 runtime/unwind/mips.h
diff --git a/runtime/linux/runtime.h b/runtime/linux/runtime.h
index beffdb5..1ba777d 100644
--- a/runtime/linux/runtime.h
+++ b/runtime/linux/runtime.h
@@ -165,7 +165,7 @@ static struct
Only define STP_USE_DWARF_UNWINDER when STP_NEED_UNWIND_DATA,
as set through a pragma:unwind in one of the [u]context-unwind.stp
functions. */
-#if (defined(__arm__) || defined(__i386__) || defined(__x86_64__) || defined(__powerpc64__)) || defined (__s390x__) || defined(__aarch64__)
+#if (defined(__arm__) || defined(__i386__) || defined(__x86_64__) || defined(__powerpc64__)) || defined (__s390x__) || defined(__aarch64__) || defined(__mips__)
#ifdef STP_NEED_UNWIND_DATA
#ifndef STP_USE_DWARF_UNWINDER
#define STP_USE_DWARF_UNWINDER
diff --git a/runtime/unwind/mips.h b/runtime/unwind/mips.h
new file mode 100644
index 0000000..8538dfc
--- /dev/null
+++ b/runtime/unwind/mips.h
@@ -0,0 +1,79 @@
+/* -*- linux-c -*-
+ *
+ * MIPS dwarf unwinder header file
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+#ifndef _STP_ARM_UNWIND_H
+#define _STP_ARM_UNWIND_H
+
+#include <linux/sched.h>
+#include <asm/ptrace.h>
+
+#define _stp_get_unaligned(ptr) (*(ptr))
+
+#define UNW_PC(frame) (frame)->regs.cp0_epc
+#define UNW_SP(frame) (frame)->regs.regs[29]
+
+#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
+
+#define UNW_REGISTER_INFO \
+ PTREGS_INFO(regs[0]), \
+ PTREGS_INFO(regs[1]), \
+ PTREGS_INFO(regs[2]), \
+ PTREGS_INFO(regs[3]), \
+ PTREGS_INFO(regs[4]), \
+ PTREGS_INFO(regs[5]), \
+ PTREGS_INFO(regs[6]), \
+ PTREGS_INFO(regs[7]), \
+ PTREGS_INFO(regs[8]), \
+ PTREGS_INFO(regs[9]), \
+ PTREGS_INFO(regs[10]), \
+ PTREGS_INFO(regs[11]), \
+ PTREGS_INFO(regs[12]), \
+ PTREGS_INFO(regs[13]), \
+ PTREGS_INFO(regs[14]), \
+ PTREGS_INFO(regs[16]), \
+ PTREGS_INFO(regs[17]), \
+ PTREGS_INFO(regs[18]), \
+ PTREGS_INFO(regs[19]), \
+ PTREGS_INFO(regs[20]), \
+ PTREGS_INFO(regs[21]), \
+ PTREGS_INFO(regs[22]), \
+ PTREGS_INFO(regs[23]), \
+ PTREGS_INFO(regs[24]), \
+ PTREGS_INFO(regs[26]), \
+ PTREGS_INFO(regs[27]), \
+ PTREGS_INFO(regs[28]), \
+ PTREGS_INFO(regs[29]), \
+ PTREGS_INFO(regs[30]), \
+ PTREGS_INFO(regs[31]), \
+ PTREGS_INFO(lo), \
+ PTREGS_INFO(hi), \
+ PTREGS_INFO(cp0_epc)
+
+#define UNW_PC_IDX 34
+#define UNW_SP_IDX 29
+
+/* Use default rules. The stack pointer should be set from the CFA.
+ And the instruction pointer should be set from the return address
+ column (which normally is the return register (regs[31]). */
+
+static inline void arch_unw_init_frame_info(struct unwind_frame_info *info,
+ /*const*/ struct pt_regs *regs,
+ int sanitize)
+{
+ if (&info->regs == regs) { /* happens when unwinding kernel->user */
+ info->call_frame = 1;
+ return;
+ }
+
+ memset(info, 0, sizeof(*info));
+ /* XXX handle sanitize??? */
+ info->regs = *regs;
+}
+
+#endif /* _STP_ARM_UNWIND_H */
diff --git a/runtime/unwind/unwind.h b/runtime/unwind/unwind.h
index f16c983..9d66732 100644
--- a/runtime/unwind/unwind.h
+++ b/runtime/unwind/unwind.h
@@ -34,6 +34,8 @@ struct unwind_frame_info
#include "arm.h"
#elif defined (__aarch64__)
#include "arm64.h"
+#elif defined (__mips__)
+#include "mips.h"
#else
#error "Unsupported dwarf unwind architecture"
#endif
--
2.7.4