From: Blaisorblade <bla...@ya...> - 2006-04-27 12:30:38
|
On Wednesday 26 April 2006 20:21, Abhay Raghu wrote: > Hello > > I have been able to debug uml by directly launching it and debugging it > with gdb. Could you explain how this works since both uml and gdb use > ptrace? In SKAS mode, UML "kernel" thread ptraces via PTRACE_SYSCALL (or the special PTRACE_SYSEMU, ask for the difference if interested) one "userspace" thread, where all application code is executed - the userspace thread runs normally until a syscall is executed - that syscall is intercepted and executed by UML. You see the "userspace" thread with status "T" in the "ps auxw" output. In this picture, gdb ptraces the "kernel" thread - so it can possibly step over a ptrace call done on the other thread, but that is not a problem. All the kernel code is in the "kernel" thread so gdb'ing it simply works. In TT mode (which however is currently becoming obsolete), instead, the picture is more complicate. There one thread, the tracing thread, ptraces various thread (one per guest process) which execute either the application code or the kernel code; when a syscall is done by a guest process, the tracing thread modifies the registers for the host thread representing that process so that it resumes executing UML code. So, you could ptrace the tracing thread, but that's of little interest normally since it doesn't execute any kernel code. A special mechanism is needed, i.e. the ptrace proxy (which seems to be born for use outside UML and then incorporated): I don't know well the detail but IIRC gdb is ptraced and the results of his ptrace syscalls are modified, so that it sees what is happening in threads other than the tracing one. -- Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com |