public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/20208] Error re-setting pending dprintf when re-running
       [not found] <bug-20208-4717@http.sourceware.org/bugzilla/>
@ 2024-12-24 15:39 ` aburgess at redhat dot com
  2025-02-24 11:02 ` cvs-commit at gcc dot gnu.org
  2025-02-24 16:37 ` aburgess at redhat dot com
  2 siblings, 0 replies; 3+ messages in thread
From: aburgess at redhat dot com @ 2024-12-24 15:39 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=20208

Andrew Burgess <aburgess at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |aburgess at redhat dot com
   Last reconfirmed|                            |2024-12-24

--- Comment #3 from Andrew Burgess <aburgess at redhat dot com> ---
This bug is fixed by this series:

 
https://inbox.sourceware.org/gdb-patches/cover.1734366277.git.aburgess@redhat.com

There are some additional improvements which I have made locally that make the
fix for this bug even better, however, the above series is blocked waiting for
this series to be merged:

 
https://inbox.sourceware.org/gdb-patches/cover.1735041586.git.aburgess@redhat.com

Once that lands upstream, I'll posted an updated version of the original
series.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug breakpoints/20208] Error re-setting pending dprintf when re-running
       [not found] <bug-20208-4717@http.sourceware.org/bugzilla/>
  2024-12-24 15:39 ` [Bug breakpoints/20208] Error re-setting pending dprintf when re-running aburgess at redhat dot com
@ 2025-02-24 11:02 ` cvs-commit at gcc dot gnu.org
  2025-02-24 16:37 ` aburgess at redhat dot com
  2 siblings, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2025-02-24 11:02 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=20208

--- Comment #4 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

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

commit 8c48ec7a6160aed0d1126c623443935e4435cd41
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Aug 29 12:34:15 2024 +0100

    gdb: handle dprintf breakpoints when unloading a shared library

    While working on the previous commit I realised that GDB would not
    handle dprintf breakpoints correctly when a shared library was
    unloaded.

    Consider this example using the test binary from shlib-unload.exp.  In
    the function 'foo' we create a dprintf is in a shared library:

      (gdb) b 59
      Breakpoint 1 at 0x401215: file
/tmp/projects/binutils-gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/shlib-unload.c,
line 59.
      (gdb) r
      Starting program:
/tmp/projects/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/shlib-unload/shlib-unload

      Breakpoint 1, main () at
/tmp/projects/binutils-gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/shlib-unload.c:59
      59      res = dlclose (handle);       /* Break here.  */
      (gdb) dprintf foo,"In foo"
      Dprintf 2 at 0x7ffff7fc50fd: file
/tmp/projects/binutils-gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/shlib-unload-lib.c,
line 23.
      (gdb) n
      Error in re-setting breakpoint 2: Function "foo" not defined.
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      warning: error removing breakpoint 2 at 0x7ffff7fc50fd
      Cannot remove breakpoints because program is no longer writable.
      Further execution is probably impossible.
      60      assert (res == 0);
      (gdb)

    What happens here is that as the inferior steps over the dlclose call
    the shared library containing 'foo' is unloaded and
    disable_breakpoints_in_unloaded_shlib is called.  However in
    disable_breakpoints_in_unloaded_shlib we have this check:

      if (b.type != bp_breakpoint
         && b.type != bp_jit_event
         && b.type != bp_hardware_breakpoint
         && !is_tracepoint (&b))
       continue;

    As the dprintf has type bp_dprintf then this check triggers and we
    ignore the dprintf, meaning the dprintf is not disabled.  When the
    inferior stops after the 'next' GDB tries to remove all breakpoints
    but the dprintf can no longer be removed, the memory in which it was
    placed has been unmapped from the inferior.

    The fix is to start using is_breakpoint() in
    disable_breakpoints_in_unloaded_shlib instead of the bp_breakpoint and
    bp_hardware_breakpoint checks.  The is_breakpoint() function also
    checks for bp_dprintf.

    With this fix in place GDB now correctly disables the breakpoint and
    we no longer see the warning about removing the breakpoint.

    During review it was pointed out that PR gdb/23149 and PR gdb/20208
    both describe something similar, though for these bugs, the inferior
    is restarted (which unloads all currently loaded shlib) rather than
    passing over the dlclose.  But the consequences are pretty similar.
    I've included a test which covers this case.

    One additional thing that these two bugs did show though is that
    disable_breakpoints_in_shlibs also needs to start using is_breakpoint
    for the same reason.  Without this change, when an inferior is
    restarted we get a warning like this for dprintf breakpoints:

      warning: Temporarily disabling breakpoints for unloaded shared library
"..."

    but we don't get a similar warning for "normal" breakpoints.  This is
    because disable_breakpoints_in_shlibs is called from clear_solib,
    which is called when an inferior is restarted.

    It is best not to think too hard about disable_breakpoints_in_shlibs,
    as this function is pretty broken, e.g. it doesn't call
    notify_breakpoint_modified, despite modifying the breakpoints.  But
    for now I'm ignoring that, but fixing this is definitely on my list
    for my next set of breakpoint related fixes, it's just that a lot of
    these breakpoint fixes end up being depending on one another, but I
    want to avoid making this series too long.  So for now, I'm ignoring
    the existing bug (missing breakpoint modified events), and fixing
    disable_breakpoints_in_shlibs to cover dprintf.

    With these fixes in place, the two bugs mentioned above should be
    fixed.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23149
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20208

    Tested-By: Hannes Domani <ssbssa@yahoo.de>
    Approved-By: Tom Tromey <tom@tromey.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug breakpoints/20208] Error re-setting pending dprintf when re-running
       [not found] <bug-20208-4717@http.sourceware.org/bugzilla/>
  2024-12-24 15:39 ` [Bug breakpoints/20208] Error re-setting pending dprintf when re-running aburgess at redhat dot com
  2025-02-24 11:02 ` cvs-commit at gcc dot gnu.org
@ 2025-02-24 16:37 ` aburgess at redhat dot com
  2 siblings, 0 replies; 3+ messages in thread
From: aburgess at redhat dot com @ 2025-02-24 16:37 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=20208

Andrew Burgess <aburgess at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Andrew Burgess <aburgess at redhat dot com> ---
I believe this issue should now be fixed in master.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-24 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-20208-4717@http.sourceware.org/bugzilla/>
2024-12-24 15:39 ` [Bug breakpoints/20208] Error re-setting pending dprintf when re-running aburgess at redhat dot com
2025-02-24 11:02 ` cvs-commit at gcc dot gnu.org
2025-02-24 16:37 ` aburgess at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).