Subject: strace on Linux/MIPS?

From: Jun Sun <[email-masked]>
Date: Thu, 27 Jul 2000 16:05:08 -0700

Has anybody been successful in trying to get strace running on
Linux/MIPS?  I managed to get 4.2, with a little from CVS tree, compiled
and run.  However, it does not quite right.  It only prints the first
system. See below.  Verified that this is the same behavior on both
2.3.99-pre3 and 2.4.0-test2.

sh-2.03# strace ls
execve("/bin/ls", ["ls"], [/* 14 vars */]) = 0
bin  boot  dev  etc  lib  mnt  opt  proc  sbin  share  tmp  var

Any idea?

Jun

---

From: Keith M Wesolowski <[email-masked]>
Date: Thu, 27 Jul 2000 16:12:17 -0700

> 2.3.99-pre3 and 2.4.0-test2.

Your kernel is too old. Ralf fixed some things in ptrace a few days
ago. Also, I would be interested in hearing if you can get 4.2 to
work. I found that, even after adjusting several places for
__NR_Linux, it segfaulted. I do have 3.1 from oss.sgi.com CVS (with a
couple minor glibc 2.2 patches) working properly with a current
kernel.

-- 
Keith M Wesolowski			[email-masked]
University of Nevada			http://www.chem.unr.edu
Chemistry Department Systems and Network Administrator

---

From: Jun Sun <[email-masked]>
Date: Thu, 27 Jul 2000 16:46:56 -0700

Keith M Wesolowski wrote:
> Your kernel is too old.

Wow, a couple days is "too old".  I guest that is Linux speed.

> Ralf fixed some things in ptrace a few days
> ago. 

Great!  Can you pinpoint the related files?  I took a snapshot of CVS on
6/27 and hacked heavily to get it work on my NEC board.  It would be
very difficult for me to move to the new kernel.  It would be better if
I can just reverse-merge with the related changes.

Jun

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 28 Jul 2000 02:11:37 +0200

> Wow, a couple days is "too old".  I guest that is Linux speed.

Software is like fish, it starts to smell soon :-)

> I can just reverse-merge with the related changes.

arch/mips/kernel/scall_o32.S
arch/mips/tools/offset.c
arch/mips64/kernel/scall_64.S
arch/mips64/kernel/scall_o32.S
arch/mips64/tools/offset.c

  Ralf

---

From: Jun Sun <[email-masked]>
Date: Thu, 27 Jul 2000 19:12:44 -0700

> arch/mips64/tools/offset.c

I just updated offset.c and scall_o32.S.  After a trial change ("nice"
-> "priority") in offset.c, strace seems to work fine now.

However, I did notice an error message for mmap(...).

mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
)                                  = 717291520

Keith, if you want the patch for strace 4.2, I can send it to you.  

Jun

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 28 Jul 2000 04:21:09 +0200

> ptrace: umoven: Input/output error

Looks like strace is still tryping to copy mmap_arg_struct like on Intel
but on MIPS we don't use that?

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Fri, 28 Jul 2000 12:22:19 +0200 (MET DST)

> I can just reverse-merge with the related changes.

 Well, you can always take a unified diff of your own changes and try to
apply it to a new snapshot.  Depending on the amount of changes you might
need to apply certain hunks manually but the overall process is usually
quite easy. 

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

---

From: Wichert Akkerman <[email-masked]>
Date: Fri, 28 Jul 2000 13:51:39 +0200

> but on MIPS we don't use that?

Could be, I think MIPS and i386 use the same codepath there. Patches
are appreciated so I can include them in strace 4.3 (eta 3 weeks from
now)

Wichert.

-- 
  _________________________________________________________________
 / Generally uninteresting signature - ignore at your convenience  \
| [email-masked]                   http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 28 Jul 2000 19:52:07 +0200

> are appreciated so I can include them in strace 4.3 (eta 3 weeks from

Well, they shouldn't use the same code ...

Bananaware patch below.

  Ralf

--- strace/linux/mips/syscallent.orig	Mon May  1 03:09:31 2000
+++ strace/linux/mips/syscallent.h	Fri Jul 28 19:50:13 2000
@@ -4088,7 +4088,7 @@
 	{ 1,	TF,	sys_swapon,		"swapon"	}, /* 4087 */
 	{ 3,	0,	sys_reboot,		"reboot"	}, /* 4088 */
 	{ 3,	0,	sys_readdir,		"readdir"	}, /* 4089 */
-	{ 6,	0,	sys_old_mmap,		"mmap"		}, /* 4090 */
+	{ 6,	0,	sys_mmap,		"mmap"		}, /* 4090 */
 	{ 2,	0,	sys_munmap,		"munmap"	}, /* 4091 */
 	{ 2,	TF,	sys_truncate,		"truncate"	}, /* 4092 */
 	{ 2,	0,	sys_ftruncate,		"ftruncate"	}, /* 4093 */

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 28 Jul 2000 23:46:04 +0200

> are appreciated so I can include them in strace 4.3 (eta 3 weeks from

Here's the second strace patch, please apply.

I noticed that process.c:change_syscall() can't work as is - the all kernels
would change the v0 register - and happily use the old value that is take
the wrong syscall.  A kernel buglet which also hits the usermode kernel
and which I'll fix asap.

  Ralf

--- strace/process.c.orig	Fri Jul 28 23:37:14 2000
+++ strace/process.c	Fri Jul 28 23:33:43 2000
@@ -502,6 +502,24 @@
 		if (errno)
 			return -1;
 	}
+#elif defined(MIPS)
+	{
+		errno = 0;
+		if (argnum < 4)
+			ptrace(PTRACE_POKEUSER, tcp->pid,
+			       (char*)(REG_A0 + argnum), tcp->u_arg[argnum]);
+		else {
+			unsigned long *sp;
+
+			if (upeek(tcp->pid, REG_SP, (long *) &sp) , 0)
+				return -1;
+
+			ptrace(PTRACE_POKEDATA, tcp->pid,
+			       (char*)(sp + argnum - 4), tcp->u_arg[argnum]);
+		}
+		if (errno)
+			return -1;
+	}
 #else
 # warning Sorry, setargs not implemented for this architecture.
 #endif