tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

RE: Debugging threaded processes



> With some help from David Holland, I have a tentative fix.  Tentative,
> because the program is segfaulting at some point; I don't know yet
why,
> or whether to blame that on the program, on GDB, or on NetBSD.

I have the answer to that, it points to a missing feature in ptrace.

GDB needs to be able to step or resume a specific LWP.  Step, to get
past the breakpoint; resume, because some architectures don't do step so
GDB has to simulate it.

The problem is that ptrace currently always acts on the first live lwp
in the list for the process.  The result is that gdb may see a
breakpoint and try to step that LWP, but instead some other LWP steps
and I see a trap at some weird address.  This also accounts for the
segfault, a bit more indirectly.

So... I looked in sys_lwp to see if I can control individual LWPs.
Answer: no, not for another process.  So it looks like ptrace needs to
be extended to do this.  Not all ptrace calls have an obvious place for
an lwpid_t argument, though (P_CONT doesn't, for example).

Any ideas?

        paul


Home | Main Index | Thread Index | Old Index