Skip to contentSkip to conversation

Regarding PTRACE implementation in QEMU user mode

Qemu-devel sathish kumar 4 participants 5 messages Sep 23, 2008

lore
Share & tools
lore
#1 lore raw
Quoted 2 lines

Can someone explain why explain why ptrace system call is not implemented in QEMU? if someone is working on it, please share some ideas.

Because it's extremely hard (read: nearly impossible) to implement properly. ptrace allows direct access to the state of a different process. Passing through ptrace would give you the state of qemu itself, not the program you're interested in, so you have to emulate everything via some othe IPC mechanism (which must also be hidden from the emulated application). This includes signals like SIGSTOP which cannot be trapped.

If you're not extremely careful you end up with a monstrosity like Cygwin, and all the problems that implies.

Paul

#2 lore raw
Quoted 5 lines · Paul Brook
Quoted 2 lines

Can someone explain why explain why ptrace system call is not implemented in QEMU? if someone is working on it, please share some ideas.

Because it's extremely hard (read: nearly impossible) to implement properly.

I'll also note that the usual use of ptrace if for gdb/gdbserver. You should use the builtin qemu gdb stub instead.

Paul

#3 lore raw
Quoted 9 lines · Paul Brook
Quoted 5 lines · Paul Brook
Quoted 2 lines

Can someone explain why explain why ptrace system call is not implemented in QEMU? if someone is working on it, please share some ideas.

Because it's extremely hard (read: nearly impossible) to implement properly.

I'll also note that the usual use of ptrace if for gdb/gdbserver. You should use the builtin qemu gdb stub instead.

The other usual use is strace, which seems like it would be useful for user mode emulation.

-- Jamie

#4 lore raw
Quoted 5 lines · Jamie Lokier
Quoted 4 lines · Paul Brook
Quoted 3 lines · Paul Brook
Quoted 2 lines

Can someone explain why explain why ptrace system call is not implemented in QEMU? if someone is working on it, please share some ideas.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Because it's extremely hard (read: nearly impossible) to implement properly.

I'll also note that the usual use of ptrace if for gdb/gdbserver. You should use the builtin qemu gdb stub instead.

The other usual use is strace, which seems like it would be useful for user mode emulation.

Set QEMU_STRACE environment variable.

Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/