Bug 466222 - gdb fails to set breakpoints
gdb fails to set breakpoints
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gdb (Show other bugs)
4.6
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Jan Kratochvil
BaseOS QE
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-09 05:09 EDT by Olivier Fourdan
Modified: 2013-03-03 21:47 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
* Placing a breakpoint to program having some parts compiled without debugging information (as provided by gcc -g) could put the breakpoint at incorrect place. The updated GDB places the breakpoint where the user requested even for code without debugging information present. Note: the program still must not have been stripped by the strip program.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-05-18 16:33:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
PAtch to fix the PC computation in find_pc_sect_line() (893 bytes, patch)
2008-10-09 05:09 EDT, Olivier Fourdan
no flags Details | Diff

  None (edit)
Description Olivier Fourdan 2008-10-09 05:09:05 EDT
Created attachment 319839 [details]
PAtch to fix the PC computation in find_pc_sect_line()

Description of problem:

gdb 6.3 sometimes fails to find the address of a function and the breakpoint is not set correctly.

Version-Release number of selected component (if applicable):

gdb-6.3.0.0-1.153

How reproducible:

100% reproducible

Steps to Reproduce:
1. Get Qt 4.4 and build it
2. edit demos/browser/main.cpp withing the Qt source directory and add two C functions

    void
    test_fn1(void)
    {
        printf ("Been there\n");
    }

    void
    test_fn2(void)
    {
        printf ("Done that...\n");
    }

    int main(int argc, char **argv)
    {
        Q_INIT_RESOURCE(data);
        BrowserApplication application(argc, argv);
        if (!application.isTheOnlyBrowser())
            return 0;
        test_fn1 ();
        test_fn2 ();
        application.newMainWindow();
        return application.exec();
    }

3. Modify the Makefile to remove the debugging symbols and compile with -O3

    CFLAGS        = -m64 -pipe -O3 -D_REENTRANT -Wall -W $(DEFINES)
    CXXFLAGS      = -m64 -pipe -O3 -D_REENTRANT -Wall -W $(DEFINES)

4. Build the demo browser
5. Try to set breakpoints on these functions from gdb
  
Actual results:

    $ gdb qt-x11-opensource-src-4.4.1/demos/browser/browser
    GNU gdb Red Hat Linux (6.3.0.0-1.159.el4rh)
    ...
    This GDB was configured as "x86_64-redhat-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".

    (gdb) break test_fn1
    Breakpoint 1 at 0x439105: file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 427.
    (gdb) break test_fn2
    Note: breakpoint 1 also set at pc 0x439105.
    Breakpoint 2 at 0x439105: file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 427.

Expected results:

gdb qt-x11-opensource-src-4.4.1/demos/browser/browser
    GNU gdb Red Hat Linux (6.3.0.0-1.159.el4rh)
    ...
    Using host libthread_db library "/lib64/tls/libthread_db.so.1".
    (gdb) break test_fn1
    Breakpoint 1 at 0x472c50
    (gdb) break test_fn2
    Breakpoint 2 at 0x472c60

Additional info:

This bug has been fixed between gdb-6.6 and gdb 6.7 by this commit on symtab.c:

    revision 1.149
    date: 2006/11/28 16:23:32;  author: drow;  state: Exp;  lines: +5 -17
            * symtab.c (find_pc_sect_line): Do not return a line before
            the start of a symtab.

The fix was commited by drow on 28-Nov-06.

The fix simply sets "val.pc = pc" instead of trying to compute a a value based on "alt->line - 1".

Patch attached.

*Note*: The fix went in in gdb 6.7 so RHEL5 which uses gdb 6.5 might be also affected, I did not check on RHEL5 (the issue being reported on RHEL4).
But the patch should apply equally on gdb-6.5 for RHEL5 (if that's needed).
Comment 2 RHEL Product and Program Management 2008-10-31 12:51:50 EDT
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".
Comment 7 RHEL Product and Program Management 2008-12-16 14:17:52 EST
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".
Comment 12 Ruediger Landmann 2009-02-03 19:29:06 EST
Release note added. If any revisions are required, please set the 
"requires_release_notes" flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

New Contents:
* Placing a breakpoint to program having some parts compiled without debugging information (as provided by gcc -g) could put the breakpoint at incorrect place.  The updated GDB places the breakpoint where the user requested even for code without debugging information present. Note: the program still must not have been stripped by the strip program.
Comment 16 errata-xmlrpc 2009-05-18 16:33:23 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1015.html

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