old-cross-binutils/gdb/testsuite/gdb.threads
Pedro Alves 776f04fafe [gdb/16062] stepi sometimes doesn't make progress
I noticed something odd while doing "stepi" over a fork syscall:

 ...
 (gdb) set disassemble-next-line on
 ...
 (gdb) si
 0x000000323d4ba7c2      131       pid = ARCH_FORK ();
    0x000000323d4ba7a4 <__libc_fork+132>:        64 4c 8b 04 25 10 00 00 00      mov    %fs:0x10,%r8
    0x000000323d4ba7ad <__libc_fork+141>:        31 d2   xor    %edx,%edx
    0x000000323d4ba7af <__libc_fork+143>:        4d 8d 90 d0 02 00 00    lea    0x2d0(%r8),%r10
    0x000000323d4ba7b6 <__libc_fork+150>:        31 f6   xor    %esi,%esi
    0x000000323d4ba7b8 <__libc_fork+152>:        bf 11 00 20 01  mov    $0x1200011,%edi
    0x000000323d4ba7bd <__libc_fork+157>:        b8 38 00 00 00  mov    $0x38,%eax
 => 0x000000323d4ba7c2 <__libc_fork+162>:        0f 05   syscall
    0x000000323d4ba7c4 <__libc_fork+164>:        48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
    0x000000323d4ba7ca <__libc_fork+170>:        0f 87 2b 01 00 00       ja     0x323d4ba8fb <__libc_fork+475>
 (gdb) si
 0x000000323d4ba7c4      131       pid = ARCH_FORK ();
    0x000000323d4ba7a4 <__libc_fork+132>:        64 4c 8b 04 25 10 00 00 00      mov    %fs:0x10,%r8
    0x000000323d4ba7ad <__libc_fork+141>:        31 d2   xor    %edx,%edx
    0x000000323d4ba7af <__libc_fork+143>:        4d 8d 90 d0 02 00 00    lea    0x2d0(%r8),%r10
    0x000000323d4ba7b6 <__libc_fork+150>:        31 f6   xor    %esi,%esi
    0x000000323d4ba7b8 <__libc_fork+152>:        bf 11 00 20 01  mov    $0x1200011,%edi
    0x000000323d4ba7bd <__libc_fork+157>:        b8 38 00 00 00  mov    $0x38,%eax
    0x000000323d4ba7c2 <__libc_fork+162>:        0f 05   syscall
 => 0x000000323d4ba7c4 <__libc_fork+164>:        48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
    0x000000323d4ba7ca <__libc_fork+170>:        0f 87 2b 01 00 00       ja     0x323d4ba8fb <__libc_fork+475>
 (gdb) si
 0x000000323d4ba7c4      131       pid = ARCH_FORK ();
    0x000000323d4ba7a4 <__libc_fork+132>:        64 4c 8b 04 25 10 00 00 00      mov    %fs:0x10,%r8
    0x000000323d4ba7ad <__libc_fork+141>:        31 d2   xor    %edx,%edx
    0x000000323d4ba7af <__libc_fork+143>:        4d 8d 90 d0 02 00 00    lea    0x2d0(%r8),%r10
    0x000000323d4ba7b6 <__libc_fork+150>:        31 f6   xor    %esi,%esi
    0x000000323d4ba7b8 <__libc_fork+152>:        bf 11 00 20 01  mov    $0x1200011,%edi
    0x000000323d4ba7bd <__libc_fork+157>:        b8 38 00 00 00  mov    $0x38,%eax
    0x000000323d4ba7c2 <__libc_fork+162>:        0f 05   syscall
 => 0x000000323d4ba7c4 <__libc_fork+164>:        48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
    0x000000323d4ba7ca <__libc_fork+170>:        0f 87 2b 01 00 00       ja     0x323d4ba8fb <__libc_fork+475>
 (gdb) si
 0x000000323d4ba7ca      131       pid = ARCH_FORK ();
    0x000000323d4ba7a4 <__libc_fork+132>:        64 4c 8b 04 25 10 00 00 00      mov    %fs:0x10,%r8
    0x000000323d4ba7ad <__libc_fork+141>:        31 d2   xor    %edx,%edx
    0x000000323d4ba7af <__libc_fork+143>:        4d 8d 90 d0 02 00 00    lea    0x2d0(%r8),%r10
    0x000000323d4ba7b6 <__libc_fork+150>:        31 f6   xor    %esi,%esi
    0x000000323d4ba7b8 <__libc_fork+152>:        bf 11 00 20 01  mov    $0x1200011,%edi
    0x000000323d4ba7bd <__libc_fork+157>:        b8 38 00 00 00  mov    $0x38,%eax
    0x000000323d4ba7c2 <__libc_fork+162>:        0f 05   syscall
    0x000000323d4ba7c4 <__libc_fork+164>:        48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
 => 0x000000323d4ba7ca <__libc_fork+170>:        0f 87 2b 01 00 00       ja     0x323d4ba8fb <__libc_fork+475>

Notice how the third "si" didn't actually make progress.

Turning on infrun and lin-lwp debug, we see:

 (gdb)
 infrun: clear_proceed_status_thread (process 5252)
 infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1)
 infrun: resume (step=1, signal=0), trap_expected=0, current thread [process 5252] at 0x323d4ba7c4
 LLR: Preparing to step process 5252, 0, inferior_ptid process 5252
 RC: Not resuming sibling process 5252 (not stopped)
 LLR: PTRACE_SINGLESTEP process 5252, 0 (resume event thread)
 sigchld
 infrun: wait_for_inferior ()
 linux_nat_wait: [process -1], []
 LLW: enter
 LNW: waitpid(-1, ...) returned 5252, No child processes
 LLW: waitpid 5252 received Child exited (stopped)
 LLW: Candidate event Child exited (stopped) in process 5252.
 SEL: Select single-step process 5252
 LLW: exit
 infrun: target_wait (-1, status) =
 infrun:   5252 [process 5252],
 infrun:   status->kind = stopped, signal = SIGCHLD
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x323d4ba7c4
 infrun: random signal 20
 infrun: stepi/nexti
 infrun: stop_stepping

So the inferior got a SIGCHLD (because the fork child exited while
we're doing 'si'), and since that signal is set to "nostop noprint
pass" (by default), it's considered a random signal, so it should not
cause a stop.  But, it resulted in an immediate a stop_stepping call
anyway.  So the single-step never really finished.

This is a regression caused by:

 [[PATCH] Do not respawn signals, take 2.]
 https://sourceware.org/ml/gdb-patches/2012-06/msg00702.html

Specifically, caused by this change (as mentioned in the "the lost
step issue first" part of that mail):

 diff --git a/gdb/infrun.c b/gdb/infrun.c
 index 53db335..3e8dbc8 100644
 --- a/gdb/infrun.c
 +++ b/gdb/infrun.c
 @@ -4363,10 +4363,8 @@ process_event_stop_test:
  	 (leaving the inferior at the step-resume-breakpoint without
  	 actually executing it).  Either way continue until the
  	 breakpoint is really hit.  */
 -      keep_going (ecs);
 -      return;
      }
 -
 +  else
    /* Handle cases caused by hitting a breakpoint.  */
    {


That made GDB fall through to the

>   /* In all-stop mode, if we're currently stepping but have stopped in
>   some other thread, we need to switch back to the stepped thread.  */
>  if (!non_stop)

part.  However, if we don't have a stepped thread to get back to,
we'll now also fall through to all the "stepping" tests.  For line
stepping, that'll turn out okay, as we'll just end up realizing the
thread is still in the stepping range, and needs to be re-stepped.
However, for stepi/nexti, we'll reach:

  if (ecs->event_thread->control.step_range_end == 1)
    {
      /* It is stepi or nexti.  We always want to stop stepping after
         one instruction.  */
      if (debug_infrun)
	 fprintf_unfiltered (gdb_stdlog, "infrun: stepi/nexti\n");
      ecs->event_thread->control.stop_step = 1;
      print_end_stepping_range_reason ();
      stop_stepping (ecs);
      return;
    }

and stop, even though the thread actually made no progress.  The fix
is to restore the keep_going call, but put it after the "switch back
to the stepped thread" code, and before the stepping tests.

Tested on x86_64 Fedora 17, native and gdbserver.  New test included.

gdb/
2013-10-18  Pedro Alves  <palves@redhat.com>

	PR gdb/16062
	* infrun.c (handle_inferior_event): Keep going if we got a random
	signal we should not stop for, instead of falling through to the
	step tests.

gdb/testsuite/
2013-10-18  Pedro Alves  <palves@redhat.com>

	PR gdb/16062
	* gdb.threads/stepi-random-signal.c: New file.
	* gdb.threads/stepi-random-signal.exp: New file.
2013-10-18 14:28:34 +00:00
..
attach-into-signal.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
attach-into-signal.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
attach-stopped.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
attach-stopped.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
bp_in_thread.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
bp_in_thread.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
clone-new-thread-event.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
clone-new-thread-event.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
corethreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
corethreads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
create-fail.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
create-fail.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
current-lwp-dead.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
current-lwp-dead.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
dlopen-libpthread-lib.c 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
dlopen-libpthread.c 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
dlopen-libpthread.exp 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
execl.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
execl.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
execl1.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
fork-child-threads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
fork-child-threads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
fork-thread-pending.c gdb/testsuite/ 2013-02-27 18:48:23 +00:00
fork-thread-pending.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gcore-thread.exp * lib/gdb.exp (gdb_core_cmd): New function. 2013-05-06 22:11:16 +00:00
hand-call-in-threads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
hand-call-in-threads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
ia64-sigill.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
ia64-sigill.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
info-threads-cur-sal-2.c PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
info-threads-cur-sal.c PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
info-threads-cur-sal.exp PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
interrupted-hand-call.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
interrupted-hand-call.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
killed.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
killed.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
leader-exit.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
leader-exit.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
linux-dp.c
linux-dp.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
local-watch-wrong-thread.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
local-watch-wrong-thread.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
Makefile.in * Makefile.in (clean): Remove Fission .dwo and .dwp files. 2012-05-17 19:03:59 +00:00
manythreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
manythreads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
multi-create.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
multi-create.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
no-unwaited-for-left.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
no-unwaited-for-left.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-ldr-exc-1.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-ldr-exc-1.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
non-ldr-exc-2.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-ldr-exc-2.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
non-ldr-exc-3.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-ldr-exc-3.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
non-ldr-exc-4.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
non-ldr-exc-4.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
pending-step.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pending-step.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
print-threads.c
print-threads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pthread_cond_wait.c gdb/testsuite/ 2013-02-14 15:24:11 +00:00
pthread_cond_wait.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pthreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
pthreads.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
schedlock.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
schedlock.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
siginfo-threads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
siginfo-threads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
sigstep-threads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
sigstep-threads.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
sigthread.c
sigthread.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
staticthreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
staticthreads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
stepi-random-signal.c [gdb/16062] stepi sometimes doesn't make progress 2013-10-18 14:28:34 +00:00
stepi-random-signal.exp [gdb/16062] stepi sometimes doesn't make progress 2013-10-18 14:28:34 +00:00
switch-threads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
switch-threads.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-execl.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-execl.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-find.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-specific-bp.c PR gdb/11568 - delete thread-specific breakpoints on thread exit 2013-09-17 19:32:47 +00:00
thread-specific-bp.exp PR gdb/11568 - delete thread-specific breakpoints on thread exit 2013-09-17 19:32:47 +00:00
thread-specific.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-specific.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread-unwindonsignal.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread_check.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread_check.exp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
thread_events.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
thread_events.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
threadapply.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
threadapply.exp 2013-07-15 Ali Anwar <ali_anwar@codesourcery.com> 2013-07-15 11:14:32 +00:00
threxit-hop-specific.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
threxit-hop-specific.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls-main.c
tls-nodebug.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-nodebug.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls-shared.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-shared.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls-var-main.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-var.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls-var.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls.c
tls.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
tls2.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchpoint-fork-child.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchpoint-fork-mt.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchpoint-fork-parent.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchpoint-fork-st.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchpoint-fork.exp gdb/testsuite/ 2013-03-15 01:41:29 +00:00
watchpoint-fork.h Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchthreads-reorder.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchthreads-reorder.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchthreads.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchthreads.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
watchthreads2.c Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
watchthreads2.exp Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
wp-replication.c * gdb.threads/wp-replication.c (main): Insert some code at the start 2013-05-22 16:30:24 +00:00
wp-replication.exp 2013-07-08 Andreas Arnez <arnez@linux.vnet.ibm.com> 2013-07-08 11:35:49 +00:00