This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] linux-nat: Never PTRACE_CONT a stepping thread
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 22 Sep 2010 01:43:25 +0200
- Subject: [rfc] linux-nat: Never PTRACE_CONT a stepping thread
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;
}