Hacking up a Furball

Sept. 1, 2006

This software comes with no binaries and NO WARRANTY.
Compile and use at your own risk.

Start with a tribble, an electric carving knife, a Van De Graf generator, some surgical thread...

No? Well then, we'll leave the cat alone also.

Screenshots, because you asked.

                       
Linux debug source                         DOS debug.com source

Linux debug README

Linux debug ChangeLog

In the mid '90s, when I was making a living writing real-time drivers for DOS, Win9x and WINNT (you there, stop snickering) I became enamored with a 'simple' program called debug.com. A debugger that disassembled executables, had breakpoints, step into and trace over and a builtin single line assembler.

I call debug.com 'simple' because it was only 20k in size. It was written in assembler. Simple one or two char commands and a command set that allowed easy use of all features.

Used it at times as a primitive IDE. Had a line editor, an assembler and a write memory to disk for the executable memory. Edit, assemble and save. Classic.

Download the DOS MASM source and origins, above.

At the same time I was doing real time drivers for linux, but using the IDEs that came with professional development systems of the time. e.g. WindRiver and I think the precursor to BlueLynx. Both of these had some kind of GUI wrapper around gdb. And therein lies the problem with linux debugging.

A brief excursion. 20 years ago someone put out a scale for rating UIs (way before the time of Mac). Had 4 grades of user interface and its availability:

1. User friendly               Mythical - non-existent
2. Abuser friendly          Uncommon - best available
3. User Rude                    Typical - most software
4. User Hostile                Too common - system software

Gdb is 1.5 meg of Bad User Interface. Somewhere around 'User Hostile'. For a GUI wrapper, add about 5M to 15M of language and library code to just do point and click selection. RMS is definitely into Free Software, the larger the better.

Though, to give RMS his due for gdb, 'bt' is invaluable. Worth learning how to load gdb and run a GPFing program just to get a BackTrace on the stack. For all other linux debugging see 'man printf'.

So when I switched over to running completely on FOSS, I lost a small love. Several years ago I encountered ALD (Assembly Language Debugger), a 100k simplified version of debug.com (I said, stop snickering) without the inline assembler.

With some minor hacking and in a bad light, got ALD-0.0.19 to operate in a manner that looked like the old debug. But only as an external inspection tool. Examine memory, registers and step/trace thru the code. Dynamic changes were limited to registers and data. No inline assembler or write changed code to disk.

That has now changed. I used a 3 year old version of ALD hacked up to present a usable interface and stuffed the core of NASM-0.98.33 into it. Does symbolic unassemble, single line assembly and write the modified debugee to disk.

BTW you might want to download and make the nasm documentation. Has formal definitions of all of the machine code mnemonics and operands.

Had to strip main(), the pre-processor, macros and symbol definitions from NASM. Just left the core assembler code, which is able to do one pass assembler with pre-defined symbols. The NASM core now uses the predefined debug symbols in the program header, if they are present, or absolute addresses otherwise.

The NASM code is not the latest and greatest. It is from a version that assembles a specific project I have been working on. Feel free to provide upgrades.

I now have a more than functional equivalent of debug.com. Linux debug does symbolic disassembly _and_ assembly.

And, yes, linux debug does write the modified executable back to disk.

Download linux debug source, above.

Unfortunately, the stripped binary is 240k. Thats what you get for writing a debugger in C. Why do you think I refer to it as a 'furball'?

Back to Modest Proposals

Email: "loveall at iinet.com".