[ Home ]
SBCL Internals

The pages on this CLiki-driven site can be edited by anybody at any time. No warranty of any kind can therefore be made; any implied warranties of merchantability or fitness for a particular purpose are expressly disclaimed
[ Home ] [ Recent Changes ] [ About CLiki ] [ Text Formatting ]

ldb is the low-level debugger that came from CMUCL, which you can compile into your SBCL builds by adding :sb-ldb to customize-target-features.lisp?. (Note that you will probably need to create that file first; it is not present in the distribution, and is in fact excluded from the distribution by being mentioned in places like .cvsignore.)

It's considerably more useful on non-x86 ports because it knows how to do backtraces. With that caveat, it's invaluable for sorting out low-level problems in porting SBCL to a new platform. Here are some of the more useful things:

Inspecting objects in memory

ldb> print 0x8338701
$1=       0x08338701: function pointer
            header: 0x00006e7e: function header
            jump-insn: 0x48000018: 301989894
$1=         self: 0x08338701: #
$nil=       next: 0x0500000b: NIL
$2=         name: 0x07022497: !COLD-INIT
$3=         arglist: 0x0833758f: "()"

Backtraces

Need example

Use with gdb

Primarily, if you have ldb compile in and your SBCL dies catastrophically, you get the ldb> prompt instead of having it quit to the command line. So, there's still a process left to attach gdb to

Making do with only gdb

It's also possible to use bare gdb to do debugging of early boot, if you're sufficiently determined. See gdb.

(Arguably, doing so is easier than maintaining ldb, which is why Bill Newman gave up on ldb in the original X86 bootstrapping. Dan Barlow likes ldb better, though.)

Dan's actually idly speculating on the possibility of jettisoning ldb in favour of an exciting set of gdb macros which could do most of what ldb does (and, he hopes, could be automatically defined at genesis time so we actually know they're correct), but (a) hasn't really investigated the feasibility, and (b) likes the said facilities far too much to want to give them up in the meantime)

Dropping into ldb

One way to drop into ldb is by hitting an implementation bug which causes sbcl to do (SB-INT:%HALT). Another is using

(define-alien-routine ("ldb_monitor" ldb-monitor) void)
and
(ldb-monitor)
to enter ldb gracefully. You can use
exit
to exit ldb and return to the REPL when you're done. Note that this won't work in ILISP at the moment, because in ILISP, /dev/tty is not a valid device and ldb tries to open /dev/tty and fails, dropping into ldb, failing, etc. According to Matthias Koeppe? on the ILISP maling list, this can be worked around by setting ilisp-*process-connection-type* to t.

This page is linked from: gdb   PPC   runtime  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively