db(1) - Unix First Edition Manual Page
11/3/71DB (I)

NAME db -- debug
SYNOPSIS db [ core [ namelist ] ]
DESCRIPTION Unlike many debugging packages (including DEC's ODT, on whichdb is loosely based) db is not loaded as part of the core

image which it is used to examine; instead it examines files.Typically, the file will be either a core image produced after a fault or the binary output of the assembler. Core isthe file being debugged; if omitted "core" is assumed. namelist is a file containing a symbol table. If it isomitted, a.out is the default. If no appropriate name list file can be found, db can still be used but some of itssymbolic facilities become unavailable.

The format for most db requests is an address followed by aone character command.

Addresses are expressions built up as follows:

1. A name has the value assigned to it when the inputfile was assembled. It may be relocatable or not

depending on the use of the name during the assembly. 2. An octal number is an absolute quantity with theappropriate value.

3. An octal number immediately followed by "r" is arelocatable quantity with the appropriate value. 4. The symbol "." indicates the current pointer of db.The current pointer is set by many requests. 5. Expressions separated by "+" or " "(blank) areexpressions with value equal to the sum of the

components. At most one of the components may berelocatable.

6. Expressions separated by "--" form an expression withvalue equal to the difference to the components. If

the right component is relocatable, the leftcomponent must be relocatable.

7. Expressions are evaluated left to right. Names forregisters are built in:

r0 ... r5sp


11/3/71DB (I)

acmq These may be examined. Their values are deduced from thecontents of the stack in a core image file. They are meaningless in a file that is not a core image.

If no address is given for a command, the current address(also specified by ".") is assumed. In general, . points to the last word or byte printed by ~. There are db commands for examining locations interpreted asoctal numbers, machine instructions, ASCII characters, and addresses. For numbers and characters, either bytes or wordsmay be examined. The following commands are used to examine the specified file.

/ The addressed word is printed in octal. \ The addressed byte is printed in octal.

" The addressed word is printed as two ASCIIcharacters.

' The addressed byte is printed as an ASCII character. ` The addressed word is multiplied by 2, then printed inoctal (used with B programs,

whose addresses are word addresses). ? The addressed word is interpreted as a machineinstruction and a symbolic form of the instruction,

including symbolic addresses, is printed. Usually, theresult will appear exactly as it was written in the source program. & The addressed word is interpreted as a symbolicaddress and is printed as the name of the symbol whose

value is closest to the addressed word, possiblyfollowed by a signed offset.

(i. e., the character "new line") This command

advances the current location counter * and prints theresulting location in the mode last specified by one

of the above requests. This character decrements "." and prints the resultinglocation in the mode last selected one of the above requests. It is

11/3/71DB (I)

a converse to . It is illegal for the word--oriented commands to have oddaddresses. The incrementing and decrementing of "." done by the and requests is by one or two depending on whetherthe last command was word or byte oriented.

The address portion of any of the above commands may befollowed by a comma and then by an expression. In this case that number of sequential words or bytes specified by theexpression is printed. "."is advanced so that it points at the last thing printed.

There are two commands to interpret the value ofexpressions.

= When preceded by an expression, the value of theexpression is typed in octal. When not preceded by an

expression, the value of. "." is indicated. Thiscommand does not change the value of ".".

: An attempt is made to print the given expression as asymbolic address. If the expression is relocatable,

that symbol is found whose value is nearest that ofthe expression, and the symbol is typed, followed by a sign and the appropriate offset. If the value of theexpression is absolute, a symbol with exactly the indicated value is sought and printed if found; if nomatching symbol is discovered, the octal value of the expression is given. The following command may be used to patch the file beingdebugged.

! This command must be preceded by an expression. Thevalue of the expression is stored at the location

addressed by the current value of "." . The opcodes donot appear in the symbol table, so the user must assemble them by hand.

The following command is used after a fault has caused a coreimage file to be produced.

$ causes the contents of the general registers andseveral other registers to be printed both in octal

and symbolic format. The values are as they were atthe time of the fault.

11/3/71DB (I)

The only way to exit from db is to generate an end of fileon the typewriter (EOT character).
SEE_ALSO as; core for format of core image.

DIAGNOSTICS "File not found" the first argument cannot be read;otherwise "?"

BUGS Really, db should know about relocation bits, floating pointoperations, and PDP11/45 instructions.