Installing ldb

ldb is a prototype of a retargetable debugger for the lcc ANSI C compiler.

Extract the distribution into its own directory. (All paths below are relative to this directory.) Installation proceeds as follows:

  1. If you don't have it already, get and install Icon. You don't need the Icon compiler; icont is sufficient, so you can probably pick up a binary distribution.
  2. If you don't have it already, get and install noweb. Since you'll have Icon, you might as well use the Icon library option when building noweb.
  3. If you don't have it already, get and install SRC Modula-3. Make sure the directory containing the Modula-3 binaries is on your search path, since the ldb binaries will also be installed there. Take note of the default directory where m3ship installs packages, since ldb and lcc will install and look for code in such packages. We refer to that directory below as $PKG_INSTALL. You'll need to know the name of the subdirectory where m3build puts machine-dependent stuff; there are lots of possibilities, like SPARC, SOLgnu, LINUXELF, etc. You'll also need to know where m3ship puts binaries; we'll call that directory $BIN_INSTALL.

    You'll need at least version 3.5.4-B, and unless you have a later version you'll need to fix the quake code for derived_c.

  4. Get and install lcc. ldb requires version 3.4b, but the patches supplied may work with more recent versions.
  5. From the root directory of the lcc distribution, apply the patches in lcc-3.4b-patch of the ldb distribution. The current patches apply to lcc version 3.4b; if you have a later version of lcc, you may have to apply one or more patches by hand.

    The patches change the lcc driver and sources so that lcc -G makes lcc generate symbol tables for ldb. They should also create the files src/ldbstab.c and src/ldbstab.h in the lcc distribution. They also change src/makefile and the bind table src/bind.c.

  6. If you are using the Linux distribution, unpack the additional Linux files on top of the patched lcc, then apply lcc-3.4b-linux-patch. I have tested this patch against Ken Yap's Linux ELF distribution, not the Linux a.out distribution.
  7. Change the option() function for your target to recognize the -G option. See etc/linux.c or etc/labrador.c for an examples. This option should: You should be able to make most of this stuff work just by changing libprefix in the sample code. You may need to add an extra empty string to the ld[] command.
  8. Re-build and re-install install the lcc driver and rcc compiler.
  9. Now return to the ldb distribution directory and change to the pkg subdirectory. If all goes well, you should be able to type `make debugger' and go out for a long lunch while your machine builds and ships one package after another. Among the many files created and shipped is the debugger ldb and the standalone PostScript interpreter m3ps. They are actually the same executable, but it does different things depending on its name.

    If anything goes wrong, you will have to consult the guide to the source to determine what package failed to build and hazard a guess why.

    You only need to build a debugger on one machine; from that machine, you should be able to teledebug to any machine supported by ldb (all two of them).

  10. You also have to build a debug nub on every machine you want to run target programs on. At the moment, the debug nub makes strongly BSD-ish assumptions, especially about signal handling. It definitely works under SunOS 4.1, and it might work on DEC ULTRIX. I hope a good person will do a POSIX version soon.

    To build the debug nub, type `make debugger', also in the pkg subdirectory of the ldb distribution. Even though the debug nub is written entirely in C and assembly language, it still uses the Modula-3 m3build program to do the building and installation, so you'll need that on your platform.

With luck, you can now run programs compiled with lcc -G and teledebug them.
Norman Ramsey
Division of Engineering and Applied Sciences
Harvard University
33 Oxford Street
Cambridge, MA 02138

Please report problems to nr@cs.tufts.edu.