gdb/gdb-6.6-scheduler_locking-s...

218 lines
8.9 KiB
Diff

2007-06-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* inferior.h (enum resume_step): New definition.
(resume): Change STEP parameter type to ENUM RESUME_STEP.
* infrun.c (resume): Likewise. Extend debug printing of the STEP
parameter. Lock the scheduler only for intentional stepping.
(proceed): Replace the variable ONESTEP with tristate RESUME_STEP.
Set the third RESUME_STEP state according to BPSTAT_SHOULD_STEP.
(currently_stepping): Change the return type to ENUM RESUME_STEP.
Return RESUME_STEP_NEEDED if it is just due to BPSTAT_SHOULD_STEP.
* linux-nat.c (select_singlestep_lwp_callback): Do not focus on
the software watchpoint events.
* linux-nat.h (struct lwp_info): Redeclare STEP as ENUM RESUME_STEP.
2007-10-19 Jan Kratochvil <jan.kratochvil@redhat.com>
* infrun.c (proceed): RESUME_STEP initialized for non-stepping.
RESUME_STEP set according to STEP only at the end of the function.
2008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Port to GDB-6.8pre.
Index: gdb-7.8.90.20150125/gdb/infrun.c
===================================================================
--- gdb-7.8.90.20150125.orig/gdb/infrun.c 2015-01-25 08:36:16.651716159 +0100
+++ gdb-7.8.90.20150125/gdb/infrun.c 2015-01-25 08:36:26.491758571 +0100
@@ -86,7 +86,7 @@ static void follow_inferior_reset_breakp
static void set_schedlock_func (char *args, int from_tty,
struct cmd_list_element *c);
-static int currently_stepping (struct thread_info *tp);
+static enum resume_step currently_stepping (struct thread_info *tp);
static void xdb_handle_command (char *args, int from_tty);
@@ -1998,7 +1998,7 @@ user_visible_resume_ptid (int step)
resume_ptid = inferior_ptid;
}
else if ((scheduler_mode == schedlock_on)
- || (scheduler_mode == schedlock_step && step))
+ || (scheduler_mode == schedlock_step && step == RESUME_STEP_USER))
{
/* User-settable 'scheduler' mode requires solo thread resume. */
resume_ptid = inferior_ptid;
@@ -2022,7 +2022,7 @@ user_visible_resume_ptid (int step)
STEP nonzero if we should step (zero to continue instead).
SIG is the signal to give the inferior (zero for none). */
void
-resume (int step, enum gdb_signal sig)
+resume (enum resume_step step, enum gdb_signal sig)
{
struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
struct regcache *regcache = get_current_regcache ();
@@ -2064,9 +2064,13 @@ resume (int step, enum gdb_signal sig)
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
- "infrun: resume (step=%d, signal=%s), "
+ "infrun: resume (step=%s, signal=%s), "
"trap_expected=%d, current thread [%s] at %s\n",
- step, gdb_signal_to_symbol_string (sig),
+ (step == RESUME_STEP_CONTINUE
+ ? "RESUME_STEP_CONTINUE"
+ : (step == RESUME_STEP_USER ? "RESUME_STEP_USER"
+ : "RESUME_STEP_NEEDED")),
+ gdb_signal_to_symbol_string (sig),
tp->control.trap_expected,
target_pid_to_str (inferior_ptid),
paddress (gdbarch, pc));
@@ -2543,6 +2547,7 @@ proceed (CORE_ADDR addr, enum gdb_signal
struct thread_info *tp;
CORE_ADDR pc;
struct address_space *aspace;
+ enum resume_step resume_step = RESUME_STEP_CONTINUE;
/* If we're stopped at a fork/vfork, follow the branch set by the
"set follow-fork-mode" command; otherwise, we'll just proceed
@@ -2586,13 +2591,19 @@ proceed (CORE_ADDR addr, enum gdb_signal
Note, we don't do this in reverse, because we won't
actually be executing the breakpoint insn anyway.
We'll be (un-)executing the previous instruction. */
+ {
tp->stepping_over_breakpoint = 1;
+ resume_step = RESUME_STEP_USER;
+ }
else if (gdbarch_single_step_through_delay_p (gdbarch)
&& gdbarch_single_step_through_delay (gdbarch,
get_current_frame ()))
/* We stepped onto an instruction that needs to be stepped
again before re-inserting the breakpoint, do so. */
+ {
tp->stepping_over_breakpoint = 1;
+ resume_step = RESUME_STEP_USER;
+ }
}
else
{
@@ -2647,6 +2658,7 @@ proceed (CORE_ADDR addr, enum gdb_signal
tp->prev_pc = regcache_read_pc (get_current_regcache ());
switch_to_thread (step_over->ptid);
tp = step_over;
+ resume_step = RESUME_STEP_USER;
}
}
@@ -2699,9 +2711,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
correctly when the inferior is stopped. */
tp->prev_pc = regcache_read_pc (get_current_regcache ());
+ if (tp->control.trap_expected || step)
+ resume_step = RESUME_STEP_USER;
+ if (resume_step == RESUME_STEP_CONTINUE && bpstat_should_step ())
+ resume_step = RESUME_STEP_NEEDED;
+
/* Resume inferior. */
- resume (tp->control.trap_expected || step || bpstat_should_step (),
- tp->suspend.stop_signal);
+ resume (resume_step, tp->suspend.stop_signal);
/* Wait for it to stop (if not standalone)
and in any case decode why it stopped, and act accordingly. */
@@ -5684,14 +5700,16 @@ switch_back_to_stepped_thread (struct ex
/* Is thread TP in the middle of single-stepping? */
-static int
+static enum resume_step
currently_stepping (struct thread_info *tp)
{
- return ((tp->control.step_range_end
+ if ((tp->control.step_range_end
&& tp->control.step_resume_breakpoint == NULL)
- || tp->control.trap_expected
- || tp->stepped_breakpoint
- || bpstat_should_step ());
+ || tp->control.trap_expected)
+ return RESUME_STEP_USER;
+ if (bpstat_should_step ())
+ return RESUME_STEP_NEEDED;
+ return RESUME_STEP_CONTINUE;
}
/* Inferior has stepped into a subroutine call with source code that
Index: gdb-7.8.90.20150125/gdb/linux-nat.c
===================================================================
--- gdb-7.8.90.20150125.orig/gdb/linux-nat.c 2015-01-25 08:36:16.653716168 +0100
+++ gdb-7.8.90.20150125/gdb/linux-nat.c 2015-01-25 08:36:26.492758576 +0100
@@ -2648,7 +2648,11 @@ static int
select_singlestep_lwp_callback (struct lwp_info *lp, void *data)
{
if (lp->last_resume_kind == resume_step
- && lp->status != 0)
+ && lp->status != 0
+ /* We do not focus on software watchpoints as we would not catch
+ STEPPING_PAST_SINGLESTEP_BREAKPOINT breakpoints in some other thread
+ as they would remain pending due to `Push back breakpoint for %s'. */
+ && lp->step == RESUME_STEP_USER)
return 1;
else
return 0;
Index: gdb-7.8.90.20150125/gdb/linux-nat.h
===================================================================
--- gdb-7.8.90.20150125.orig/gdb/linux-nat.h 2015-01-25 08:36:16.653716168 +0100
+++ gdb-7.8.90.20150125/gdb/linux-nat.h 2015-01-25 08:36:44.948838126 +0100
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "target.h"
+#include "infrun.h"
#include <signal.h>
@@ -88,8 +89,8 @@ struct lwp_info
running and not stepping, this is 0. */
CORE_ADDR stop_pc;
- /* Non-zero if we were stepping this LWP. */
- int step;
+ /* The kind of stepping of this LWP. */
+ enum resume_step step;
/* The reason the LWP last stopped, if we need to track it
(breakpoint, watchpoint, etc.) */
Index: gdb-7.8.90.20150125/gdb/infrun.h
===================================================================
--- gdb-7.8.90.20150125.orig/gdb/infrun.h 2015-01-25 08:36:16.654716172 +0100
+++ gdb-7.8.90.20150125/gdb/infrun.h 2015-01-25 08:36:26.493758580 +0100
@@ -92,7 +92,14 @@ extern void proceed (CORE_ADDR, enum gdb
/* The `resume' routine should only be called in special circumstances.
Normally, use `proceed', which handles a lot of bookkeeping. */
-extern void resume (int, enum gdb_signal);
+enum resume_step
+ {
+ /* currently_stepping () should return non-zero for non-continue. */
+ RESUME_STEP_CONTINUE = 0,
+ RESUME_STEP_USER, /* Stepping is intentional by the user. */
+ RESUME_STEP_NEEDED /* Stepping only for software watchpoints. */
+ };
+extern void resume (enum resume_step, enum gdb_signal);
/* Return a ptid representing the set of threads that we will proceed,
in the perspective of the user/frontend. */
Index: gdb-7.8.90.20150125/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
===================================================================
--- gdb-7.8.90.20150125.orig/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp 2015-01-25 08:36:16.654716172 +0100
+++ gdb-7.8.90.20150125/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp 2015-01-25 08:36:26.493758580 +0100
@@ -97,7 +97,7 @@ gdb_test "set debug infrun 1"
gdb_test \
"step" \
- ".*need to step-over.*resume \\(step=1.*signal arrived while stepping over breakpoint.*switching back to stepped thread.*stepped to a different line.*callme.*" \
+ ".*need to step-over.*resume \\(step=RESUME_STEP_USER.*signal arrived while stepping over breakpoint.*switching back to stepped thread.*stepped to a different line.*callme.*" \
"step"
set cnt_after [get_value "args\[$my_number\]" "get count after step"]