From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [Darwin 1/4] detach: Do not resume inferior after ptrace detach
Date: Fri, 01 Jul 2011 19:03:00 -0000 [thread overview]
Message-ID: <1309547006-21412-2-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1309547006-21412-1-git-send-email-brobecker@adacore.com>
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, as
documented by the ptrace(2) man page.
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.
Tested on x86_64-darwin. Checked in.
---
gdb/ChangeLog | 5 +++++
gdb/darwin-nat.c | 6 +++++-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c37c9a9..5be8066 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2011-07-01 Joel Brobecker <brobecker@adacore.com>
+ * darwin-nat.c (darwin_detach): Call darwin_resume_inferior
+ only when inf->private->no_ptrace.
+
+2011-07-01 Joel Brobecker <brobecker@adacore.com>
+
* ada-lang.c (print_it_exception): Print temporary catchpoints
as "Temporary catchpoint".
(print_mention_exception): Likewise.
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 7be85d5..fc5263a 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1601,7 +1601,11 @@ darwin_detach (struct target_ops *ops, char *args, int from_tty)
darwin_reply_to_all_pending_messages (inf);
- darwin_resume_inferior (inf);
+ /* When using ptrace, we have just performed a PT_DETACH, which
+ resumes the inferior. On the other hand, when we are not using
+ ptrace, we need to resume its execution ourselves. */
+ if (inf->private->no_ptrace)
+ darwin_resume_inferior (inf);
darwin_mourn_inferior (ops);
}
--
1.7.1
next prev parent reply other threads:[~2011-07-01 19:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-01 19:03 Various fixes to the Darwin port Joel Brobecker
2011-07-01 19:03 ` Joel Brobecker [this message]
2011-07-01 19:03 ` [Darwin 2/4] Do not crash (failed assertion) after PT_KILL ptrace error Joel Brobecker
2011-07-02 16:59 ` Mark Kettenis
2011-07-03 16:18 ` Joel Brobecker
2011-07-03 7:30 ` Joel Brobecker
2011-07-01 19:03 ` [Darwin 3/4] [mach-o] get rid of current_oso global Joel Brobecker
2011-07-01 19:11 ` [Darwin 4/4] remove comment in machoread.c (macho_symfile_read) Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309547006-21412-2-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox