From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [rfc] linux-nat: Never PTRACE_CONT a stepping thread
Date: Wed, 22 Sep 2010 09:43:00 -0000 [thread overview]
Message-ID: <20100921234325.GA31267@host1.dyn.jankratochvil.net> (raw)
Hi,
as referenced in:
[patch 3/4]#3 linux-nat: Do not respawn signals
http://sourceware.org/ml/gdb-patches/2010-09/msg00360.html
If multiple signals happen besides SIGTRAP GDB still may switch from thread A
away (as not considering it stepping) to thread B for SIGUSR1 and accidentally
PTRACE_CONT thread A while resignalling SIGUSR1.
It probably could have its own testcase.
I will code one depending on the resolution of the #3 series above.
No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
Thanks,
Jan
gdb/
2010-09-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbthread.h (currently_stepping): New declaration.
* infrun.c (currently_stepping): Remove the forward declaration.
(currently_stepping): Make it global.
* linux-nat.c (resume_callback) <lp->stopped && lp->status == 0>: New
variables tp and step, initialized them. Pass STEP to to_resume.
Print also possibly "PTRACE_SINGLESTEP" if STEP. Initialize LP->STEP.
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index cd24eaf..e89e88d 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -352,4 +352,6 @@ extern struct thread_info* inferior_thread (void);
extern void update_thread_list (void);
+extern int currently_stepping (struct thread_info *tp);
+
#endif /* GDBTHREAD_H */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 0720b31..8afdd77 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -74,8 +74,6 @@ static int follow_fork (void);
static void set_schedlock_func (char *args, int from_tty,
struct cmd_list_element *c);
-static int currently_stepping (struct thread_info *tp);
-
static int currently_stepping_or_nexting_callback (struct thread_info *tp,
void *data);
@@ -4842,7 +4840,7 @@ infrun: not switching back to stepped thread, it has vanished\n");
/* Is thread TP in the middle of single-stepping? */
-static int
+int
currently_stepping (struct thread_info *tp)
{
return ((tp->step_range_end && tp->step_resume_breakpoint == NULL)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index a0eca0e..69b9a5f 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1820,20 +1820,26 @@ resume_callback (struct lwp_info *lp, void *data)
}
else if (lp->stopped && lp->status == 0)
{
+ struct thread_info *tp = find_thread_ptid (lp->ptid);
+ /* lp->step may already contain a stale value. */
+ int step = tp ? currently_stepping (tp) : 0;
+
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
- "RC: PTRACE_CONT %s, 0, 0 (resuming sibling)\n",
+ "RC: %s %s, 0, 0 (resuming sibling)\n",
+ step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
target_pid_to_str (lp->ptid));
linux_ops->to_resume (linux_ops,
pid_to_ptid (GET_LWP (lp->ptid)),
- 0, TARGET_SIGNAL_0);
+ step, TARGET_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
- "RC: PTRACE_CONT %s, 0, 0 (resume sibling)\n",
+ "RC: %s %s, 0, 0 (resume sibling)\n",
+ step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
target_pid_to_str (lp->ptid));
lp->stopped = 0;
- lp->step = 0;
+ lp->step = step;
memset (&lp->siginfo, 0, sizeof (lp->siginfo));
lp->stopped_by_watchpoint = 0;
}
next reply other threads:[~2010-09-21 23:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-22 9:43 Jan Kratochvil [this message]
2010-10-16 17:10 ` Pedro Alves
2010-10-17 18:28 ` Jan Kratochvil
2010-10-17 19:04 ` Pedro Alves
2010-10-18 8:51 ` Jan Kratochvil
2010-10-19 19:24 ` Pedro Alves
2010-11-02 1:56 ` Jan Kratochvil
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=20100921234325.GA31267@host1.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.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