Bug 301701

Summary: GDB fails to break in the $delete destructor
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: cagney, kevin
Target Milestone: ---Keywords: Reopened
Target Release: ---Flags: kevin: fedora-cvs+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-6.6-34.fc8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-12-10 23:49:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 298061    
Bug Blocks:    
Attachments:
Description Flags
Testcase. none

Description Jan Kratochvil 2007-09-22 15:55:22 UTC
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 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 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 15:55:22 UTC
Created attachment 203081 [details]
Testcase.

Comment 2 Jan Kratochvil 2007-09-22 16:36:05 UTC
Committed to the Rawhide CVS:
* Sat Sep 22 2007 Jan Kratochvil <jan.kratochvil> - 6.6-28
- Support also the `$allocate' and `$delete' ctor/dtor variants (BZ 301701).


Comment 3 Jan Kratochvil 2007-10-08 12:25:32 UTC
It was also committed to Rawhide CVS for this Bug:
* Wed Sep 26 2007 Jan Kratochvil <jan.kratochvil> - 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 12:26:31 UTC
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 18:32:01 UTC
Package Name: foobar? 
Should that be gdb? or was there some other package you needed branched?

Comment 6 Jan Kratochvil 2007-10-08 18:39:11 UTC
(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 18:49:21 UTC
Yeah, just wanted to make sure. ;) 

cvs done. 

Comment 8 Jan Kratochvil 2007-12-10 23:49:07 UTC
This Bug started the F-8 branch and this Bug got the final fix by:
* Sun Oct 14 2007 Jan Kratochvil <jan.kratochvil> - 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.