I'm writing a debugger that uses the Linux ptrace API for process control
and I think I've found a bug in ptrace in MIPS Linux. The specific
situation that breaks horribly with my debugger is quite complex, so I
wrote a little testbed to show the problem. The code and a sample Makefile
are attached. You can build the example for x86 or MIPS. I have some
things in there for PPC but I haven't ported it fully yet. Basically the
problem seems to be that writing a breakpoint (instruction 0xd), running
to the breakpoint, replacing the breakpoint with the original instruction
and then resuming sometimes results in the process halting on the same
address, even though there isn't a breakpoint there anymore. If you resume
again, or wait for a "while" after removing the breakpoint everything
works fine. I believe the problem is probably linked to some sort of
problem with the kernel not flushing the instruction cache, but that's
just a guess.
I've encountered problems in ptrace like this with other architectures
before. If anyone wants to take my ptrace test code and make it part of
some kernel validation system please do. The code was whipped up fairly
quickly so you might want to clean it up. I've verified that when it is
run slowly enough it works fine.
I'd guess that this problem has been fixed in later versions of the
kernel. If anyone can point me to a 2.4 release with this fixed I'd like
to know about it. I tried building the cvs checkout but the build failed.
It looks like I'll need a newer toolchain than the one I got from
I'm using a stock MontaVista distribution for the MIPS Malta 4Kc in big
endian mode, downloaded from their site a couple of days ago. I recompiled
the kernel with the arch/mips/configs/defconfig-malta, but haven't changed
any options yet. Since that could be hard to classify here are some
details about my system:
$ uname -a
Linux 126.96.36.199 2.4.17_mvl21 #8 Wed Jan 7 18:19:32 PST 2004 mips unknown
19) ./mips_fp_be-gcc -v
./mips_fp_be-gcc: Actual path =
'/space1/opt/hardhat/previewkit/mips/fp_be/bin/' Actual name =
Reading specs from
gcc version 2.95.3 20010315 (release/MontaVista)
$ cat /proc/cpuinfo
processor : 0
cpu model : MIPS 4Kc V0.5
BogoMIPS : 124.51
wait instruction : no
microsecond timers : yes
extra interrupt vector : yes
hardware watchpoint : yes
VCED exceptions : not available
VCEI exceptions : not available
Any help would be greatly appreciated,
 Here's the error I get building the linux-mips.org cvs kernel. I don't
know why it's trying to build a ramfs component, I only have ext2, /proc,
/dev/pts, NFS, and NFS as root enabled. I've also diabled ramdisk support
make: `arch/mips/kernel/offset.s' is up to date.
make: `arch/mips/kernel/reg.s' is up to date.
usr/initramfs_data.S: Assembler messages:
usr/initramfs_data.S:29: Error: Unknown pseudo-op: `.incbin'
make: *** [usr/initramfs_data.o] Error 1
make: *** [usr] Error 2
Nathan Field (email@example.com) All gone.
But the trouble with analogies is that analogies are like goldfish:
sometimes they have nothing to do with the topic at hand.
-- Crispin (from a posting to the Bugtraq mailing list)
Description: Text document
Description: Text document