This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Regarding PR no 1783


Hi,

Even i faced a similar problem.

This is a small code that we wrote :

#include
#include

class Sthread
{
public:
   int x ;
   int y ;
   Sthread() { printf ("Nice sthread\n") ;}

   ~Sthread() ;
   void test_sthread (void) ;
};

void Sthread::test_sthread (void)
{
   int i ;
   i = 10 ;
   i++ ;
   printf ("Value of I = %d\n", i) ;
}

void main ()

{
  class Sthread *newThr ;

  printf ("This code tests gdb type printing \n") ;
  newThr = new Sthread() ;

newThr->test_sthread() ;

  return 0 ;
}

On debugging this with the latest gdb
6.6, here's the output :

GNU gdb 6.6
Copyright (C) 2006 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 "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) break main
Breakpoint 1 at 0x8049522: file new.cpp, line 26.
(gdb) run
Starting program: /emc/quabalak/progs/new

Breakpoint 1, main () at new.cpp:26
26         printf ("This code tests gdb type printing \n") ;

(gdb) n
This code tests gdb type printing
27         newThr = new Sthread() ;
(gdb) ptype Sthread
type = class Sthread {
 public:
   int x;
   int y;

Sthread & operator=(Sthread const &);

   ~Sthread(void);
   Sthread(Sthread const &);
   Sthread(void);
   void test_sthread(void);
}
(gdb) n
Nice sthread
29         newThr->test_sthread() ;
(gdb) s
Sthread::test_sthread (this=0x8050bb8) at
new.cpp:17
17          i = 10 ;
(gdb) ptype Sthread
Type Sthread has no component named Sthread.
(gdb)

From this its seen that the type of a class can be printed without
problems as long as you are not inside the member function of that
class itself. When inside the

member function like in test_sthread (), trying to print the type of
the class gives a problem. Till gdb fixes this problem, the workaround
is to suffix
"class" before the class name. In the above case, we would be required to say

(gdb) ptype class Sthread

I tried with tha latest redhat gdb release 6.6, the problem still
exists. So would like to know any further updates on this problem. By
when it will be fixed?

Thanks in advance

Indira


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