Using ldb

This is a very short guide to using ldb. Not much, but all there is.

Compile your program with lcc -G To start your program, type

a.out --pause-- args
It will print out a message like
  => DEBUG NUB <=
  to debug: /usr/local/bin/ldb target a.out connect dynastar 1143
In a separate window, execute the ldb command. You can also start ldb by typing just `ldb' or `ldb a.out'. You must execute ldb from the directory in which a.out was linked. ldb has a cd command so you can change directories without restarting. Type '?' to ldb for a list of commands.

If you just want to debug a running program, send it a QUIT, which the debug nub will catch.

Common problems

If the expression server gets into a bad state (as a result of faulty error recovery), the following sequence will get a new one:
	disc wait		(disconnect)
	target a.out		(loses old state, including bad exp server)
	connect host port	(reconnect to the same target)

Complaints, questions, or comments to nr@cs.tufts.edu.

Tricks

To generate information for external symbols, compile a file with lcc -G -SE. Useful if you want to call strcmp() or want to refer to _iobuf[0] (stdin), etc.

To dereference pointers in structures, arrays, etc, type to ldb i /followpointers 1 def 2, 3, or more will follow more pointers. 0 is default, doesn't follow pointers.

By default ldb prints only the first 100 elements of an array. To change the number, type to ldb

    i /$ArrayLimit 15 def
e.g. to print the first 15 elements. Similary ldb prints only the first 30 characters of strings; for more, type to ldb e.g.
    i /$StringLimit 50 def

Bugs

You can run ldb and a target program in the same window using ldb's `run' command. ldb shares standard input gracefully, but there are some problems: