Skip to contentSkip to conversation

strace on Linux/MIPS?

DISCUSSION Jun Sun 5 participants 10 messages Jul 27, 2000 – Jul 31, 2000 MIPS

lore
Share & tools
lore

Jun Sun

author
#0 lore raw

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

#1 lore raw
Quoted 5 lines · Jun Sun

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.

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.

Signature · 3 lines
Keith M Wesolowski			[email protected]
University of Nevada			http://www.chem.unr.edu
Chemistry Department Systems and Network Administrator
author
#2 lore raw
Quoted 10 lines · Keith M Wesolowski
Quoted 5 lines · Jun Sun

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.

Your kernel is too old.

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

Quoted 2 lines

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

#3 lore raw
Quoted 9 lines · Jun Sun
Quoted 7 lines
Quoted 5 lines

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.

Your kernel is too old.

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

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

Quoted 7 lines
Quoted 2 lines

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.

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

author
#4 lore raw
Quoted 9 lines · Ralf Baechle
Quoted 8 lines
Quoted 3 lines

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.

Quoted 7 lines

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

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

#5 lore raw
Quoted 8 lines · Jun Sun

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

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

Quoted 1 line

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

Ralf

#9 lore raw
In reply to Jun Sun
Quoted 4 lines · Jun Sun

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.

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.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#6 lore raw
In reply to Ralf Baechle
Quoted 2 lines · Previously Ralf Baechle

Looks like strace is still tryping to copy mmap_arg_struct like on Intel 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.

Signature · 4 lines
  _________________________________________________________________
 / Generally uninteresting signature - ignore at your convenience  \
| [email protected]                   http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |
#7 lore raw
Quoted 7 lines · Wichert Akkerman
Quoted 2 lines · Previously Ralf Baechle

Looks like strace is still tryping to copy mmap_arg_struct like on Intel 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)

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

Bananaware patch below.

Ralf

linux/mips/syscallent.h renamed from linux/mips/syscallent.orig +1 -1
@@ -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 */
#8 lore raw
In reply to Wichert Akkerman
Quoted 7 lines · Wichert Akkerman
Quoted 2 lines · Previously Ralf Baechle

Looks like strace is still tryping to copy mmap_arg_struct like on Intel 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)

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

process.c renamed from process.c.orig +18 -0
@@ -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