Bug 22583 - gdb.base/breakpoint-in-ro-region.exp regressions on software single-step targets
Summary: gdb.base/breakpoint-in-ro-region.exp regressions on software single-step targets
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 8.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-11 11:09 UTC by Pedro Alves
Modified: 2018-03-31 12:43 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2017-12-11 11:09:08 UTC
At <https://sourceware.org/ml/gdb-patches/2017-12/msg00212.html>, Maciej writes:

On 12/09/2017 01:16 AM, Maciej W. Rozycki wrote:

>  This change, i.e.:
> 
> commit d930703d68ae160ddfe8ebe5fdcf416fb6090e1e
> Author: Pedro Alves <palves@redhat.com>
> Date:   Thu Nov 16 18:44:43 2017 +0000
> 
> caused regressions to appear in remote `mips-mti-linux-gnu' target testing 
> (`x86_64-linux-gnu' host), specifically:
> 
> FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
> FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: single-step breakpoint is not left behind
> FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: step in ro region (cannot insert hw break)
> FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: single-step breakpoint is not left behind
> FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: single-step breakpoint is not left behind
> 
> and indeed detailed logs indicate a breakpoint is left lingering, e.g.:
> 
> (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
> maint info breakpoints 0
> Num     Type           Disp Enb Address    What
> 0       sw single-step keep y   0x00400774 in main at [...]/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c:24 inf 1 thread 1
> 	stop only in thread 1
> (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
> 
> vs:
> 
> (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
> maint info breakpoints 0
> No breakpoint or watchpoint matching '0'.
> (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
> 
> as at commit d930703d68ae^.

Filling so we don't forget before 8.1 is out.
Comment 1 Pedro Alves 2017-12-13 19:46:30 UTC
I've managed to rebase my old "software single-step on x86-64" branch on current master:

  https://github.com/palves/gdb/commits/palves/x86_software_single_step

and I can reproduce this locally now.
Comment 2 Sourceware Commits 2018-01-11 17:51:17 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71d378ae60a4f072ce392046878d471255f6c8a1

commit 71d378ae60a4f072ce392046878d471255f6c8a1
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jan 11 17:50:31 2018 +0000

    gdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)
    
    As Maciej reported at
    <https://sourceware.org/ml/gdb-patches/2017-12/msg00212.html>, this
    commit:
    
     commit d930703d68ae160ddfe8ebe5fdcf416fb6090e1e
     Date: Thu Nov 16 18:44:43 2017 +0000
     Subject: Don't ever Quit out of resume
    
    caused regressions on software single-set targets, specifically:
    
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: step in ro region (cannot insert hw break)
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: single-step breakpoint is not left behind
    
    and indeed detailed logs indicate a breakpoint is left lingering, e.g.:
    
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
     maint info breakpoints 0
     Num     Type           Disp Enb Address    What
     0       sw single-step keep y   0x00400774 in main at [...]/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c:24 inf 1 thread 1
    	 stop only in thread 1
     (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
    
    vs:
    
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
     maint info breakpoints 0
     No breakpoint or watchpoint matching '0'.
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
    
    as at commit d930703d68ae^.
    
    Before commit d930703d68ae, we had a cleanup installed in 'resume'
    that would delete single-step breakpoints on error:
    
      /* Resuming.  */
    
      /* Things to clean up if we QUIT out of resume ().  */
      static void
      resume_cleanups (void *ignore)
      {
        if (!ptid_equal (inferior_ptid, null_ptid))
         delete_single_step_breakpoints (inferior_thread ());
    
        normal_stop ();
      }
    
    That whole function was removed by d930703d68ae mainly to eliminate
    the normal_stop call:
    
    ~~~~
        Note that the exception called from within resume ends up calling
        normal_stop via resume_cleanups.  That's very borked though, because
        normal_stop is going to re-handle whatever was the last reported
        event, possibly even re-running a hook stop...
    ~~~~
    
    But as the regression shows, removing resume_cleanups completely went
    a bit too far, as the delete_single_step_breakpoints call is still
    necessary.
    
    So fix the regression by reinstating the
    delete_single_step_breakpoints call on error.  However, since we're
    trying to eliminate cleanups, restore it in a different form (using
    TRY/CATCH).
    
    Tested on x86-64 GNU/Linux both top of master and on top of a series
    that implements software single-step on x86.
    
    gdb/ChangeLog:
    2018-01-11  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22583
    	* infrun.c (resume): Rename to ...
    	(resume_1): ... this.
    	(resume): Reimplement as wrapper around resume_1.
Comment 3 Sourceware Commits 2018-01-11 17:55:35 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f740fa5094817e948853bbcba46410a05175260d

commit f740fa5094817e948853bbcba46410a05175260d
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jan 11 17:50:59 2018 +0000

    gdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)
    
    As Maciej reported at
    <https://sourceware.org/ml/gdb-patches/2017-12/msg00212.html>, this
    commit:
    
     commit d930703d68ae160ddfe8ebe5fdcf416fb6090e1e
     Date: Thu Nov 16 18:44:43 2017 +0000
     Subject: Don't ever Quit out of resume
    
    caused regressions on software single-set targets, specifically:
    
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: step in ro region (cannot insert hw break)
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: single-step breakpoint is not left behind
     FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: single-step breakpoint is not left behind
    
    and indeed detailed logs indicate a breakpoint is left lingering, e.g.:
    
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
     maint info breakpoints 0
     Num     Type           Disp Enb Address    What
     0       sw single-step keep y   0x00400774 in main at [...]/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c:24 inf 1 thread 1
    	 stop only in thread 1
     (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
    
    vs:
    
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
     maint info breakpoints 0
     No breakpoint or watchpoint matching '0'.
     (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
    
    as at commit d930703d68ae^.
    
    Before commit d930703d68ae, we had a cleanup installed in 'resume'
    that would delete single-step breakpoints on error:
    
      /* Resuming.  */
    
      /* Things to clean up if we QUIT out of resume ().  */
      static void
      resume_cleanups (void *ignore)
      {
        if (!ptid_equal (inferior_ptid, null_ptid))
         delete_single_step_breakpoints (inferior_thread ());
    
        normal_stop ();
      }
    
    That whole function was removed by d930703d68ae mainly to eliminate
    the normal_stop call:
    
    ~~~~
        Note that the exception called from within resume ends up calling
        normal_stop via resume_cleanups.  That's very borked though, because
        normal_stop is going to re-handle whatever was the last reported
        event, possibly even re-running a hook stop...
    ~~~~
    
    But as the regression shows, removing resume_cleanups completely went
    a bit too far, as the delete_single_step_breakpoints call is still
    necessary.
    
    So fix the regression by reinstating the
    delete_single_step_breakpoints call on error.  However, since we're
    trying to eliminate cleanups, restore it in a different form (using
    TRY/CATCH).
    
    Tested on x86-64 GNU/Linux both top of master and on top of a series
    that implements software single-step on x86.
    
    gdb/ChangeLog:
    2018-01-11  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22583
    	* infrun.c (resume): Rename to ...
    	(resume_1): ... this.
    	(resume): Reimplement as wrapper around resume_1.
Comment 4 Pedro Alves 2018-01-11 17:56:51 UTC
Fix pushed.