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]

Re: Move GDB to C++ ?


Andrew Cagney wrote:

> Instead of changing GDB to C++ and hoping the change will magically
> transform GDB's code base into a clean ideal design; should we instead
> be focused on trying to address what I suspect is the underlying
> motivation here - a desire to clean up and re-structure GDB's code base
> so that it more clearly corresponds to a more modern Object Oriented design?

I think that trying to use better design without support of a language for which
such design is a native one, would be considerably harder. GNOME is a perfect 
example -- in attempt to use OOP in C, they have this GObject thing which is an
approximation of real classes, only harder to use. Ah, and there's even separate
tool, called GOP, that takes class definition in some meta-language and produces
.h and .c file. So, there's fairly complicate non-standard solution for
an already-solved problem.

Let's use one example in GDB -- values. Presently, struct value has a 
field lval_type, and in a number of places, a switch over lval_type is
made. This switch-over-type is a typical red-flag in OOP programs; in case
of GDB this makes it hard to understand what is exact behaviour of 
lval_register, for example. CodeSourcery's implementation of register browing
required extending struct value, so that fetching a value goes via special
remote protocol packet. This ended up been not exactly nice. If struct value
was a base class with a defined interface, and each kind of value (rvalue, lvalue,
register, etc) were a derived class, then the internal logic of GDB would be
more clear, and adding new kinds of values would be much simpler.

I'd be happy to actually refactor struct value in this way, but only when using
the proper tool, namely C++. I don't want to complicate things by emulating
classes in C.

Actually, it appears that this C++ discussion got a bit stalled, apparently since
nobody wants to make the first step. So, how about his plan of action:

1. GDB is made compiled with C++ compiler, with resulting errors removed.
2. I refactor struct value, and folks get to comment if the resulting code
is better, or worse, than what we have.

Comments?

-  Volodya



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