This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

2.95.2 nad 2.95.1 g++ debug bug?


Hello,

I noted that gdb 4.16, 4.18, and 20000314 all step into g++ 2.95.2 and
2.95.1 but not 2.8.1 iostream via a next.  Is this a bug or
configuration problem with g++ 2.95.x or gdb?  We are using
AlphaServers running Digital UNIX 4.0D.  I used 'g++ -g created.cpp'
to compile a simple C++ program attached below.

--------------------------------------
GNU gdb 20000314
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alphaev56-dec-osf4.0d"...
(gdb) break main
Breakpoint 1 at 0x12000b5d8: file created.cpp, line 23.
(gdb) run
Starting program: /home/u3/rjackson/cpp/a.out 

Constructor for obj 
Breakpoint 1, main () at created.cpp:23
23         cout << "\nStarting main";
(gdb) n
ostream::operator<< (this=0x14000eac0, s=0x140006c20 "")
    at /usr/local/src/gcc_2.95.2/gcc-2.95.2/libio/iostream.cc:816
816     {
(gdb) n
ostream::operator<< (this=0x1400003f8, s=0x140005568 "\nStarting main")
    at /usr/local/src/gcc_2.95.2/gcc-2.95.2/libio/iostream.cc:817
817       if (opfx())
(gdb) quit
The program is running.  Exit anyway? (y or n) y
--------------------------------------

On a Solaris system gdb next works as expected.

--------------------------------------
GNU gdb 19990712
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.7"...
(gdb) break main
Breakpoint 1 at 0x12054: file created.cpp, line 20.
(gdb) run
Starting program: /home/rjackson/a.out 


Breakpoint 1, main () at created.cpp:20
20         cout << "\nStarting main";
(gdb) n
Constructor for obj 1 called
21         simpleObj obj2 (2);            // main local automatic object
(gdb) n
Starting main
Constructor for obj 2 called
23         somefunc();                   //  function call
(gdb) q
The program is running.  Exit anyway? (y or n) y
--------------------------------------

created.cpp
--------------------------------------
//  File createD.cpp
//  demonstrates when constructors/destructors/overloaded= are called

#include <iostream>

class simpleObj {
  public:
     simpleObj ( int num);
     simpleObj (const simpleObj& rhs);
     simpleObj& operator = (const simpleObj& rhs);
     ~simpleObj();
  private:
     int data;
};

void somefunc ();      // function prototype
void somefunc2 (simpleObj);  // function2 prototype

simpleObj obj1 (1);   //  global object

int main ()
{
   cout << "\nStarting main";
   simpleObj obj2 (2);            // main local automatic object
   static simpleObj obj3 (3);    //  main local static object
   somefunc();                   //  function call
   simpleObj obj4 (4);           // main local automatic object
   simpleObj obj5 = obj4;        // main local automatic object
   obj2 = obj4;
   somefunc2(obj4);
   cout << "\nLeaving main";
   return 0;
}


// smallObj function definitions
simpleObj::simpleObj (int num)
{
    data = num;
    cout << "\nConstructor for obj " << data <<" called";
}

simpleObj::simpleObj (const simpleObj& rhs)
{
    data = rhs.data;
    cout << "\nCopy Constructor for obj " << data <<" called";
}


simpleObj& simpleObj::operator = (const simpleObj& rhs)
{
    cout << "\nOverload= for obj " << data <<" called";
    if (this == &rhs)
       return *this;
    data = rhs.data;
    return *this;
}

simpleObj::~simpleObj ()
{
   cout << "\nDestructor for obj " << data <<" called";
}

// function definition
void somefunc ()
{
   cout << "\nStarting function";
   simpleObj obj5 (5);            // main local automatic object
   static simpleObj obj6 (6);   //  main local static object
   simpleObj obj7 (7);           // main local automatic object
   cout << "\nLeaving function";
}

void somefunc2 (simpleObj objj)
{
  cout << "\nStarting function2";
  cout << "\nLeaving function2";
}
--------------------------------------

-- 
Regards,
Richard Jackson
Computer Center Lead Engineer
Central Systems & Dept. UNIX Consulting
University Computing & Information Systems (UCIS)
George Mason University, Fairfax, Virginia

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]