Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sdb(CP) — Xenix 2.3.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

adb(CP)

a.out(F)

cc(CP)

core(F)

ld(CP)



     SDB(CP)                  XENIX System V                   SDB(CP)



     Name
          sdb - Invokes symbolic debugger.

     Syntax
          sdb [ objfil [ corfil [ directory:directory ]]]

     Description
          sdb is a symbolic debugger which can be used with C
          programs.

          Objfil is an executable program file which has been compiled
          with the -Zi (debug) option and linked with the -I option.
          The default for objfil is a.out.  Corfil is assumed to be a
          core image file produced after executing objfil; the default
          for corfil is core.  A ``-'' in place of corfil forces sdb
          to ignore any core image file.  The colon separated
          directory list is used to locate the source files used to
          build objfil.

          It is useful to know that at any time there is a current
          line and current file.  They are initially set to the first
          line in main().  The current line and file may be changed
          with the source file examination commands.

          Names of variables are written just as they are in C
          programs.  Variables local to a procedure may be accessed
          using the form procedure.variable.  If no procedure name is
          given, the procedure containing the current line is used by
          default.

          You can also refer to structure members as variable.member,
          pointers to structure members as variable->member and array
          elements as variable[number].  Pointers may be de-referenced
          by using the form pointer[0].  You can also use combinations
          of these forms.

          It is also possible to specify a variable by its address.
          You can use all forms of integer constants which are valid
          in C programs, so that addresses and numbers may be input in
          decimal, octal, or hexadecimal.

          Line numbers in source programs are referred to as
          filename:number or procedure:number.  In either case the
          number is relative to the beginning of the file.  If no
          procedure or filename is given, the current file is used by
          default.  If no number is given, the first line of the named
          procedure or file is used.

          There are several kinds of commands available to the sdb
          debugger as described in the following sections. sdb
          commands appear in boldface type. For all commands, items in
          brackets ([ ]) are optional.



     Page 1                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



        Data Examination Commands
          t      Displays a stack trace.

          T      Prints the top line of the stack trace.

          variable/[clm]

          Displays the value of variable according to length l and
          format m.  A numeric count c indicates that a region of
          memory, beginning at the address implied by variable, is to
          be displayed.  If l and m are omitted, sdb chooses a format
          suitable for the variable type as declared in the program.
          The length specifiers are:

          b   One byte

          h   Two bytes (half word)

          l   Four bytes (long word)


          Legal values for
               m are:

               c   Character

               d   Decimal

               u   Unsigned decimal

               o   Octal

               x   Hexadecimal

               f   32 bit single precision floating point

               g   64 bit single precision floating point

               s   Assumes variable is a string pointer and
                   prints characters starting at the address
                   pointed to by the variable.

               a   Prints characters starting at the variable's
                   address.

               i   Disassembles with numeric/symbolic addresses.

               The length specifiers are only effective with the
               formats c, d, u, o, and x.  If one of these formats is
               specified and l is omitted, the length defaults to two
               bytes.  If a numeric length specifier is used for the




     Page 2                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



               format variable then that many characters are printed.
               Otherwise, successive characters are printed until
               either a null byte is reached or 128 characters are
               printed.

          linenumber?[clm]

          Prints the value at the address from a.out or i space given
          by linenumber, according to the format lm.  The default
          format is i.

          variable=[lm]
          linenumber=[lm]
          number=[lm]

          Prints the address of variable or linenumber in the format
          specified by lm . If no format is given, then lx is used.
          The last variant of this command provides a convenient way
          to convert between decimal, octal, and hexadecimal.  A
          single number cannot be used as a line number because the
          command would be ambiguous; the proc:number form must be
          used.

          variable!value

          Sets variable to the given value.  The value may be any
          valid C expression.

          x    Displays the machine registers and current machine-
               language instruction.

          X    Displays the current machine-language instruction.

        Source File Examination Commands
          e    Displays current procedure and filenames.

          e procedure

          Sets the current file and current line to the file
          containing procedure.

          e filename

          Sets the current file and current line number to the first
          line in filename .

          /regular expression[/]

          Searches forward from the current line for a line containing
          a string matching regular expression as in ed(C).





     Page 3                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



          ?regular expression[?]

          Searches backward from the current line for a line
          containing a string matching regular expression as in ed(C).

          p    Prints the current line.

          z    Prints the current line followed by the next nine
               lines.  Sets the current line to the last line printed.

          w    Creates a window by printing ten lines around the
               current line.

          number

          Sets the current line to the given line number and displays
          the line.

          [count]+

          Advances the current line by count lines and display the new
          line.  If count is omitted, the default is one line.

          [count]-

          Retreats from the current line by count lines and display
          the new line.  If count is omitted, the default is one line.

        Execution Control Commands
          L    Load the program to be debugged but do not run it. If
               you wish to examine the initial values of memory
               locations before the program has started to run, or if
               you wish to disassemble portions of the program without
               actually running it, you must first enter the L
               command.

          [count] r [args]
          [count] R
               Runs the program with the given arguments.  The r
               command with no arguments reuses the previous arguments
               to the program while the R command runs the program
               with no arguments.  An argument beginning with < or >
               causes redirection for the standard input or output
               respectively.  If count is given, it specifies the
               number of breakpoints to be ignored.

          [linenumber] c [count]
          [linenumber] C [count]
               Continues after a breakpoint or interrupt.  If count is
               given, it specifies the number of breakpoints to be
               ignored.  C continues with the signal which caused the
               program to stop reactivated and c ignores it.  If a



     Page 4                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



               line number is specified then a temporary breakpoint is
               placed at the line and execution is continued.  The
               breakpoint is deleted when the command finishes.

          linenumber g [count]
               Continues after a breakpoint with execution resumed at
               the given line.  If count is given, it specifies the
               number of breakpoints to be ignored.

          [count] s
               Single steps.  Runs the program through count lines.
               If no count is given then the program is run for one
               line.

          [count] S
               Single steps but steps through subroutine calls.

          [count] i
               Machine-language single steps.  Runs the program
               through count machine-language instructions.  If no
               count is given then one machine-language instruction is
               executed.

          [count] I
               Machine-language single steps, but steps through call
               instructions.

          variable$m [count]
               Single steps (as with s) until the specified location
               is modified with a new value.  Count specifies the
               number of instructions to step; if omitted, count is
               effectively infinity.  The variable must be accessible
               from the current procedure.  Since this command is
               performed by software, it can be very slow.

          [level] v
               Switches verbose mode on and off, for use with single
               stepping with S, s, or m.  If level is omitted or is
               zero, then just the current source file and/or
               subroutine name is printed when either changes.  If
               level is one, each C source line is printed before it
               is executed; if level is two, each assembler line
               statement is also printed. The v command turns verbose
               mode off if it is on for any level.

          k    Kills the debugged program.

          procedure(arg1,arg2,...)
          procedure(arg1,arg2,...)/m
               Executes the named procedure with the given arguments.
               The second form causes the value to be returned by the
               procedure to be printed according to format m.  If no



     Page 5                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



               format is given, it defaults to d.

          [linenumber] b [commands]
               Sets a breakpoint at the given line.  If a procedure
               name without a line number is given (e.g., a breakpoint
               is placed at the first line in the procedure.  If no
               linenumber is given, a breakpoint is placed at the
               current line.  If no commands are given then execution
               stops just before the breakpoint and control is
               returned to sdb.  Otherwise the commands are executed
               when the breakpoint is encountered and execution
               continues.  Multiple commands are specified by
               separating them with semicolons.

          B    Prints a list of the currently active breakpoints.

          [linenumber] d
               Deletes a breakpoint at the given line.  If no
               linenumber is given, then the breakpoints are deleted
               interactively: each breakpoint location is printed and
               a line is read from the standard input.  If the line
               begins with a y or d, then the breakpoint is deleted.

          D    Deletes all breakpoints.

          l    Prints the last executed line.  Makes the last executed
               line the current line.

          linenumber a
               Announces.  If linenumber is of the form proc:number or
               number, the command effectively does a linenumber b l.
               If linenumber is of the form proc:, the command
               effectively does a proc: b T.

        Miscellaneous Commands
          !command
               Interprets command.  Command interpreter executes
               command.

          newline
               Advances the current line by one line and prints the
               new current line if the previous command printed a
               source line.  Displays the next memory location if the
               previous command displayed a memory location.

          Ctrl-D
               Scrolls. Prints the next ten lines of instructions,
               source or data depending on which was printed last.

          < filename
               Reads commands from filename until the end of file is
               reached, and then continues to accept commands from



     Page 6                                           (printed 8/7/87)





     SDB(CP)                  XENIX System V                   SDB(CP)



               standard input.  When sdb is told to display a variable
               by a command in such a file, the variable name is
               displayed along with the value.  This command may not
               be nested; the redirection character (<) may not appear
               as a command in a file.

          "string
               Prints the given string.  The C escape sequences of the
               form \character are recognized, where character is a
               non-numeric character.

          q    Exits the debugger.

        Debugger Commands
          V    Prints the version number.

          Q    Prints a list of procedures and files being debugged.

     Files
          a.out
          core

     See Also
          adb(CP), a.out(F), cc(CP), core(F), ld(CP)

     Notes
          In order to make use of the symbolic debugging features of
          sdb, the program being debugged must have been compiled with
          the -Zi option. sdb does not use the ordinary symbol table
          information in an a.out file and has limited facilities for
          debugging at the machine code level. If you have to debug a
          program that has been compiled without using the -Zi option,
          it may be preferable to use adb.






















     Page 7                                           (printed 8/7/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026