[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
| Title: | Digital Ladebug debugger | 
|  | 
| Moderator: | TLE::LUCIA | 
|  | 
| Created: | Fri Feb 28 1992 | 
| Last Modified: | Fri Jun 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 969 | 
| Total number of notes: | 3959 | 
891.0. "Problems with virtual functions/inheritence" by DECC::MJHANS (Matthew Hanselman, DEC C/C++) Wed Mar 19 1997 12:01
    ladebug 4.0-30 and DEC C++ 5.5-004
    
    I've noticed a problem with setting breakpoints in classes that have
    virtual inheritence/functions.  Namely, in certain circumstances, you
    cannot set a breakpoint in a class that does not override or introduce
    any new virtual functions.
    
    This is actually a problem/quirkiness of the object model, and it's not
    entirely clear how it should be solved.  For a pointer to a description
    of the quirkness, look at page 17, example 4-16, of the document
    http://tlg-www.zko.dec.com/tlg/cxxc/www/deccxx-object-model.ps.
    
    An example and quick explanation:
    
    C3 does not introduce or override any virtual functions.  But the
    quirkiness of the object model requires C3 to have a vptr anyway.  This
    vptr is never used by the compiler, and is never initialized.  Ladebug
    is attempting to follow this vptr, and is dying as a result.
    
    How should this be solved?  I think that before ladebug follows a vptr,
    it should first check to make sure there are no virtual functions
    introduced/overidden.  
    
    What do you think?
    
    Compile & debug the following program.  input "stop in main; run; stop
    in c3.f" to see the problem.
    
    ------------------------------------------------------------------
    struct C1 {};
    
    struct C2 {
        virtual int f();
    }; 
    
    struct C3 :  public virtual C1, public virtual C2 {};
    
    int C2::f()
    {
        return 0;
    }
    
    C3 c3;
    int main()
    {
        return c3.f();
    }
    ------------------------------------------------------------------
    % ladebug a.out
    Welcome to the Ladebug Debugger Version 4.0-30
    ------------------ 
    object file name: a.out 
    Reading symbolic information ...done
    (ladebug) stop in main; run; stop in c3.f
    [#1: stop in int main(void) ]
    [1] stopped at [int main(void):17 0x1200022ac]
         17     return c3.f();
    Cannot reference virtual table: table pointer is zero
    c3.f has no valid breakpoint address
    Warning: Breakpoint not set
    
    
    							- Matt
| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 891.1 | Added to list | TLE::MERRITT | Steve Merritt, Ladebug Team | Fri Mar 21 1997 10:33 | 6 | 
|  | 
Thanks for the input.  I've added this to the C++ issues list.
I'll try to look at it shortly.
-Steve
 |