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: Will therefore GDB utilize C++ or not?


On 04/10/2012 02:41 AM, Pedro Alves wrote:
> Indeed, gdbserver would need to remain pure C, and likewise any
> code shared between gdbserver and gdb should have to be kept
> as such.  This is important, because we want gdbserver to be usable
> in #1, resource constrained scenarios where the C++ dependency would
> be unacceptable.  We don't want there to need to be other gdbserver-like
> programs specialized for such environments, and gdbserver to be usable only
> on bigger machines.  We want gdbserver to run everywhere.  And #2, the debugger

I agree.  The system configure or capability of embedded devices are
diversiform, from tiny piece of memory to multiple giga-bytes of memory.
 GDBserver fits to low-end devices.  Even nowadays, the size of
GDBserver increases as more functionalities added, we should avoid
GDBserver depends on C++ libraries.

> is one of the first programs that is desirable to get running on a new
> system/board.  Usually you get C going much sooner than C++.
> 

Yes, when building up a system on a board, GDBserver is usually the
"first class" programs to build.

> 
> I'm very wary that introducing C++ will make it increasingly
> difficult to share between the C++ and C parts.  Currently not
> that much is shared between gdb and gdbserver, but it is long desired,
> and in actually in this year's plan to merge gdb's and gdbserver's
> backends (am I am actively working on this.  See
> <http://sourceware.org/gdb/wiki/LocalRemoteFeatureParity>).

Agree.  We have multiple codes to share among GDB and GDBserver, this
will reduce the scope of GDB C++-fication.

> There's also the issue with in-process code, which is also
> desirable to remain as C code.  Latest developments push towards having
> debugger code run _within_ the inferior.  Witness gdbserver's current IPA
> (in-process agent; libinproctrace.so), which has a lot of coupling in its
> implementation (and a lot of code shared), and a bunch of code shared with
> gdbserver.  We can't predict which bits of GDB will we want to be able to
> reuse in GDBserver or an IPA, but I do believe that we will be considering
> it (reuse something more) the future.
> 

As GDBserver and in-process agent becomes more and more powerful (which
is the trend of debugging, IMO), they will share more and more code with
GDB.  For example, when supporting ITSET in GDBserver and in-proc agent,
even the design is not mature, it shows that we need move some bits of
GDB to gdb/common, and share with GDBserver and in-proc agent.

> So all in all, I believe that in a C++ world, GDB's "C++ in C" wouldn't
> really go away; it would end up still being prominent, not as hidden as
> libbfd or other dependencies.  Not hidden enough that we could just
> tuck it under the carpet.  I worry that this actually makes it _worse_
> for new contributers, who will need to learn about GDB's C idiomatic usage,
> and whatever new C++ idiomatic usage GDB would end up with.  With that, and
> the worry about the new source of trouble and bugs and confusion that
> it would be the bridging between the parts written in the different languages,
> I do believe we're better off staying in C land, at least for a couple years more.

In short, I am not against using C++ in GDB.

-- 
Yao (éå)


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