Differences between revisions 14 and 15
Revision 14 as of 2013-07-31 11:41:41
Size: 5440
Editor: PedroAlves
Comment: fix tables
Revision 15 as of 2013-07-31 11:43:49
Size: 5582
Editor: PedroAlves
Deletions are marked like this. Additions are marked like this.
Line 46: Line 46:
  * Configury stuff.

     || GDB || GDBserver || comments ||
     || gdb/configure.ac, etc. || gdb/gdbserver/configure.ac, etc. || ||
Line 65: Line 70:
  2. Create Makefile.am and m4 files, but don't creat configure files. Similar to what we did for gnulib. This is suggested by Pedro.   2. Create Makefile.am and m4 files, but don't create configure files. Similar to what we did for gnulib. This is suggested by Pedro.

Common part of GDB and GDBserver

This page describes the work to move duplicate code of GDB and GDBserver to files in the gdb/common/ directory.

1. Goal

There's a lot of code duplication between GDB and GDBserver. The project has been taking baby steps in reducing such duplication, by putting shared code in the gdb/common/ directory. The goal of this project is to reduce the duplication as much as possible, and to signify the contents of the gdb/common/ directory.

2. Where's the duplication then?

  • Target backends. These are the biggest duplication offenders. That is, the gdb/*-nat.c files and the gdb/gdbserver/*-low.c files accomplish pretty much the same. (Some targets do things differently enough, that they're not really duplication of code, but can be considered different implementations. The Linux support is one such case. Over the years we've been converging them though -- see the LocalRemoteFeatureParity page for more details.). GDBserver supports fewer target OSs than GDB does. Ideally, we'd finish the LocalRemoteFeatureParity project first, and then just dump the GDB-side backends. However, there are bits of the backends, most prominently, the arch specific bits, that can be shared between the implementations before then, as the interfaces are similar enough. E.g., debug registers/watchpoint support; code that detects which variant of a processor the program is running (the xml target description to send to GDB core), etc.. Sharing such arch specific code significantly reduces the effort for new ports (those usually don't need to touch common code). As is today most ports involve doing the same work twice. We should clean up some of the existing ports, laying grounds for good examples for new ports. Presently, there's overlap/duplication in:

    • Linux
      • See the LocalRemoteFeatureParity page for more details.









        ... and related arch specific files ...

    • Windows
      • GDB




        ... and related arch specific files ...

    • NTO
      • GDB




        ... and related arch specific files ...

  • Terminal handling
    • GDB






  • Event loop machinery
    • GDB





  • Configury stuff.
    • GDB



      gdb/configure.ac, etc.

      gdb/gdbserver/configure.ac, etc.

3. Plan

Here is something like a plan on what we can do on this project,

  • Move duplicated code among *-nat.c and *-low.c. Some macros, and code accessing hardware registers should be the same on both GDB and GDBserver. No reason to keep the same code in two copies respectively. Move these duplicated part to common/ directory, and give a logically reasonable file name. For example, the code for accessing debug registers are duplicated in i386-low.c and i386-nat.c, so they can be moved to common directory with file name i386-dbg-reg.c and i386-rdbg-reg.h. See Move common macros to i386-dbg-reg.h. There is no automatic way to identify the duplications between *-nat.c and *-low.c except examining code manually.

  • Move duplicated code in gdb/linux-thread-db.c and gdb/gdbserver/thread-db.c. There should be some duplications, but still no idea on how to, due to lack of knowledge on these two files. As part of this piece of work, part of gdb_proc_serivce.h in GDB and GDBserver can be moved to common dir, and leave its own definition of 'struct ps_prochandle'.
  • Part of terminal.h is duplicated as well, and we can move them to common/ dir.

4. Guidelines

4.1. File Naming

  • Avoid "common" in file names in files under common/. Instead, name the files for what they contain, not for the fact that they're "common" to two programs (gdb, gdbserver) presently. The preferred direction is, when moving things to common/, take the opportunity to split them into smaller, more atomic, leaner units. E.g., that's how we ended up with ptid.h/ptid.c, instead of inferior-common.h (or some such). If the resulting file is just a dumping ground of miscellaneous things, then call it that. Say, foo-misc.h or foo-defs.h, not foo-common.h.

5. Build/Configure

In order not to mess up the plan above, Yao moves build/configure related stuff into a separate section. In March 2011, Yao gave a try to build stuffs in common/ directory into libcommon.a, for GDB and GDBserver to link. See the thread on this here. Finally, patches were dropped from CVS, because of various failures they caused.

So far, we have three possible approaches,

  1. Don't have its own build stuff in common/, let gdb or gdbserver to build them.
  2. Create Makefile.am and m4 files, but don't create configure files. Similar to what we did for gnulib. This is suggested by Pedro.
  3. Use Yao's original's patches, with various bugs fixed.


None: Common (last edited 2016-01-16 14:43:53 by PedroAlves)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.