OSDN Git Service

Darwin/detach: Do not resume inferior after ptrace detach
authorbrobecke <brobecke>
Fri, 1 Jul 2011 18:36:11 +0000 (18:36 +0000)
committerbrobecke <brobecke>
Fri, 1 Jul 2011 18:36:11 +0000 (18:36 +0000)
commitebc2e636a319d05496abe58fbda7ad8f9c07c8f2
tree2c91b3c6370c967bb253ef7ebeecb39fd7e980fa
parentaad229452b2f5729449fddeba9fdcd1e3cb78438
Darwin/detach: Do not resume inferior after ptrace detach

When trying to detach from an inferior that we start from the debugger,
GDB prints the following warning:

    (gdb) detach
    Detaching from program: /[...]/foo, process 74593
    warning: Mach error at "/[...]/darwin-nat.c:445" in function "darwin_resume_inferior": (os/kern) failure (0x5)

The warning comes from the following code in darwin_detach:

     darwin_resume_inferior (inf);

This is because the process has already been resumed by the
PT_DETACH ptrace operation that has just been performed.

On the other hand, when trying to detach from an inferior that
was started outside of debugger control (thus after having attached
the debugger to that inferior), things go smoothly.  That's because
we don't use ptrace to control the process in that case, and so
the resume is perfectly justified.

This patch makes sure that we resume the inferior during the detach
only when we're NOT using ptrace.

gdb/ChangeLog:

        * darwin-nat.c (darwin_detach): Call darwin_resume_inferior
        only when inf->private->no_ptrace.
gdb/ChangeLog
gdb/darwin-nat.c