I have a problem with the latest gdb code (updated from CVS 20000216);
step into functions (`step') does not work correctly when using shared
libraries.  Older versions, like 4.18, seems to work fine.

The problem at least occurs when trying to step into a function from
one shared library to another.

The example included demonstrates the bogus behaviour, tested on Red
Hat Linux v6.1 with gcc v2.95.2 and the latest gdb source.

When stepping into TestClass2 from TestClass, gdb treats the `step' as
a `next', i.e. the function is not visited.


CXXFLAGS += -fPIC -g

testapp:                main.o libtestclass.so libtestclass2.so
        $(CXX) $< -o $@ -L . -ltestclass -ltestclass2 -g -Wl,-rpath,.

debug default:          testapp

clean:
        -rm -f *.o *.so testapp

libtestclass.so:        testclass.o libtestclass2.so
        $(CXX) -shared -o $@ $< -L. -ltestclass2 -Wl,-rpath,.
libtestclass2.so:       testclass2.o
        $(CXX) -shared -o $@ $<
testclass.o:            testclass.cpp testclass.h testclass2.h
testclass2.o:           testclass2.cpp testclass2.h
main.o:                 main.cpp testclass.h testclass2.h

#include "testclass.h"
#include "testclass2.h"

void bar()
{
  int nResult = 84;
  nResult /= 2;
  TestClass2 c2;
  c2.foo();
}


int main(int, char** argv)
{
  bar();
  TestClass* pcT1 = new TestClass();
  int foo = pcT1->bar();
  bar();
  pcT1->bar();
  bar();
  pcT1->done();
  return 0;
}

#include "testclass.h"
#include "testclass2.h"

TestClass::TestClass()
  : m_nValue(0),
    m_bDone(false)
{
  m_nValue++;
  m_nValue = 10;
  m_nValue *= 2;
  m_nValue /= 5;
}
TestClass::~TestClass()
{
}
int TestClass::bar()
{
  TestClass2 c2;
  c2.foo();
  return m_nValue;
}
void TestClass::done()
{
  m_bDone = true;
}

#ifndef TESTCLASS
#define TESTCLASS
class TestClass
{
public:
  TestClass();
  ~TestClass();
  int bar();
  void done();
private:
  int m_nValue;
  bool m_bDone;
};
#endif // TESTCLASS

#include "testclass2.h"
TestClass2::TestClass2()
{
}
void
TestClass2::foo()
{
  int nResult = 5;
  for ( int i = 0; i < 3; ++i ) {
    nResult *= nResult;
  }
}

#ifndef TESTCLASS2
#define TESTCLASS2
class TestClass2
{
public:
  TestClass2();
  void foo();
};
#endif // TESTCLASS2

Reply via email to