public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
@ 2009-11-27 22:32 Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 4/8] Implement ppc32 variant of __is_user_regs Anton Vorontsov
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:32 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

Hi all,

Here are some patches that add systemtap support for ppc32 machines.

This is all pretty straightforward, though I didn't test it much,
only run few 'hello world' taps and decided that it's good enough. ;-)

I plan to test it more thoughtfully sometime next week, and fix missing
things (if any). But so far I'm interested in the feedback on this
initial support.

Thanks!

p.s. I though it would be a good idea to cc linuxppc-dev. At least
kexec-tools guys tend to do it as well.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/8] Rename uprobes_ppc64.c to uprobes_ppc.c, use it for  ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 4/8] Implement ppc32 variant of __is_user_regs Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 3/8] stack-ppc: Adjust for ppc32 Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 7/8] Implement _div64 and _mod64 " Anton Vorontsov
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

The code *looks* generic enough, so I think it can be used for ppc32
without modifications.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/uprobes/uprobes_arch.c  |    4 +-
 runtime/uprobes/uprobes_arch.h  |    4 +-
 runtime/uprobes/uprobes_ppc.c   |  147 +++++++++++++++++++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc.h   |   82 ++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc64.c |  147 ---------------------------------------
 runtime/uprobes/uprobes_ppc64.h |   82 ----------------------
 runtime/uprobes2/uprobes_arch.c |    4 +-
 runtime/uprobes2/uprobes_arch.h |    4 +-
 8 files changed, 237 insertions(+), 237 deletions(-)
 create mode 100644 runtime/uprobes/uprobes_ppc.c
 create mode 100644 runtime/uprobes/uprobes_ppc.h
 delete mode 100644 runtime/uprobes/uprobes_ppc64.c
 delete mode 100644 runtime/uprobes/uprobes_ppc64.h

diff --git a/runtime/uprobes/uprobes_arch.c b/runtime/uprobes/uprobes_arch.c
index 99ef54c..6c58d5f 100644
--- a/runtime/uprobes/uprobes_arch.c
+++ b/runtime/uprobes/uprobes_arch.c
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.c"
 #elif defined (__i386__)
 #include "uprobes_i386.c"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.c"
 #else
diff --git a/runtime/uprobes/uprobes_arch.h b/runtime/uprobes/uprobes_arch.h
index 0223e28..f642f52 100644
--- a/runtime/uprobes/uprobes_arch.h
+++ b/runtime/uprobes/uprobes_arch.h
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.h"
 #elif defined (__i386__)
 #include "uprobes_i386.h"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.h"
 #else
diff --git a/runtime/uprobes/uprobes_ppc.c b/runtime/uprobes/uprobes_ppc.c
new file mode 100644
index 0000000..819ac73
--- /dev/null
+++ b/runtime/uprobes/uprobes_ppc.c
@@ -0,0 +1,147 @@
+/*
+ * Userspace Probes (UProbes) for PowerPC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ */
+/*
+ * In versions of uprobes built in the SystemTap runtime, this file
+ * is #included at the end of uprobes.c.
+ */
+
+/*
+ * Replace the return address with the trampoline address.  Returns
+ * the original return address.
+ */
+static
+unsigned long arch_hijack_uret_addr(unsigned long trampoline_address,
+		struct pt_regs *regs, struct uprobe_task *utask)
+{
+	unsigned long orig_ret_addr = regs->link;
+
+	regs->link = trampoline_address;
+	return orig_ret_addr;
+}
+
+/*
+ * Get an instruction slot from the process's SSOL area, containing the
+ * instruction at ppt's probepoint.  Point the eip at that slot, in preparation
+ * for single-stepping out of line.
+ */
+static
+void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
+		struct pt_regs *regs)
+{
+	struct uprobe_ssol_slot *slot;
+
+	slot = uprobe_get_insn_slot(ppt);
+	if (!slot) {
+		utask->doomed = 1;
+		return;
+	}
+	regs->nip = (long)slot->insn;
+}
+
+
+static inline void calc_offset(struct uprobe_probept *ppt,
+	       struct pt_regs *regs)
+{
+	int offset = 0;
+	unsigned int opcode = 0;
+	unsigned int insn = *ppt->insn;
+
+	opcode = insn >> 26;
+	switch (opcode) {
+	case 16:	/* bc */
+		if ((insn & 2) == 0) {
+			offset = (signed short)(insn & 0xfffc);
+			regs->nip = ppt->vaddr + offset;
+		}
+		if (insn & 1)
+			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
+		break;
+	case 17:	/* sc */
+		/* Do we need to do anything */
+		break;
+	case 18:	/* b */
+		if ((insn & 2) == 0) {
+			offset = insn & 0x03fffffc;
+			if (offset & 0x02000000)
+				offset -= 0x04000000;
+			regs->nip = ppt->vaddr + offset;
+		}
+		if (insn & 1)
+			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
+		break;
+	}
+#ifdef UPROBES_DEBUG
+	printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n",
+			ppt->vaddr, regs->nip, offset);
+	if (insn & 1)
+		printk (KERN_ERR "regs->link=%p \n", regs->link);
+#endif
+	return;
+}
+
+/*
+ * Called after single-stepping.  ppt->vaddr is the address of the
+ * instruction which was replaced by a breakpoint instruction.  To avoid
+ * the SMP problems that can occur when we temporarily put back the
+ * original opcode to single-step, we single-stepped a copy of the
+ * instruction.
+ *
+ * This function prepares to return from the post-single-step
+ * interrupt.
+ *
+ * 1) Typically, the new nip is relative to the copied instruction.  We
+ * need to make it relative to the original instruction.  Exceptions are
+ * branch instructions.
+ *
+ * 2) For branch instructions, update the nip if the branch uses
+ * relative addressing.  Update the link instruction to the instruction
+ * following the original instruction address.
+ */
+
+static
+void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
+		struct pt_regs *regs)
+{
+	unsigned long copy_nip;
+
+	copy_nip = (unsigned long) ppt->slot->insn;
+	up_read(&ppt->slot->rwsem);
+
+	/*
+	 * If the single stepped instruction is non-branch instruction
+	 * then update the IP to be relative to probepoint.
+	 */
+	if (regs->nip == copy_nip + MAX_UINSN_BYTES)
+		regs->nip = ppt->vaddr + MAX_UINSN_BYTES;
+	else
+		calc_offset(ppt,regs);
+}
+
+static
+int arch_validate_probed_insn(struct uprobe_probept *ppt,
+		 struct task_struct *tsk)
+{
+	if ((unsigned long)ppt->vaddr & 0x03) {
+		printk(KERN_WARNING
+			"Attempt to register uprobe at an unaligned addr\n");
+		return -EINVAL;
+	}
+	return 0;
+}
diff --git a/runtime/uprobes/uprobes_ppc.h b/runtime/uprobes/uprobes_ppc.h
new file mode 100644
index 0000000..5604635
--- /dev/null
+++ b/runtime/uprobes/uprobes_ppc.h
@@ -0,0 +1,82 @@
+#ifndef _ASM_UPROBES_H
+#define _ASM_UPROBES_H
+/*
+ * Userspace Probes (UProbes) for PowerPC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ */
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/signal.h>
+
+#define BREAKPOINT_SIGNAL SIGTRAP
+#define SSTEP_SIGNAL SIGTRAP
+
+/* Normally defined in Kconfig */
+#define CONFIG_UPROBES_SSOL
+#define CONFIG_URETPROBES 1
+
+typedef unsigned int uprobe_opcode_t;
+#define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
+#define BP_INSN_SIZE 4
+#define MAX_UINSN_BYTES 4
+#define SLOT_IP(tsk) 32	/* instruction pointer slot from include/asm/elf.h */
+
+struct uprobe_probept_arch_info {};
+struct uprobe_task_arch_info {};
+
+/* Architecture specific switch for where the IP points after a bp hit */
+#define ARCH_BP_INST_PTR(inst_ptr)	(inst_ptr)
+
+struct uprobe_probept;
+struct uprobe_task;
+struct task_struct;
+
+/* On powerpc, nip points to the trap. */
+static inline unsigned long arch_get_probept(struct pt_regs *regs)
+{
+	return (unsigned long)(regs->nip);
+}
+
+static inline void arch_reset_ip_for_sstep(struct pt_regs *regs)
+{
+}
+
+static inline int arch_validate_probed_insn(struct uprobe_probept *ppt,
+						struct task_struct *tsk);
+
+static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr,
+		struct pt_regs *regs, struct uprobe_task *utask);
+
+static inline void arch_restore_uret_addr(unsigned long ret_addr,
+		struct pt_regs *regs)
+{
+	regs->nip = ret_addr;
+}
+
+static unsigned long arch_get_cur_sp(struct pt_regs *regs)
+{
+	return (unsigned long)(regs->gpr[1]);
+}
+
+static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs,
+		struct task_struct *tsk)
+{
+	return (unsigned long)(regs->gpr[1]);
+}
+
+#endif				/* _ASM_UPROBES_H */
diff --git a/runtime/uprobes/uprobes_ppc64.c b/runtime/uprobes/uprobes_ppc64.c
deleted file mode 100644
index 819ac73..0000000
--- a/runtime/uprobes/uprobes_ppc64.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Userspace Probes (UProbes) for PowerPC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation, 2007
- */
-/*
- * In versions of uprobes built in the SystemTap runtime, this file
- * is #included at the end of uprobes.c.
- */
-
-/*
- * Replace the return address with the trampoline address.  Returns
- * the original return address.
- */
-static
-unsigned long arch_hijack_uret_addr(unsigned long trampoline_address,
-		struct pt_regs *regs, struct uprobe_task *utask)
-{
-	unsigned long orig_ret_addr = regs->link;
-
-	regs->link = trampoline_address;
-	return orig_ret_addr;
-}
-
-/*
- * Get an instruction slot from the process's SSOL area, containing the
- * instruction at ppt's probepoint.  Point the eip at that slot, in preparation
- * for single-stepping out of line.
- */
-static
-void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
-		struct pt_regs *regs)
-{
-	struct uprobe_ssol_slot *slot;
-
-	slot = uprobe_get_insn_slot(ppt);
-	if (!slot) {
-		utask->doomed = 1;
-		return;
-	}
-	regs->nip = (long)slot->insn;
-}
-
-
-static inline void calc_offset(struct uprobe_probept *ppt,
-	       struct pt_regs *regs)
-{
-	int offset = 0;
-	unsigned int opcode = 0;
-	unsigned int insn = *ppt->insn;
-
-	opcode = insn >> 26;
-	switch (opcode) {
-	case 16:	/* bc */
-		if ((insn & 2) == 0) {
-			offset = (signed short)(insn & 0xfffc);
-			regs->nip = ppt->vaddr + offset;
-		}
-		if (insn & 1)
-			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
-		break;
-	case 17:	/* sc */
-		/* Do we need to do anything */
-		break;
-	case 18:	/* b */
-		if ((insn & 2) == 0) {
-			offset = insn & 0x03fffffc;
-			if (offset & 0x02000000)
-				offset -= 0x04000000;
-			regs->nip = ppt->vaddr + offset;
-		}
-		if (insn & 1)
-			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
-		break;
-	}
-#ifdef UPROBES_DEBUG
-	printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n",
-			ppt->vaddr, regs->nip, offset);
-	if (insn & 1)
-		printk (KERN_ERR "regs->link=%p \n", regs->link);
-#endif
-	return;
-}
-
-/*
- * Called after single-stepping.  ppt->vaddr is the address of the
- * instruction which was replaced by a breakpoint instruction.  To avoid
- * the SMP problems that can occur when we temporarily put back the
- * original opcode to single-step, we single-stepped a copy of the
- * instruction.
- *
- * This function prepares to return from the post-single-step
- * interrupt.
- *
- * 1) Typically, the new nip is relative to the copied instruction.  We
- * need to make it relative to the original instruction.  Exceptions are
- * branch instructions.
- *
- * 2) For branch instructions, update the nip if the branch uses
- * relative addressing.  Update the link instruction to the instruction
- * following the original instruction address.
- */
-
-static
-void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
-		struct pt_regs *regs)
-{
-	unsigned long copy_nip;
-
-	copy_nip = (unsigned long) ppt->slot->insn;
-	up_read(&ppt->slot->rwsem);
-
-	/*
-	 * If the single stepped instruction is non-branch instruction
-	 * then update the IP to be relative to probepoint.
-	 */
-	if (regs->nip == copy_nip + MAX_UINSN_BYTES)
-		regs->nip = ppt->vaddr + MAX_UINSN_BYTES;
-	else
-		calc_offset(ppt,regs);
-}
-
-static
-int arch_validate_probed_insn(struct uprobe_probept *ppt,
-		 struct task_struct *tsk)
-{
-	if ((unsigned long)ppt->vaddr & 0x03) {
-		printk(KERN_WARNING
-			"Attempt to register uprobe at an unaligned addr\n");
-		return -EINVAL;
-	}
-	return 0;
-}
diff --git a/runtime/uprobes/uprobes_ppc64.h b/runtime/uprobes/uprobes_ppc64.h
deleted file mode 100644
index 5604635..0000000
--- a/runtime/uprobes/uprobes_ppc64.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef _ASM_UPROBES_H
-#define _ASM_UPROBES_H
-/*
- * Userspace Probes (UProbes) for PowerPC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation, 2007
- */
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/signal.h>
-
-#define BREAKPOINT_SIGNAL SIGTRAP
-#define SSTEP_SIGNAL SIGTRAP
-
-/* Normally defined in Kconfig */
-#define CONFIG_UPROBES_SSOL
-#define CONFIG_URETPROBES 1
-
-typedef unsigned int uprobe_opcode_t;
-#define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
-#define BP_INSN_SIZE 4
-#define MAX_UINSN_BYTES 4
-#define SLOT_IP(tsk) 32	/* instruction pointer slot from include/asm/elf.h */
-
-struct uprobe_probept_arch_info {};
-struct uprobe_task_arch_info {};
-
-/* Architecture specific switch for where the IP points after a bp hit */
-#define ARCH_BP_INST_PTR(inst_ptr)	(inst_ptr)
-
-struct uprobe_probept;
-struct uprobe_task;
-struct task_struct;
-
-/* On powerpc, nip points to the trap. */
-static inline unsigned long arch_get_probept(struct pt_regs *regs)
-{
-	return (unsigned long)(regs->nip);
-}
-
-static inline void arch_reset_ip_for_sstep(struct pt_regs *regs)
-{
-}
-
-static inline int arch_validate_probed_insn(struct uprobe_probept *ppt,
-						struct task_struct *tsk);
-
-static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr,
-		struct pt_regs *regs, struct uprobe_task *utask);
-
-static inline void arch_restore_uret_addr(unsigned long ret_addr,
-		struct pt_regs *regs)
-{
-	regs->nip = ret_addr;
-}
-
-static unsigned long arch_get_cur_sp(struct pt_regs *regs)
-{
-	return (unsigned long)(regs->gpr[1]);
-}
-
-static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs,
-		struct task_struct *tsk)
-{
-	return (unsigned long)(regs->gpr[1]);
-}
-
-#endif				/* _ASM_UPROBES_H */
diff --git a/runtime/uprobes2/uprobes_arch.c b/runtime/uprobes2/uprobes_arch.c
index 3c86804..a91d5b6 100644
--- a/runtime/uprobes2/uprobes_arch.c
+++ b/runtime/uprobes2/uprobes_arch.c
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.c"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.c"
 #elif defined (__ia64__)
diff --git a/runtime/uprobes2/uprobes_arch.h b/runtime/uprobes2/uprobes_arch.h
index 87e0cc8..cce5775 100644
--- a/runtime/uprobes2/uprobes_arch.h
+++ b/runtime/uprobes2/uprobes_arch.h
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.h"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.h"
 #elif defined (__ia64__)
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 5/8] Share ppc64 and ppc32 code where possible
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (5 preceding siblings ...)
  2009-11-27 22:33 ` [PATCH 2/8] Rename stack-ppc64.c to stack-ppc.c Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:57 ` [PATCH 6/8] Use proper types for do_div Anton Vorontsov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

* runtime/copy.c: Can use ppc64's code.
* runtime/regs.h: Ditto.
* runtime/string.h: Ditto.
* tapset/context.stp: Ditto.
* tapset/errno.stp: Ditto.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/copy.c     |    2 +-
 runtime/regs.h     |    2 +-
 runtime/string.h   |    6 +++---
 tapset/context.stp |    2 +-
 tapset/errno.stp   |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/runtime/copy.c b/runtime/copy.c
index 4fb8725..40f1511 100644
--- a/runtime/copy.c
+++ b/runtime/copy.c
@@ -105,7 +105,7 @@ do {									   \
 		: "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
 		: "memory");						   \
 } while (0)
-#elif defined (__powerpc64__) || defined (__ia64__) || defined (__arm__)
+#elif defined (__powerpc__) || defined (__ia64__) || defined (__arm__)
 #define __stp_strncpy_from_user(dst,src,count,res) \
 	do { res = __strncpy_from_user(dst, src, count); } while(0)
 
diff --git a/runtime/regs.h b/runtime/regs.h
index dc6b50a..08449aa 100644
--- a/runtime/regs.h
+++ b/runtime/regs.h
@@ -36,7 +36,7 @@
   (((regs)->cr_iip = (x) & ~3UL), (ia64_psr(regs)->ri = (x) & 3UL))
 
 
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 
 #define REG_IP(regs) regs->nip
 #define REG_SP(regs) regs->gpr[1]
diff --git a/runtime/string.h b/runtime/string.h
index f4d4cc0..b08304e 100644
--- a/runtime/string.h
+++ b/runtime/string.h
@@ -19,14 +19,14 @@ static void _stp_text_str(char *out, char *in, int len, int quoted, int user);
  * is provided without the paranoid check. Use it if available, fall back
  * to __get_user() if not. Other archs can use __get_user() as is
  */
-#ifdef __powerpc64__
+#if defined(__powerpc__)
 #ifdef __get_user_inatomic
 #define __stp_get_user(x, ptr) __get_user_inatomic(x, ptr)
 #else /* __get_user_inatomic */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
 #endif /* __get_user_inatomic */
-#else /* __powerpc64__ */
+#else /* defined(__powerpc__) */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
-#endif /* __powerpc64__ */
+#endif /* defined(__powerpc__) */
 
 #endif /* _STRING_H_ */
diff --git a/tapset/context.stp b/tapset/context.stp
index 36701e6..b30f7dc 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -15,7 +15,7 @@
 %{
 #include <asm/processor.h>
 
-#if defined(__powerpc64__)
+#if defined(__powerpc__)
 #if !defined(task_pt_regs)
 #define task_pt_regs(tsk)       ((struct pt_regs *)(tsk)->thread.regs)
 #endif
diff --git a/tapset/errno.stp b/tapset/errno.stp
index 011ff7e..d4d571b 100644
--- a/tapset/errno.stp
+++ b/tapset/errno.stp
@@ -369,7 +369,7 @@ static long _stp_returnval(struct pt_regs *regs) {
 #elif defined (__x86_64__)
 		// TODO: Handle -m32 apps.
 		return regs->rax;
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 		return regs->gpr[3];
 #elif defined (__ia64__)
 		return regs->r8;
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/8] Rename stack-ppc64.c to stack-ppc.c
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (4 preceding siblings ...)
  2009-11-27 22:33 ` [PATCH 8/8] Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32 Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 5/8] Share ppc64 and ppc32 code where possible Anton Vorontsov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

There should be no functional changes in this patch.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stack-ppc.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++++
 runtime/stack-ppc64.c |   62 -------------------------------------------------
 runtime/stack.c       |    2 +-
 3 files changed, 63 insertions(+), 63 deletions(-)
 create mode 100644 runtime/stack-ppc.c
 delete mode 100644 runtime/stack-ppc64.c

diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c
new file mode 100644
index 0000000..3267194
--- /dev/null
+++ b/runtime/stack-ppc.c
@@ -0,0 +1,62 @@
+/* -*- linux-c -*-
+ * ppc64 stack tracing functions
+ *
+ * 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.
+ */
+
+static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
+                               struct task_struct *tsk)
+{
+	unsigned long ip, newsp, lr = 0;
+	int count = 0;
+	int firstframe = 1;
+	unsigned long *_sp = (unsigned long *)&REG_SP(regs);	
+	unsigned long sp = (unsigned long)_sp;
+	lr = 0;
+	do {
+		if (sp < KERNELBASE)
+			return;
+		_sp = (unsigned long *) sp;
+		newsp = _sp[0];
+		ip = _sp[2];
+		if (!firstframe || ip != lr) {
+			if (verbose) {
+				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
+				_stp_symbol_print(ip);
+				if (firstframe)
+					_stp_print(" (unreliable)");
+				_stp_print_char('\n');
+			}
+			else
+				_stp_printf("0x%016lx ", ip);
+		}
+		firstframe = 0;
+		/*
+		 * See if this is an exception frame.
+		 * We look for the "regshere" marker in the current frame.
+		 */
+		if ( _sp[12] == 0x7265677368657265ul) {
+			struct pt_regs *regs = (struct pt_regs *)
+				(sp + STACK_FRAME_OVERHEAD);
+			if (verbose) {
+				_stp_printf("--- Exception: %lx at ",regs->trap);
+				_stp_symbol_print(regs->nip);
+				_stp_print_char('\n');
+				lr = regs->link;
+				_stp_print("    LR =");
+				_stp_symbol_print(lr);
+				_stp_print_char('\n');
+				firstframe = 1;
+			}
+			else {
+				_stp_printf("0x%016lx ",regs->nip);
+				_stp_printf("0x%016lx ",regs->link);
+			}
+		}
+
+		sp = newsp;
+	} while (count++ < MAXBACKTRACE);
+}
diff --git a/runtime/stack-ppc64.c b/runtime/stack-ppc64.c
deleted file mode 100644
index 3267194..0000000
--- a/runtime/stack-ppc64.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- linux-c -*-
- * ppc64 stack tracing functions
- *
- * 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.
- */
-
-static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
-                               struct task_struct *tsk)
-{
-	unsigned long ip, newsp, lr = 0;
-	int count = 0;
-	int firstframe = 1;
-	unsigned long *_sp = (unsigned long *)&REG_SP(regs);	
-	unsigned long sp = (unsigned long)_sp;
-	lr = 0;
-	do {
-		if (sp < KERNELBASE)
-			return;
-		_sp = (unsigned long *) sp;
-		newsp = _sp[0];
-		ip = _sp[2];
-		if (!firstframe || ip != lr) {
-			if (verbose) {
-				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
-				_stp_symbol_print(ip);
-				if (firstframe)
-					_stp_print(" (unreliable)");
-				_stp_print_char('\n');
-			}
-			else
-				_stp_printf("0x%016lx ", ip);
-		}
-		firstframe = 0;
-		/*
-		 * See if this is an exception frame.
-		 * We look for the "regshere" marker in the current frame.
-		 */
-		if ( _sp[12] == 0x7265677368657265ul) {
-			struct pt_regs *regs = (struct pt_regs *)
-				(sp + STACK_FRAME_OVERHEAD);
-			if (verbose) {
-				_stp_printf("--- Exception: %lx at ",regs->trap);
-				_stp_symbol_print(regs->nip);
-				_stp_print_char('\n');
-				lr = regs->link;
-				_stp_print("    LR =");
-				_stp_symbol_print(lr);
-				_stp_print_char('\n');
-				firstframe = 1;
-			}
-			else {
-				_stp_printf("0x%016lx ",regs->nip);
-				_stp_printf("0x%016lx ",regs->link);
-			}
-		}
-
-		sp = newsp;
-	} while (count++ < MAXBACKTRACE);
-}
diff --git a/runtime/stack.c b/runtime/stack.c
index 042f44c..ae89995 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -41,7 +41,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #elif  defined (__i386__)
 #include "stack-i386.c"
 #elif defined (__powerpc64__)
-#include "stack-ppc64.c"
+#include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
 #elif defined (__s390__) || defined (__s390x__)
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 8/8] Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (3 preceding siblings ...)
  2009-11-27 22:33 ` [PATCH 7/8] Implement _div64 and _mod64 " Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 2/8] Rename stack-ppc64.c to stack-ppc.c Anton Vorontsov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

Currently staprun fails at send_relocation_kernel(), this is because
ppc32 doesn't have ".__start" symbol. I think we should use _stext,
just as other arches.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/staprun/staprun.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c
index 078be4c..5bd5163 100644
--- a/runtime/staprun/staprun.c
+++ b/runtime/staprun/staprun.c
@@ -372,7 +372,7 @@ int send_relocation_kernel ()
               free (line); line=NULL;
               if (symbol == NULL) continue; /* OOM? */
 
-#ifdef __powerpc__
+#ifdef __powerpc64__
 #define KERNEL_RELOC_SYMBOL ".__start"
 #else
 #define KERNEL_RELOC_SYMBOL "_stext"
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 4/8] Implement ppc32 variant of __is_user_regs
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 3/8] stack-ppc: Adjust for ppc32 Anton Vorontsov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

* tapset/nd_syscalls.stp: Implement ppc32 variant of __is_user_regs.
* tapset/syscalls.stp: Ditto.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 tapset/nd_syscalls.stp |    3 +++
 tapset/syscalls.stp    |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp
index f9a6ffc..e7492a1 100644
--- a/tapset/nd_syscalls.stp
+++ b/tapset/nd_syscalls.stp
@@ -1320,6 +1320,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp
index dde0ca9..430d37f 100644
--- a/tapset/syscalls.stp
+++ b/tapset/syscalls.stp
@@ -1093,6 +1093,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/8] stack-ppc: Adjust for ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 4/8] Implement ppc32 variant of __is_user_regs Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 1/8] Rename uprobes_ppc64.c to uprobes_ppc.c, use it " Anton Vorontsov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

Get rid of magic numbers, use appropriate defines from ptrace.h.

From now on stack-ppc.c should be suitable for ppc32.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stack-ppc.c |    4 ++--
 runtime/stack.c     |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c
index 3267194..df2db15 100644
--- a/runtime/stack-ppc.c
+++ b/runtime/stack-ppc.c
@@ -21,7 +21,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 			return;
 		_sp = (unsigned long *) sp;
 		newsp = _sp[0];
-		ip = _sp[2];
+		ip = _sp[STACK_FRAME_LR_SAVE];
 		if (!firstframe || ip != lr) {
 			if (verbose) {
 				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
@@ -38,7 +38,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 		 * See if this is an exception frame.
 		 * We look for the "regshere" marker in the current frame.
 		 */
-		if ( _sp[12] == 0x7265677368657265ul) {
+		if (_sp[STACK_FRAME_MARKER] == STACK_FRAME_REGS_MARKER) {
 			struct pt_regs *regs = (struct pt_regs *)
 				(sp + STACK_FRAME_OVERHEAD);
 			if (verbose) {
diff --git a/runtime/stack.c b/runtime/stack.c
index ae89995..25dbdbb 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -40,7 +40,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #include "stack-ia64.c"
 #elif  defined (__i386__)
 #include "stack-i386.c"
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 #include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 7/8] Implement _div64 and _mod64 for ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (2 preceding siblings ...)
  2009-11-27 22:33 ` [PATCH 1/8] Rename uprobes_ppc64.c to uprobes_ppc.c, use it " Anton Vorontsov
@ 2009-11-27 22:33 ` Anton Vorontsov
  2009-11-27 22:33 ` [PATCH 8/8] Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32 Anton Vorontsov
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

_div64 and _mod64 arch-specific details were taken from gcc/longlong.h,
just as it was done for i386.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/arith.c |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/runtime/arith.c b/runtime/arith.c
index 4c818a7..a032e9c 100644
--- a/runtime/arith.c
+++ b/runtime/arith.c
@@ -20,7 +20,8 @@
 /* 64-bit division for 64-bit cpus and i386 */
 /* Other 32-bit cpus will need to modify this file. */
 
-#if defined (__i386__) || defined(__arm__)
+#if defined (__i386__) || defined(__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 static long long _div64 (long long u, long long v);
 static long long _mod64 (long long u, long long v);
 #endif
@@ -114,7 +115,8 @@ static int _stp_random_pm (unsigned n)
 
 
 
-#if defined (__i386__) || defined (__arm__)
+#if defined (__i386__) || defined (__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 
 /* 64-bit division functions extracted from libgcc */
 typedef long long DWtype;
@@ -181,6 +183,40 @@ typedef union
 		(count) = __cbtmp ^ 31;					\
 	} while (0)
 
+#elif defined (__powerpc__)
+/* these are the ppc versions of these macros from gcc/longlong.h */
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  do {									\
+    if (__builtin_constant_p (ah) && (ah) == 0)				\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == 0)			\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else								\
+      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"	\
+	       : "=r" (sh), "=&r" (sl)					\
+	       : "r" (ah), "r" (bh), "rI" (al), "r" (bl));		\
+  } while (0)
+
+#define count_leading_zeros(count, x) \
+  __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 32
+
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {									\
+    USItype __m0 = (m0), __m1 = (m1);					\
+    __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));	\
+    (pl) = __m0 * __m1;							\
+  } while (0)
+
 #elif defined (__arm__)
 
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
@@ -548,6 +584,6 @@ static long long _mod64 (long long u, long long v)
 	return w;
 }
 
-#endif /* __i386__ || __arm__ */
+#endif /* __i386__ || __arm__ || (__powerpc__ && !__powerpc64__) */
 
 #endif /* _ARITH_C_ */
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 6/8] Use proper types for do_div
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (6 preceding siblings ...)
  2009-11-27 22:33 ` [PATCH 5/8] Share ppc64 and ppc32 code where possible Anton Vorontsov
@ 2009-11-27 22:57 ` Anton Vorontsov
  2009-12-09 15:56   ` Mark Wielaard
  2009-12-01 17:55 ` [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Frank Ch. Eigler
  2009-12-01 19:14 ` Jim Keniston
  9 siblings, 1 reply; 14+ messages in thread
From: Anton Vorontsov @ 2009-11-27 22:57 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

do_div accepts unsigned 64-bit integer type for dividend, signed types
would cause do_div's typecheck fail:

stat-common.c: In function 'needed_space':
stat-common.c:50: error: comparison of distinct pointer types lacks a cast
...same errors in time.c and tapset-timers.cxx's generated code...

A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically
we don't need do_div, but since the whole _stp_gettimeofday_ns() operates
on 64-bit types we'd better be safe and use uint64_t for the math.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stat-common.c |    8 ++++----
 runtime/time.c        |    3 ++-
 tapset-timers.cxx     |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/runtime/stat-common.c b/runtime/stat-common.c
index 7123dc8..f970304 100644
--- a/runtime/stat-common.c
+++ b/runtime/stat-common.c
@@ -34,7 +34,7 @@ static int _stp_stat_calc_buckets(int stop, int start, int interval)
 	return buckets;
 }
 
-static int needed_space(int64_t v)
+static int needed_space(uint64_t v)
 {
 	int space = 0;
 
@@ -134,7 +134,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 {
 	int scale, i, j, val_space, cnt_space;
 	int low_bucket = -1, high_bucket = 0, over = 0, under = 0;
-	int64_t val, v, valmax = 0;
+	uint64_t val, v, valmax = 0;
 	int eliding = 0;
 	char *cur_buf = buf, *fake = buf;
 	char **bufptr = (buf == NULL ? &fake : &cur_buf);
@@ -186,7 +186,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 	if (valmax <= HIST_WIDTH)
 		scale = 1;
 	else {
-		int64_t tmp = valmax;
+		uint64_t tmp = valmax;
 		int rem = do_div(tmp, HIST_WIDTH);
 		scale = tmp;
 		if (rem) scale++;
@@ -282,7 +282,7 @@ static void _stp_stat_print_histogram(Hist st, stat *sd)
 	_stp_print_flush();
 }
 
-static void __stp_stat_add (Hist st, stat *sd, int64_t val)
+static void __stp_stat_add (Hist st, stat *sd, uint64_t val)
 {
 	int n;
 	if (sd->count == 0) {
diff --git a/runtime/time.c b/runtime/time.c
index 58c23e5..d588370 100644
--- a/runtime/time.c
+++ b/runtime/time.c
@@ -275,7 +275,8 @@ static int64_t
 _stp_gettimeofday_ns(void)
 {
     int64_t base;
-    cycles_t last, delta;
+    cycles_t last;
+    uint64_t delta;
     unsigned int freq;
     unsigned int seq;
     stp_time_t *time;
diff --git a/tapset-timers.cxx b/tapset-timers.cxx
index 6574626..7195cfa 100644
--- a/tapset-timers.cxx
+++ b/tapset-timers.cxx
@@ -241,7 +241,7 @@ hrtimer_derived_probe_group::emit_interval (translator_output* o)
 {
   o->line() << "({";
   o->newline(1) << "unsigned long nsecs;";
-  o->newline() << "int64_t i = stp->intrv;";
+  o->newline() << "uint64_t i = stp->intrv;";
   o->newline() << "if (stp->rnd != 0) {";
   // XXX: why not use stp_random_pm instead of this?
   o->newline(1) << "int64_t r;";
-- 
1.6.3.3

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (7 preceding siblings ...)
  2009-11-27 22:57 ` [PATCH 6/8] Use proper types for do_div Anton Vorontsov
@ 2009-12-01 17:55 ` Frank Ch. Eigler
  2009-12-01 19:14 ` Jim Keniston
  9 siblings, 0 replies; 14+ messages in thread
From: Frank Ch. Eigler @ 2009-12-01 17:55 UTC (permalink / raw)
  To: avorontsov; +Cc: systemtap, linuxppc-dev

Anton Vorontsov <avorontsov@ru.mvista.com> writes:

> Here are some patches that add systemtap support for ppc32 machines.
> [...]

Thanks, committed, with a little extra for ppc64 compatibility.

- FChE

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
  2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
                   ` (8 preceding siblings ...)
  2009-12-01 17:55 ` [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Frank Ch. Eigler
@ 2009-12-01 19:14 ` Jim Keniston
  9 siblings, 0 replies; 14+ messages in thread
From: Jim Keniston @ 2009-12-01 19:14 UTC (permalink / raw)
  To: avorontsov, ananth; +Cc: systemtap, linuxppc-dev

On Sat, 2009-11-28 at 01:32 +0300, Anton Vorontsov wrote:
> Hi all,
> 
> Here are some patches that add systemtap support for ppc32 machines.
> 
> This is all pretty straightforward, though I didn't test it much,
> only run few 'hello world' taps and decided that it's good enough. ;-)
> 
> I plan to test it more thoughtfully sometime next week, and fix missing
> things (if any). But so far I'm interested in the feedback on this
> initial support.
> 
> Thanks!
> 
> p.s. I though it would be a good idea to cc linuxppc-dev. At least
> kexec-tools guys tend to do it as well.

I think one thing that got missed was completing the support for ppc32
in tapset/powerpc/registers.stp (functions *_arg and [u_]register).  A
lot of the 32-bit code is already in place, having been copied over from
the x86_64 version, but the _reg_offsets[] array and
_stp_get_register_by_offset() work only for 64-bit contexts.  A comment
at the end of _stp_register_regs() suggests that you can get the correct
32-bit offsets by dividing the 64-bit offsets by 2; compare pt_regs
structs to verify.

I'm cc-ing Ananth, who did the original ppc64 work on this file.

The *_arg and [u_]register functions are described in the stapfuncs man
page (but not in the Language Reference doc).
testsuite/systemtap.context/num_args.tcl tests some of these functions
(or used to, at least).

Jim Keniston

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/8] Use proper types for do_div
  2009-11-27 22:57 ` [PATCH 6/8] Use proper types for do_div Anton Vorontsov
@ 2009-12-09 15:56   ` Mark Wielaard
  2009-12-09 16:09     ` Anton Vorontsov
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Wielaard @ 2009-12-09 15:56 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: systemtap, linuxppc-dev

Hi Anton,

On Sat, 2009-11-28 at 01:33 +0300, Anton Vorontsov wrote: 
> do_div accepts unsigned 64-bit integer type for dividend, signed types
> would cause do_div's typecheck fail:
> 
> stat-common.c: In function 'needed_space':
> stat-common.c:50: error: comparison of distinct pointer types lacks a cast
> ...same errors in time.c and tapset-timers.cxx's generated code...
> 
> A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically
> we don't need do_div, but since the whole _stp_gettimeofday_ns() operates
> on 64-bit types we'd better be safe and use uint64_t for the math.
> 
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>  runtime/stat-common.c |    8 ++++----
>  runtime/time.c        |    3 ++-
>  tapset-timers.cxx     |    2 +-
>  3 files changed, 7 insertions(+), 6 deletions(-)

I don't immediately see anything wrong with the code. But on x86_64 this
does cause some regression test failures in testsuite/systemtap.maps. In
particular the following tests now fail (they all pass with this one
patch reverted):

Running /home/mark/src/systemtap/testsuite/systemtap.maps/elision.exp ...
FAIL: elision-1
FAIL: elision0
FAIL: elision1
FAIL: elision2
FAIL: elision3
Running /home/mark/src/systemtap/testsuite/systemtap.maps/ix.exp ...
FAIL: systemtap.maps/ix.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_large_neg.exp ...
FAIL: systemtap.maps/linear_large_neg.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_overunder.exp ...
FAIL: systemtap.maps/linear_overunder.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_under.exp ...
FAIL: systemtap.maps/linear_under.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/log.exp ...
FAIL: systemtap.maps/log.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/log_edge.exp ...
FAIL: systemtap.maps/log_edge.stp

Could you have a look?

Thanks,

Mark

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/8] Use proper types for do_div
  2009-12-09 15:56   ` Mark Wielaard
@ 2009-12-09 16:09     ` Anton Vorontsov
  2009-12-09 22:48       ` Mark Wielaard
  0 siblings, 1 reply; 14+ messages in thread
From: Anton Vorontsov @ 2009-12-09 16:09 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: systemtap, linuxppc-dev

On Wed, Dec 09, 2009 at 04:56:34PM +0100, Mark Wielaard wrote:
> On Sat, 2009-11-28 at 01:33 +0300, Anton Vorontsov wrote: 
> > do_div accepts unsigned 64-bit integer type for dividend, signed types
> > would cause do_div's typecheck fail:
> > 
> > stat-common.c: In function 'needed_space':
> > stat-common.c:50: error: comparison of distinct pointer types lacks a cast
> > ...same errors in time.c and tapset-timers.cxx's generated code...
> > 
> I don't immediately see anything wrong with the code. But on x86_64 this
> does cause some regression test failures in testsuite/systemtap.maps. In
> particular the following tests now fail (they all pass with this one
> patch reverted):
> 
> Running /home/mark/src/systemtap/testsuite/systemtap.maps/elision.exp ...
> FAIL: elision-1
[...]
> Running /home/mark/src/systemtap/testsuite/systemtap.maps/log_edge.exp ...
> FAIL: systemtap.maps/log_edge.stp
> 
> Could you have a look?

I think this should be fixed by this patch:

http://sourceware.org/ml/systemtap/2009-q4/msg00800.html

Can you try it? With this patch I see no new regressions on x86_64.

Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/8] Use proper types for do_div
  2009-12-09 16:09     ` Anton Vorontsov
@ 2009-12-09 22:48       ` Mark Wielaard
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Wielaard @ 2009-12-09 22:48 UTC (permalink / raw)
  To: avorontsov; +Cc: systemtap, linuxppc-dev

Hi Anton,

On Wed, 2009-12-09 at 19:09 +0300, Anton Vorontsov wrote:
> I think this should be fixed by this patch:
> 
> http://sourceware.org/ml/systemtap/2009-q4/msg00800.html
> 
> Can you try it? With this patch I see no new regressions on x86_64.

Yes, that fixes everything. Sorry I didn't see that patch earlier. I see
Wenji also tested it already. I have pushed it for you.

Thanks,

Mark


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-12-09 22:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-27 22:32 [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Anton Vorontsov
2009-11-27 22:33 ` [PATCH 4/8] Implement ppc32 variant of __is_user_regs Anton Vorontsov
2009-11-27 22:33 ` [PATCH 3/8] stack-ppc: Adjust for ppc32 Anton Vorontsov
2009-11-27 22:33 ` [PATCH 1/8] Rename uprobes_ppc64.c to uprobes_ppc.c, use it " Anton Vorontsov
2009-11-27 22:33 ` [PATCH 7/8] Implement _div64 and _mod64 " Anton Vorontsov
2009-11-27 22:33 ` [PATCH 8/8] Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32 Anton Vorontsov
2009-11-27 22:33 ` [PATCH 2/8] Rename stack-ppc64.c to stack-ppc.c Anton Vorontsov
2009-11-27 22:33 ` [PATCH 5/8] Share ppc64 and ppc32 code where possible Anton Vorontsov
2009-11-27 22:57 ` [PATCH 6/8] Use proper types for do_div Anton Vorontsov
2009-12-09 15:56   ` Mark Wielaard
2009-12-09 16:09     ` Anton Vorontsov
2009-12-09 22:48       ` Mark Wielaard
2009-12-01 17:55 ` [PATCH 0/8 userland!] systemtap: Add initial support for ppc32 Frank Ch. Eigler
2009-12-01 19:14 ` Jim Keniston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).