Bug 301701 - GDB fails to break in the $delete destructor
GDB fails to break in the $delete destructor
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
rawhide
All Linux
medium Severity low
: ---
: ---
Assigned To: Jan Kratochvil
Fedora Extras Quality Assurance
: Reopened
Depends On: 298061
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-22 11:55 EDT by Jan Kratochvil
Modified: 2007-12-10 18:49 EST (History)
2 users (show)

See Also:
Fixed In Version: gdb-6.6-34.fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-12-10 18:49:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
kevin: fedora‑cvs+


Attachments (Terms of Use)
Testcase. (19.58 KB, application/octet-stream)
2007-09-22 11:55 EDT, Jan Kratochvil
no flags Details

  None (edit)
Description Jan Kratochvil 2007-09-22 11:55:22 EDT
Description of problem:
When I am trying to set breakpoint on a destructor, which has virtual destructor
in its inheritance, using 'b class::~class' form, gdb sets the breakpoint, but
it does not get hit when program is run. Gdb most likely setting this breakpoint
on a incorrect PC address, or setting it on non in-charge destructor, which
never gets called.


How reproducible:
See attached testcase


-- Additional comment from jan.kratochvil@redhat.com on 2007-09-20 10:26 EST --
[...]

Comment 1 lists the command 'b class::~class', I agree this command does not
target the destructor variant used in the testcase.

(1) Please use apostrophes to quote the destructor (/constructor) names
    themselves, such as:
    (gdb) b 'my::~my'

(2) You may use <tab>-completion if you use the quotation as above:
    (gdb) b 'my::~my<tab>

(3) In this specific testcase of the provided it_file 101926 you should use:
    (gdb) b 'my::~my$delete()'

(4) There is a break-point menu provided if the specified name qualifies for
    multiple functions:
    (gdb) b 'A::A'
    [0] cancel
    [1] all
    [2] A::A() at /tmp/constructor.C:9
    [3] A::A(int) at /tmp/constructor.C:10
    [4] A::A(long) at /tmp/constructor.C:11
    [5] A::A$base() at /tmp/constructor.C:9

    It may be considered a Bug in the Red Hat branch of the GDB that it does not
    offer the `$delete' destructor variants in this menu.  Therefore
    (gdb) b 'my::~my'
    only resolves to a single destructor instance and thus no menu is displayed.
    With the proposed fix there would be some menu like:
    (gdb) b 'my::~my'
    [0] cancel
    [1] all
    [2] my::~my() at destructor.cxx:24
    [3] my::~my$delete() at destructor.cxx:24

(5) Another Bug targets the proper rewrite of this constructors/destructors
    handling by GDB.  The current Jeff Johnston's patches use the .symtab
    section and depend on the DW_AT_MIPS_linkage_name DWARF tags.  This is
    wrong as it should all be based on the unnamed DWARF .debug_info PC ranges.
    I already spent a lot of time on this patch but I still do not have it
    finished right now.  Still I hope to get it upstream submittable soon.


Suggesting to consider this Bug as the target for (4) - to update
add_minsym_members() in gdb-6.3-linespec-20041213.patch to also list the
`$delete' variant of the destructor.  Only the $allocate variant of the
constructors is defined in the patch gdb-6.3-constructor-20041216.patch but
AFAIK gcc never uses this one.  This the patch may also include even this one.


-- Additional comment from jan.kratochvil@redhat.com on 2007-09-21 11:41 EST --
[...]

here is the proposed implementation:

(gdb) b my::~my
[0] cancel
[1] all
[2] my::~my() at destructor.cxx:24
[3] my::~my$delete() at destructor.cxx:24
> 1
Breakpoint 3 at 0x400e2a: file destructor.cxx, line 24.
Breakpoint 4 at 0x400db8: file destructor.cxx, line 24.
warning: Multiple breakpoints were set.
warning: Use the "delete" command to delete unwanted breakpoints.

(gdb) b 25
Breakpoint 1 at 0x400dd1: file destructor.cxx, line 25.
Breakpoint 2 at 0x400e43: file destructor.cxx, line 25.
warning: Multiple breakpoints were set.
warning: Use the "delete" command to delete unwanted breakpoints.
Comment 1 Jan Kratochvil 2007-09-22 11:55:22 EDT
Created attachment 203081 [details]
Testcase.
Comment 2 Jan Kratochvil 2007-09-22 12:36:05 EDT
Committed to the Rawhide CVS:
* Sat Sep 22 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-28
- Support also the `$allocate' and `$delete' ctor/dtor variants (BZ 301701).
Comment 3 Jan Kratochvil 2007-10-08 08:25:32 EDT
It was also committed to Rawhide CVS for this Bug:
* Wed Sep 26 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-30
- Fix re-setting of the ctors/dtors breakpoints with multiple PCs (BZ 301701).

But now it does not work for shared libraries and PIE executables for
breakpoints set before the binary gets loaded:
(gdb) b 25
Breakpoint 1 at 0xf95: file two.C, line 25.
Breakpoint 2 at 0x1019: file two.C, line 25.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) r
Starting program: /tmp/gdb_desc_brkpt_bug/twopie 
Breakpoint 1 at 0xf95
Breakpoint 2 at 0x1019
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0xf95: Input/output error.
Cannot insert breakpoint 2.
Error accessing memory address 0x1019: Input/output error.
Comment 4 Jan Kratochvil 2007-10-08 08:26:31 EDT
Going to commit there a prepared fix for F-8:

Package Change Request
======================
Package Name: foobar
New Branches: F-8
Comment 5 Kevin Fenzi 2007-10-08 14:32:01 EDT
Package Name: foobar? 
Should that be gdb? or was there some other package you needed branched?
Comment 6 Jan Kratochvil 2007-10-08 14:39:11 EDT
(In reply to comment #5)
> Package Name: foobar? 
> Should that be gdb? or was there some other package you needed branched?

Sure it was a copy-paste typo, sorry:

Package Change Request
======================
Package Name: gdb
New Branches: F-8
Comment 7 Kevin Fenzi 2007-10-08 14:49:21 EDT
Yeah, just wanted to make sure. ;) 

cvs done. 
Comment 8 Jan Kratochvil 2007-12-10 18:49:07 EST
This Bug started the F-8 branch and this Bug got the final fix by:
* Sun Oct 14 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-34
- Set the breakpoints always to all the ctors/dtors variants (BZ 301701).

On the other hand this whole patchset is already superseded in F9 6.7.1.

Note You need to log in before you can comment on or make changes to this bug.