MDB(1) MDB(1) NAME mdb - binary file editor SYNOPSIS mdb [ -w ] file [ command ] DESCRIPTION Mdb allows inspection of the contents of file. If the -w option is given, then modification of the contents is also allowed. Mdb accepts commands of the form [address] [, count] [command] If a command is given as an argument, then mdb will execute that command, otherwise it will read and execute commands from the standard input. If address is present then the current position, called `dot', is set to address. Initially dot is set to 0. Command is repeated count times with dot advancing between repetitions. The default count is 1. Address and count are expressions. Expressions Expressions take one of the following forms: . The value of dot. + The value of dot. ^ The value of dot. " The value of the last address typed. integer A number, decimal by default. A `0' prefix causes it to be interpreted as octal; a `0x' prefix causes it to be interpreted as hexadecimal. (expr) The value of the expression expr. Operators e1+e2 Integer addition. e1-e2 Integer subtraction. e1*e2 Integer multiplication. e1%e2 MDB(1) MDB(1) Integer division. (N.B. not modulus). e1|e2 Bitwise disjunction. e1&e2 Bitwise conjunction. Commands Commands have the following syntax: /f Locations starting at address in file are printed according to the format f. ?f Same as `/'. =f The value of address itself is printed according to the format f. A format consists of one or more characters that specify a style of printing. Each format fetches some data, prints it, and if the command is not `=', advances dot by the amount of data fetched. All data is assumed to be held in little- endian form (least significant byte first). o Print a two-byte integer in octal. O Print a four-byte integer in octal. d Print a two-byte integer in decimal. D Print a four-byte integer in decimal. u Print a two-byte integer in unsigned decimal. U Print a four-byte integer in unsigned decimal. b Print a single byte in hexadecimal. x Print a two-byte integer in hexadecimal. X Print a four-byte integer in hexadecimal. n Prints a newline. No data is fetched. + Increments dot by 1. No data is printed. - Decrements dot by 1. No data is printed. ^ Increments dot by the size of the last format encountered. c Prints a single byte as a character. C Prints a single byte as a printable character, converting it to backslash escaped hex if neces- sary. Other commands include: [?/]w value Write the two-byte value to the addressed loca- tion. [?/]W value Write the four-byte value to the addressed loca- tion. MDB(1) MDB(1) [?/]i Disassemble count instructions starting at address (dot by default). $modifier File must be a dis(6) file. Modifier is one of the following subcommands: D Print the descriptor section. h Print the file header. l Print the links section. i Print the import section. d Print the data section. H Print exception handler tables. s Print the name of the source file. SOURCE /appl/cmd/mdb.b SEE ALSO dis(6) BUGS Most of the more useful features of mdb's antecedent db are unimplemented. It is not possible to print strings or UTF-8 characters. As there is no ``native'' word format in Inferno, the assumption that all words are little-endian is hard to jus- tify.